Beispiel #1
0
 public void getQuote(oldIRCClient _irc, string msg)
 {
     string[] helper = msg.Split(new char[]{' '}, 2);
     if(helper.Length >1)
     {
         int id = ResolveFilter(helper[1]);
         if (id == -1)
         {
             _irc.sendChatMessage("No quote found");
         }
         else
         {
             _irc.sendChatMessage(id.ToString() + ". " + quotelist[id]);
         }
     }
     else
     {
         if (quotelist.Count == 0)
         {
             _irc.sendChatMessage("There are no quotes!");
         }
         else
         {
             int ID = rnd.Next(0, quotelist.Count);
             string[] quote = quotelist[ID].Split(new char[] { ':' }, 2);
             _irc.sendChatMessage("\"" + quote[1] + "\" by " + quote[0]);
         }
     }
 }
Beispiel #2
0
        public void AddIntervalMessage(oldIRCClient _irc, ReadMessage msg)
        {
            if(_irc.moderators.Contains(msg.user))
            {
                string[] temp = msg.message.Split(new char[] { ' ' }, 2);
                string[] helper = temp[1].Split(new char[] { ':' }, 2);

                int intervalMin = -1;
                if(helper.Length == 2)
                {
                    if (int.TryParse(helper[0], out intervalMin))
                    {
                        time.Add(intervalMin);
                        srcTime.Add(intervalMin);
                        intervalMessage.Add(helper[1]);
                        _irc.sendChatMessage("\"" + helper[1] + "\" with interval of " + intervalMin.ToString() + " minute(s)");
                    }
                    else
                    {
                        _irc.sendChatMessage("Failed to convert the minutes. Wrong syntax?");
                    }
                }
                else
                {
                    _irc.sendChatMessage("Wrong syntax!! It's \"Number:Message\"");
                }
            }
            else
            {
                _irc.sendChatMessage(msg.user + ": Insufficient rights!");
            }
        }
Beispiel #3
0
        public void AddCoins(oldIRCClient irc, ReadMessage msg)
        {
            if (irc.moderators.Contains(msg.user))
            {
                string[] helper = msg.message.Split(new char[] { ' ' }, 3);
                uint coinsVal;
                Tuple<uint, DateTime> values;

                if (uint.TryParse(helper[2], out coinsVal))
                {
                    if (userCoins.ContainsKey(helper[1].ToLower()))
                    {
                        values = userCoins[helper[1].ToLower()];
                        Tuple<uint, DateTime> newValues = new Tuple<uint, DateTime>(values.Item1 + coinsVal, values.Item2);
                        userCoins[helper[1].ToLower()] = newValues;
                        irc.sendChatMessage(msg.user + ": Added " + coinsVal.ToString() + " coin(s) to a user " + helper[1]);
                    }
                    else
                    {
                        irc.sendChatMessage("No user under this name found");
                    }
                }
                else
                {
                    irc.sendChatMessage("Failed to convert the coins value. Wrong syntax?");
                }
            }
            else
            {
                irc.sendChatMessage("You don't have permissions to perform this command");
            }
        }
Beispiel #4
0
        public void betAnswer(oldIRCClient irc, ReadMessage msg)
        {
            if (irc.moderators.Contains(msg.user))
            {
                if(!betRunning)
                {
                    if(betType == (byte)eBetType.Value)
                    {
                        string[] helper = msg.message.Split(new char[] { ' ' }, 2);
                        if (helper[1] != String.Empty)
                        {
                            int answer = 0;
                            if (int.TryParse(helper[1], out answer))
                            {
                                betEnded = true;
                                irc.sendChatMessage("Answer is: " + answer.ToString() + ". If this is correct, do \"!betWinners \"" );
                            }
                            else
                                irc.sendChatMessage("Failed to parse the answer. Has to be Int value");
                        }
                        else
                            irc.sendChatMessage("No answer provided!");

                    }
                    else if(betType == (byte)eBetType.Time)
                    {

                    }
                }
                else
                {
                    irc.sendChatMessage("A bet is currently running.");
                }
            }
        }
Beispiel #5
0
 public ViewerPB(oldIRCClient _irc)
 {
     irc = _irc;
     if(File.Exists(Path.Combine(directory, userInfoFile)))
     {
         loadData();
     }
 }
Beispiel #6
0
        public void PlaySlots(oldIRCClient irc, ReadMessage msg)
        {
            if(irc.dynamicDelayCheck())
            {
                Tuple<uint, DateTime> values;

                double timedifference;

                if (userCoins.ContainsKey(msg.user))
                {
                    values = userCoins[msg.user];
                }
                else
                {
                    values = new Tuple<uint, DateTime>(irc.SlotsInitialCoins, DateTime.MinValue);
                    userCoins.Add(msg.user, values);
                }

                timedifference = (DateTime.UtcNow - values.Item2).TotalSeconds;

                if (timedifference < irc.GamesDelay)
                {
                    irc.sendChatMessage(msg.user + ": You have to wait " + (Math.Round((values.Item2 - DateTime.UtcNow).TotalSeconds + irc.GamesDelay, 2)).ToString() + " second(s).");
                }
                else
                {
                    string[] helper = msg.message.Split(new char[] { ' ' }, 2);
                    uint coinsBet = 0;
                    if (uint.TryParse(helper[1], out coinsBet))
                    {
                        if (coinsBet > values.Item1)
                        {
                            irc.sendChatMessage(msg.user + ": You don't have that many coins!");
                        }
                        else
                        {
                            int[] results = new int[3];
                            results[0] = rnd.Next(0, emotes.Length);
                            results[1] = rnd.Next(0, emotes.Length);
                            results[2] = rnd.Next(0, emotes.Length);
                            if (results[0] == results[1] && results[0] == results[2])
                            {
                                irc.sendChatMessage(msg.user + ": " + emotes[results[0]] + " , " + emotes[results[1]] + " , " + emotes[results[2]] + " - Congratulations, you win " + (coinsBet * 100).ToString() + " coin(s)!");
                                Tuple<uint, DateTime> newValues = new Tuple<uint, DateTime>(values.Item1 + coinsBet * 100, DateTime.UtcNow);
                                userCoins[msg.user] = newValues;
                            }
                            else
                            {
                                irc.sendChatMessage(msg.user + ": " + emotes[results[0]] + " , " + emotes[results[1]] + " , " + emotes[results[2]] + " - you lose, " + coinsBet.ToString() + " coin(s)!");
                                Tuple<uint, DateTime> newValues = new Tuple<uint, DateTime>(values.Item1 - coinsBet, DateTime.UtcNow);
                                userCoins[msg.user] = newValues;
                            }
                        }
                    }
                }
            }
        }
Beispiel #7
0
        public Blacklist(oldIRCClient _irc)
        {
            irc = _irc;
            if (File.Exists(filterFile))
            {
                loadBlacklist();
            }

            if (File.Exists(Path.Combine(directory, userInfoFile)))
            {
                loadUserInfo();
            }
        }
Beispiel #8
0
 public void callVote(oldIRCClient irc, ReadMessage msg)
 {
     if (irc.moderators.Contains(msg.user))
     {
         string[] helper = msg.message.Split(new char[] { ' ' }, 2);
         if (!voteActive)
         {
             voteObjective = helper[1];
             irc.sendChatMessage("Vote object set to: '" + voteObjective + "'.");
             userVoted.Clear();
             voteOptions.Clear();
         }
         else
         {
             irc.sendChatMessage("A vote is currently active. Please close the vote, first.");
         }
     }
 }
Beispiel #9
0
        public void DisplayCoins(oldIRCClient irc, ReadMessage msg)
        {
            if(irc.dynamicDelayCheck())
            {
                Tuple<uint, DateTime> values;

                if (userCoins.ContainsKey(msg.user))
                {
                    values = userCoins[msg.user];
                }
                else
                {
                    values = new Tuple<uint, DateTime>(irc.SlotsInitialCoins, DateTime.MinValue);
                    userCoins[msg.user] = values;
                }
                irc.sendChatMessage(msg.user + ": You have " + values.Item1.ToString() + " coin(s).");
            }
        }
Beispiel #10
0
        public void getQuotebyID(oldIRCClient _irc, ReadMessage msg)
        {
            int id = GetIDFromString(msg.message);

            if(id == -1)
            {
                _irc.sendChatMessage("Failed to convert ID. Syntax incorrect?");
            }
            else if(id>quotelist.Count-1)
            {
                _irc.sendChatMessage("Wrong ID (outside of a list)!");
            }
            else
            {
                string[] quote = quotelist[id].Split(new char[] { ':' }, 2);
                _irc.sendChatMessage("\"" + quote[1] + "\" by " + quote[0]);
            }
        }
        public void addCustomCvar(oldIRCClient irc, ReadMessage msg)
        {
            if(irc.moderators.Contains(msg.user))
            {
                string[] start = msg.message.Split(new char[] { ' ' }, 2);
                int indexOfColon = start[1].IndexOf(':');
                int indexOfComa = start[1].IndexOf(',');

                if(indexOfColon> 0)
                {
                    if(indexOfComa > 0 && indexOfComa < indexOfColon)
                    {
                        int numberOfCvars = 1;                                                          //The beginning of it, is making sure program gets the part before the first Colon.
                        for (int i = 0; i < indexOfColon; i++)                                          //Example: You have bitch,t**s,hits:This,message
                        {                                                                               //So here, we make sure we get:
                            if(start[1].ElementAt(i) == ',')                                            //helper[0] = bitch
                            {                                                                           //helper[1] = t**s
                                numberOfCvars++;                                                        //helper[2] = hits:This,message
                            }
                        }
                        string[] helper = start[1].Split(new char[]{','}, numberOfCvars);
                        string[] lastPart = helper[helper.Length - 1].Split(new char[]{':'}, 2);        //Split out "hits:This,message" to:
                        for (int i = 0; i < helper.Length - 1; i++)                                     //lastpart[0] = hits
                        {                                                                               //lastpart[1] = This,message
                            cvarslist.Add(helper[i].ToLower(), lastPart[1]);                            //And finally add everything to Dictionary.
                        }
                        cvarslist.Add(lastPart[0].ToLower(), lastPart[1]);

                        irc.sendChatMessage("Custom cvar added!");
                    }
                    else
                    {
                        string[] lastPart = start[1].Split(new char[] { ':' }, 2);
                        cvarslist.Add(lastPart[0].ToLower(), lastPart[1]);

                        irc.sendChatMessage("Custom cvar added!");
                    }
                }
                else
                    irc.sendChatMessage("Failed to add custom cvar. Invalid syntax?");
                saveCvarsToFile();
            }
        }
        public void cvarPerform(oldIRCClient irc, ReadMessage msg)
        {
            if(msg.message.Length>2)
            {
                string helper = msg.message.Substring(1, msg.message.Length - 1).ToLower();

                if (cvarslist.ContainsKey(helper))
                {
                    string message;
                    cvarslist.TryGetValue(helper, out message);
                    irc.sendChatMessage(message);
                }
                else if (irc.moderators.Contains(msg.user) && restrictedCvars.ContainsKey(helper))
                {
                    string message;
                    restrictedCvars.TryGetValue(helper, out message);
                    irc.sendChatMessage(message);
                }
            }
        }
Beispiel #13
0
        public void callBet(oldIRCClient irc, ReadMessage msg)
        {
            if(irc.moderators.Contains(msg.user))
            {
                if (!betRunning)
                {
                    string[] message = msg.message.Split(new char[] { ' ' }, 2);

                    betDataValue.Clear();
                    betDataTime.Clear();
                    betEnded = false;

                    if (message[1] != String.Empty)
                    {
                        objective = message[1];
                        irc.sendChatMessage("New bet (Int Value): " + objective);
                    }
                }
                else
                    irc.sendChatMessage("A bet is already running. Close the bet first!");
            }
        }
Beispiel #14
0
 public void addQuote(oldIRCClient _irc, ReadMessage MSG)
 {
     if(_irc.moderators.Contains(MSG.user))
     {
         int personNameStart = MSG.message.IndexOf(' ');
         int quoteStart = MSG.message.IndexOf(':');
         if (personNameStart > 0 && quoteStart > 0)
         {
             string[] helper = MSG.message.Split(new char[] { ' ' }, 2);
             quotelist.Add(helper[1]);
             saveQuotes();
             _irc.sendChatMessage(quotelist[quotelist.Count - 1]);
         }
         else
         {
             _irc.sendChatMessage("Invalid syntax");
         }
     }
     else
     {
         _irc.sendChatMessage("You don't have permissions to perform this command");
     }
 }
Beispiel #15
0
 public void removeQuote(oldIRCClient irc, ReadMessage msg)
 {
     if(irc.moderators.Contains(msg.user))
     {
         int id = GetIDFromString(msg.message);
         if (id == -1)
         {
             irc.sendChatMessage("Wrong syntax");
         }
         else if (id > quotelist.Count - 1)
         {
             irc.sendChatMessage("Wrong id");
         }
         else
         {
             irc.sendChatMessage("Removed (" + id.ToString() + "): " + quotelist[id]);
             quotelist.RemoveAt(id);
         }
     }
     else
     {
         irc.sendChatMessage("You don't have permissions to perform this command");
     }
 }
Beispiel #16
0
        public void getWinners(oldIRCClient irc, ReadMessage msg)
        {
            if(betEnded)
            {
                if(!resultsCalculated)
                {

                }
            }
            else
            {

            }
        }
Beispiel #17
0
 public void openBet(oldIRCClient irc, ReadMessage msg)
 {
     if (irc.moderators.Contains(msg.user))
     {
         if (!betRunning)
         {
             betRunning = true;
             irc.sendChatMessage("Bets are now opened.");
         }
         else
             irc.sendChatMessage("A bet is already running.");
     }
 }
Beispiel #18
0
        public void playerBets(oldIRCClient irc, ReadMessage msg)
        {
            Tuple<uint, DateTime> values;

            double timedifference;

            if (userCoins.ContainsKey(msg.user))
            {
                values = userCoins[msg.user];
            }
            else
            {
                values = new Tuple<uint, DateTime>(irc.SlotsInitialCoins, DateTime.MinValue);
                userCoins.Add(msg.user, values);
            }

            if(betType == (byte)eBetType.Value)
            {
                timedifference = (DateTime.UtcNow - values.Item2).TotalSeconds;

                if (timedifference < irc.GamesDelay)
                {
                    irc.sendChatMessage(msg.user + ": You have to wait " + (Math.Round((values.Item2 - DateTime.UtcNow).TotalSeconds + irc.GamesDelay, 2)).ToString() + " second(s).");
                }
                else
                {
                    if (msg.message.IndexOf(' ') > 0 && msg.message.IndexOf(':') > 0)
                    {
                        int betOn;
                        uint valueCoins;
                        string[] message = msg.message.Split(new char[] { ' ' }, 2);
                        string[] helper = message[1].Split(new char[] { ':' }, 2);
                        if (uint.TryParse(helper[0], out valueCoins) && int.TryParse(helper[1], out betOn))
                        {
                            if (values.Item1 > valueCoins)
                            {
                                Tuple<uint, int> userBet = new Tuple<uint, int>(valueCoins, betOn);
                                betDataValue.Add(msg.user, userBet);
                                Tuple<uint, DateTime> newValues = new Tuple<uint, DateTime>(values.Item1 - valueCoins, DateTime.Now);
                                userCoins[msg.user] = newValues;
                                irc.sendChatMessage(msg.user + ": You've bet " + valueCoins.ToString() + " coin(s) on " + betOn.ToString());
                            }
                            else
                                irc.sendChatMessage(msg.user + ": You don't have enough coins!");
                        }
                        else
                            irc.sendChatMessage(msg.user + ": Failed to convert values. The syntax is: !bet 'amount of coins':'value you bet on'");
                    }
                }
            }
        }
Beispiel #19
0
        public void displayResults(oldIRCClient irc, ReadMessage msg)
        {
            if (irc.moderators.Contains(msg.user))
            {
                int numberOfVotes = userVoted.Count;
                if (voteActive)
                {
                    irc.sendChatMessage("A vote is currently active. Close the vote, first!");
                }
                else
                {
                    if (voteObjective != String.Empty && numberOfVotes > 0)
                    {
                        irc.sendChatMessage_NoDelays("Results for: '" + voteObjective + "' are:");

                        uint[] results = new uint[voteOptions.Count];
                        foreach(uint element in userVoted.Values)
                        {
                            results[element]++;
                        }
                        int[] resultsNum = new int[3] { -1, -1, -1 };
                        string[] resultOption = new string[3];

                        resultsNum[0] = -1;
                        resultOption[0] = "";

                        for (int i = 0; i < results.Length; i++)
                        {
                            if (resultsNum[0] < results[i])
                            {
                                resultsNum[2] = resultsNum[1];
                                resultOption[2] = resultOption[1];
                                resultsNum[1] = resultsNum[0];
                                resultOption[1] = resultOption[0];
                                resultsNum[0] =  (int)results[i];
                                resultOption[0] = voteOptions[i];
                            }
                            else if (resultsNum[1] < results[i])
                            {
                                resultsNum[2] = resultsNum[1];
                                resultOption[2] = resultOption[1];
                                resultsNum[1] = (int)results[i];
                                resultOption[1] = resultOption[i];
                            }
                            else if (resultsNum[2] < results[i])
                            {
                                resultsNum[2] = (int)results[i];
                                resultOption[2] = resultOption[i];
                            }
                        }

                        for (int i = 0; i < 3; i++)
                        {
                            if (resultsNum[i] > 0)
                            {
                                double prec = Math.Round(((resultsNum[i] * 1.0 / numberOfVotes) * 100), 2);
                                irc.sendChatMessage_NoDelays((i+1).ToString() + ". " + resultOption[i] + " (" + prec.ToString() + "%).");
                            }
                        }
                    }
                    else
                    {
                        irc.sendChatMessage("Vote results are empty. There was no voting in this session?");
                    }
                }
            }
        }
Beispiel #20
0
 public void voteOpen(oldIRCClient irc, ReadMessage msg)
 {
     if (irc.moderators.Contains(msg.user))
     {
         if (!voteActive)
         {
             voteActive = true;
             irc.sendChatMessage_NoDelays("Vote opened: " + voteObjective);
             for (int i = 0; i < voteOptions.Count; i++)
             {
                 irc.sendChatMessage_NoDelays((i + 1).ToString() + ". " + voteOptions[i]);
             }
         }
         else
         {
             irc.sendChatMessage("No vote is currently active.");
         }
     }
 }
Beispiel #21
0
        public void setBetType(oldIRCClient irc, ReadMessage msg)
        {
            if(irc.moderators.Contains(msg.user))
            {
                if(!betRunning)
                {
                    string[] message = msg.message.Split(new char[] { ' ' }, 2);

                    if (message[1] != String.Empty)
                    {
                        if(message[1].StartsWith("Time", StringComparison.InvariantCultureIgnoreCase))
                        {
                            betType = (byte)eBetType.Time;
                            betEnded = false;
                            results.Clear();
                            betDataTime.Clear();
                            betDataValue.Clear();
                            irc.sendChatMessage("Betting type set to: Time");
                        }
                        else if(message[1].StartsWith("Number", StringComparison.InvariantCultureIgnoreCase) || message[1].StartsWith("Value", StringComparison.InvariantCultureIgnoreCase)|| message[1].StartsWith("default", StringComparison.InvariantCultureIgnoreCase))
                        {
                            betType = (byte)eBetType.Value;
                            betEnded = false;
                            results.Clear();
                            betDataTime.Clear();
                            betDataValue.Clear();
                            irc.sendChatMessage("Betting type set to: Number (Int)");
                        }
                        else
                        {
                            irc.sendChatMessage("No changes were made");
                        }

                    }
                    else
                        irc.sendChatMessage("Empty string? Should be either a 'number' or 'time'");

                }
                else
                    irc.sendChatMessage("A bet is already running. Close the bet first!");
            }
        }
Beispiel #22
0
 public void getNumberOfQuotes(oldIRCClient irc)
 {
     irc.sendChatMessage("Number of elements: " + quotelist.Count.ToString());
 }
Beispiel #23
0
 public void displayVote(oldIRCClient irc, ReadMessage msg)
 {
     if (irc.moderators.Contains(msg.user) || irc.trustedUsers.Contains(msg.user))
     {
         if (voteActive)
         {
             irc.sendChatMessage_NoDelays(voteObjective);
             for (int i = 0; i < voteOptions.Count; i++)
             {
                 irc.sendChatMessage_NoDelays((i + 1).ToString() + ". " + voteOptions[i]);
             }
         }
     }
 }
        private void responsedToQuestion(oldIRCClient irc, string user)
        {
            int id;
            id = rnd.Next(0, Fortunes.Length);
            irc.sendChatMessage(user + ": " + Fortunes[id]);

            _fortune[user] = new Tuple<DateTime, bool>(DateTime.UtcNow, false);
        }
Beispiel #25
0
 public void setOptions(oldIRCClient irc, ReadMessage msg)
 {
     if (irc.moderators.Contains(msg.user))
     {
         voteOptions.Clear();
         string[] starter = msg.message.Split(new char[] { ' ' }, 2);
         var count = starter[1].Count(x => x == ':');
         if (count > 0)
         {
             string[] voteOptionsTemp = starter[1].Split(':');
             for (int i = 0; i < voteOptionsTemp.Length; i++)
             {
                 voteOptions.Add(voteOptionsTemp[i]);
             }
         }
         else
         {
             irc.sendChatMessage("There have to be at least 2 options!");
         }
     }
 }
Beispiel #26
0
        public void answerAsk(oldIRCClient irc, ReadMessage msg)
        {
            string[] helper = msg.message.Split(new char[] { ' ' }, 2);
            DateTime lastSendMsg = DateTime.UtcNow;
            bool _notified = false;
            double timedifference;

            if(_ask.ContainsKey(msg.user))
            {
                var temp = _ask[msg.user];
                lastSendMsg = temp.Item1;
                _notified = temp.Item2;
            }
            else
            {
                lastSendMsg = DateTime.MinValue;
                _notified = false;
                _ask.Add(msg.user, new Tuple<DateTime,bool>(lastSendMsg, _notified));
            }

            if(irc.dynamicDelayCheck())
            {
                if (!irc.safeAskMode)
                {
                    timedifference = (DateTime.UtcNow - lastSendMsg).TotalSeconds;

                    if (timedifference < irc.GamesDelay)
                    {
                        if (!_notified)
                        {
                            var temp = _ask[msg.user];
                            temp = new Tuple<DateTime, bool>(temp.Item1, true);
                            irc.sendChatMessage(msg.user + ": You have to wait " + (Math.Round((lastSendMsg - DateTime.UtcNow).TotalSeconds + irc.GamesDelay, 2)).ToString() + " second(s).");
                            _ask[msg.user] = temp;
                        }
                    }
                    else
                    {
                        responsedToQuestion(irc, msg.user, helper[1]);
                    }
                }
                else
                {
                    if (irc.moderators.Contains(msg.user))
                    {
                        timedifference = (DateTime.UtcNow - lastSendMsg).TotalSeconds;

                        if (timedifference < irc.GamesDelay)
                        {
                            if (!_notified)
                            {
                                var temp = _ask[msg.user];
                                temp = new Tuple<DateTime, bool>(temp.Item1, true);
                                irc.sendChatMessage(msg.user + ": You have to wait " + (Math.Round((lastSendMsg - DateTime.UtcNow).TotalSeconds + irc.GamesDelay, 2)).ToString() + " second(s).");
                                _ask[msg.user] = temp;
                            }
                        }
                        else
                        {
                            responsedToQuestion(irc, msg.user, helper[1]);
                        }
                    }
                }
            }
        }
Beispiel #27
0
        private void responsedToQuestion(oldIRCClient irc, string user, string question)
        {
            int id;
            string response;
            if ((response = uniqueQuestion(user, question)) != String.Empty)
            {
                irc.sendChatMessage(user + ": " + response);
            }
            else if (question.StartsWith("When", StringComparison.InvariantCultureIgnoreCase))
            {
                id = rnd.Next(0, AnswersTime.Length);
                irc.sendChatMessage(user + ": " + AnswersTime[id]);
            }
            else if (question.StartsWith("What", StringComparison.InvariantCultureIgnoreCase) || question.StartsWith("Wat", StringComparison.InvariantCultureIgnoreCase))
            {
                id = rnd.Next(0, AnswersItem.Length);
                irc.sendChatMessage(user + ": " + AnswersItem[id]);
            }
            else if (question.StartsWith("Who", StringComparison.InvariantCultureIgnoreCase))
            {
                id = rnd.Next(0, AnswersPerson.Length);
                irc.sendChatMessage(user + ": " + AnswersPerson[id]);
            }
            else if (question.StartsWith("Where", StringComparison.InvariantCultureIgnoreCase))
            {
                id = rnd.Next(0, AnswersPlace.Length);
                irc.sendChatMessage(user + ": " + AnswersPlace[id]);
            }
            else if (question.StartsWith("Why", StringComparison.InvariantCultureIgnoreCase))
            {
                id = rnd.Next(0, AnswersWhy.Length);
                irc.sendChatMessage(user + ": " + AnswersWhy[id]);
            }
            else if (question.Contains("or"))
            {
                irc.sendChatMessage(user + ": " + respond_to_this_or_that(question));
            }
            else
            {
                id = rnd.Next(0, AnswersGeneric.Length);
                irc.sendChatMessage(user + ": " + AnswersGeneric[id]);
            }

            _ask[user] = new Tuple<DateTime, bool>(DateTime.UtcNow, false);
        }
Beispiel #28
0
 public void Vote(oldIRCClient irc, ReadMessage msg)
 {
     if (voteActive)
     {
         if (!userVoted.ContainsKey(msg.user))
         {
             uint value;
             string[] helper = msg.message.Split(new char[] { ' ' }, 2);
             if (uint.TryParse(helper[1], out value))
             {
                 value--;
                 if (value >= 0 && value < voteOptions.Count)
                 {
                     userVoted.Add(msg.user, value);
                     Console.WriteLine("User " + msg.user + " voted for " + (value + 1).ToString());
                 }
             }
         }
         else
         {
             uint value;
             string[] helper = msg.message.Split(new char[] { ' ' }, 2);
             if (uint.TryParse(helper[1], out value))
             {
                 value--;
                 if (value >= 0 && value < voteOptions.Count)
                 {
                     userVoted[msg.user] = value;
                     Console.WriteLine("User " + msg.user + " changed his vote to: " + (value + 1).ToString());
                 }
             }
         }
     }
     else
         irc.sendChatMessage("There is no currently active vote!");
 }
Beispiel #29
0
        static void Main(string[] args)
        {
            string _cachedMessage = "";

            Console.CancelKeyPress += Console_CancelKeyPress;       //Some additional events
            irc = new oldIRCClient();
            if (!irc.configFileExisted)
            {
                Console.WriteLine("No config file found. An example config file was created");
                System.Environment.Exit(1);
            }

            initBot();

            if (irc.intervalMessagesEnabled)
            {
                _intervals.sendIrc(irc, _jsonStatus);
                _timer.Start();
                _timer.Elapsed += new System.Timers.ElapsedEventHandler(_intervals.timerSender);
            }
            for(int i=0; i<args.Length; i++)
            {
                if(args[i] == "+msg")
                {
                    i++;
                    while(i < args.Length && !args[i].StartsWith("+"))
                    {
                        _cachedMessage += args[i] + " ";
                        i++;
                    }
                    i--;
                }
            }
            cachedMessage = _cachedMessage;
            irc.meebyIrc.Listen();
        }
Beispiel #30
0
 public void voteClose(oldIRCClient irc, ReadMessage msg)
 {
     if (irc.moderators.Contains(msg.user))
     {
         if (voteActive)
         {
             voteActive = false;
             irc.sendChatMessage("'" + voteObjective + "' voting closed.");
         }
         else
         {
             irc.sendChatMessage("No vote is currently active.");
         }
     }
 }