Exemplo n.º 1
0
        public bool checkForSpam(ReadMessage msg)
        {
            string message = msg.message.ToLower();

            if(msg.user != String.Empty)
            {
                if (!allowedToPostLinks.ContainsKey(msg.user))
                {
                    allowedToPostLinks.Add(msg.user, 0);
                }

                if (allowedToPostLinks[msg.user] < allowedToPostLinksRequirement && isLink(message))
                {
                    return true;
                }

                if (blacklist_fullphrase.Contains(message))
                    return true;
                else if (blacklist_startswith.Any(s => message.StartsWith(s)))
                    return true;
                else if (blacklist_endswith.Any(s => message.EndsWith(s)))
                    return true;
                else if (blacklist_words.Any(s => message.Contains(s)))
                    return true;
                else
                {
                    if (allowedToPostLinks[msg.user] < allowedToPostLinksRequirement)
                        allowedToPostLinks[msg.user]++;
                    return false;
                }
            }
            return false;
        }
Exemplo n.º 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!");
            }
        }
Exemplo n.º 3
0
 internal void displayViewerPB(ReadMessage msg)
 {
     if(irc.moderators.Contains(msg.user))
     {
         irc.sendChatMessage("Viewer PB for this channel is: " + viewerPB.ToString());
     }
 }
Exemplo n.º 4
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");
            }
        }
Exemplo n.º 5
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.");
                }
            }
        }
Exemplo n.º 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;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 7
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]);
            }
        }
Exemplo n.º 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.");
         }
     }
 }
Exemplo n.º 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).");
            }
        }
Exemplo n.º 10
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();
            }
        }
Exemplo n.º 11
0
        public bool checkForBanWorthyContent(ReadMessage msg)
        {
            string message = msg.message.ToLower();

            if (msg.user != String.Empty)
            {
                if (blacklist_ban_fullphrase.Contains(message))
                    return true;
                else if (blacklist_ban_startswith.Any(s => message.StartsWith(s)))
                    return true;
                else if (blacklist_ban_endswith.Any(s => message.EndsWith(s)))
                    return true;
                else if (blacklist_ban_words.Any(s => message.Contains(s)))
                    return true;
                else
                    return false;
            }
            return false;
        }
Exemplo n.º 12
0
        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);
                }
            }
        }
Exemplo n.º 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!");
            }
        }
Exemplo n.º 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");
     }
 }
Exemplo n.º 15
0
 internal void DeathCounterDisplay(ReadMessage formattedMessage)
 {
     sendChatMessage("Current number of deaths: " + deaths.ToString());
 }
Exemplo n.º 16
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?");
                    }
                }
            }
        }
Exemplo n.º 17
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.");
         }
     }
 }
Exemplo n.º 18
0
 internal void AddFilter(ReadMessage msg)
 {
     if(irc.moderators.Contains(msg.user))
     {
         string[] helper = msg.message.Split(new char[] { ' ' }, 2);
         if(helper[1].Length > 3)
         {
             string tempFilter = helper[1].Substring(1, helper[1].Length - 2).ToLower();
             if (helper[1].StartsWith("[") && helper[1].EndsWith("]"))
             {
                 if (!blacklist_fullphrase.Contains(tempFilter))
                 {
                     blacklist_fullphrase.Add(tempFilter);
                     irc.sendChatMessage("Added new full phrase filter: " + tempFilter);
                     saveBlacklist();
                 }
                 else
                 {
                     irc.sendChatMessage("Such full phrase filter already exists!");
                 }
             }
             else if (helper[1].StartsWith("*") && helper[1].EndsWith("]"))
             {
                 if (!blacklist_startswith.Contains(tempFilter))
                 {
                     blacklist_startswith.Add(tempFilter);
                     irc.sendChatMessage("Added new 'starts with' filter: " + tempFilter);
                     saveBlacklist();
                 }
                 else
                 {
                     irc.sendChatMessage("Such 'starts with' filter already exists!");
                 }
             }
             else if (helper[1].StartsWith("[") && helper[1].EndsWith("*"))
             {
                 if (!blacklist_endswith.Contains(tempFilter))
                 {
                     blacklist_endswith.Add(tempFilter);
                     irc.sendChatMessage("Added new 'ends with' filter: " + tempFilter);
                     saveBlacklist();
                 }
                 else
                 {
                     irc.sendChatMessage("Such 'ends with' filter already exists!");
                 }
             }
             else if (helper[1].StartsWith("*") && helper[1].EndsWith("*"))
             {
                 string filter = helper[1].Substring(1, helper[1].Length - 2).ToLower();
                 if (!blacklist_words.Contains(filter))
                 {
                     blacklist_words.Add(filter);
                     irc.sendChatMessage("Added new word filter: " + filter);
                     saveBlacklist();
                 }
                 else
                 {
                     irc.sendChatMessage("Such word filter already exists!");
                 }
             }
             else
                 irc.sendChatMessage("Failed to add a new filter. Wrong syntax?");
         }
     }
 }
Exemplo n.º 19
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.");
         }
     }
 }
Exemplo n.º 20
0
 internal void updateSpeedrunName(ReadMessage msg)
 {
     string[] helper = msg.message.Split(new char[] { ' ' }, 2);
     if (helper[1] != "")
     {
         SpeedrunName = helper[1];
         sendChatMessage("Speedrun.com name for a streamer set to: " + helper[1]);
         SaveConfig();
     }
 }
Exemplo n.º 21
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]);
                        }
                    }
                }
            }
        }
Exemplo n.º 22
0
 internal void resetFromAllowedToPostLinks(ReadMessage msg)
 {
     if (irc.moderators.Contains(msg.user))
     {
         string[] helper = msg.message.Split(' ');
         if (helper.Length > 1)
         {
             for (int i = 1; i < helper.Length; i++)
             {
                 if (!helper[i].Any(char.IsPunctuation))
                 {
                     string name = helper[i].ToLower();
                     if (allowedToPostLinks.ContainsKey(name))
                     {
                         allowedToPostLinks[name] = 0;       //if dictionary contains the user
                         irc.sendChatMessage("Reseted requirement for " + name + " to 0");
                     }
                     else
                     {
                         irc.sendChatMessage(name + " not found in database.");
                     }
                 }
             }
         }
         else
             irc.sendChatMessage("Invalid syntax!");
     }
 }
Exemplo n.º 23
0
        internal void RemoveFilter(ReadMessage msg)
        {
            if (irc.moderators.Contains(msg.user))
            {
                string[] helper = msg.message.Split(new char[] { ' ' }, 2);

                if (helper[1].StartsWith("[") && helper[1].EndsWith("]"))
                {
                    string filter = helper[1].Substring(1, helper[1].Length - 2).ToLower();
                    if (blacklist_fullphrase.Contains(filter))
                    {
                        blacklist_fullphrase.Remove(filter);
                        irc.sendChatMessage("Removed full phrase filter: " + filter);
                        saveBlacklist();
                    }
                    else
                    {
                        irc.sendChatMessage("No filter found");
                    }
                }
                else if (helper[1].StartsWith("*") && helper[1].EndsWith("]"))
                {
                    string filter = helper[1].Substring(1, helper[1].Length - 2).ToLower();
                    if (blacklist_startswith.Contains(filter))
                    {
                        blacklist_startswith.Remove(filter);
                        irc.sendChatMessage("Removed 'starts with' filter: " + filter);
                        saveBlacklist();
                    }
                    else
                    {
                        irc.sendChatMessage("No filter found");
                    }
                }
                else if (helper[1].StartsWith("[") && helper[1].EndsWith("*"))
                {
                    string filter = helper[1].Substring(1, helper[1].Length - 2).ToLower();
                    if (blacklist_endswith.Contains(filter))
                    {
                        blacklist_endswith.Remove(filter);
                        irc.sendChatMessage("Removed 'ends with' filter: " + filter);
                        saveBlacklist();
                    }
                    else
                    {
                        irc.sendChatMessage("No filter found");
                    }
                }
                else if (helper[1].StartsWith("*") && helper[1].EndsWith("*"))
                {
                    string filter = helper[1].Substring(1, helper[1].Length - 2).ToLower();
                    if (blacklist_words.Contains(filter))
                    {
                        blacklist_words.Remove(filter);
                        irc.sendChatMessage("Removed word filter: " + filter);
                        saveBlacklist();
                    }
                    else
                    {
                        irc.sendChatMessage("No filter found");
                    }
                }
                else
                    irc.sendChatMessage("Wrong syntax?");
            }
        }
Exemplo n.º 24
0
        internal void addToAllowedToPostLinks(ReadMessage msg)
        {
            if(irc.moderators.Contains(msg.user))
            {
                string[] helper = msg.message.Split(' ');
                if (helper.Length > 1)
                {
                    for (int i = 1; i < helper.Length; i++)
                    {
                        if(!helper[i].Any(char.IsPunctuation))
                        {
                            string name = helper[i].ToLower();
                            if(allowedToPostLinks.ContainsKey(name))
                                allowedToPostLinks[name] = allowedToPostLinksRequirement;       //if dictionary contains the user
                            else
                                allowedToPostLinks.Add(name, allowedToPostLinksRequirement);    //if it doesn't contain the user

                            irc.sendChatMessage("Set allowedToPostLinks for " + name + " to " + allowedToPostLinksRequirement);
                        }
                    }
                }
                else
                    irc.sendChatMessage("Invalid syntax!");
            }
        }
Exemplo n.º 25
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");
     }
 }
Exemplo n.º 26
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!");
         }
     }
 }
Exemplo n.º 27
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!");
 }
Exemplo n.º 28
0
 internal void DeathCounterRemove(ReadMessage formattedMessage)
 {
     if (moderators.Contains(formattedMessage.user) || trustedUsers.Contains(formattedMessage.user))
     {
         if (formattedMessage.message.StartsWith("!deathRemove "))
         {
             string[] helper = formattedMessage.message.Split(new char[] { ' ' }, 2);
             uint temp;
             if (uint.TryParse(helper[1], out temp))
             {
                 if (deaths < temp)
                 {
                     sendChatMessage("Value is higher than the current number of deaths!");
                 }
                 else
                 {
                     deaths = deaths - temp;
                     sendChatMessage("Removed " + temp.ToString() + " deaths. Current number of deaths: " + deaths.ToString());
                     saveDeaths();
                 }
             }
             else
                 sendChatMessage(formattedMessage.user + ": Invalid syntax?");
         }
         else
         {
             deaths--;
             sendChatMessage("Removed 1 death. Current number of deaths: " + deaths.ToString());
             saveDeaths();
         }
     }
 }
Exemplo n.º 29
0
        private static bool runBot(ReadMessage formattedMessage)
        {
            FormattedMessage = formattedMessage;
            Console.WriteLine(formattedMessage.user + ": " + formattedMessage.message);

                if (cachedMessage != String.Empty)
                {
                    irc.sendChatMessage(cachedMessage);
                    cachedMessage = String.Empty;
                }

                if (irc.filteringEnabled && !(irc.moderators.Contains(formattedMessage.user) || irc.trustedUsers.Contains(formattedMessage.user)) && _blacklist.checkForSpam(formattedMessage))
                {
                    irc.purgeMessage(formattedMessage.user);
                    if (irc.filteringRespond) irc.sendChatMessage("Probably spam FrankerZ");
                    return true;
                }

                if (irc.filteringEnabled && !(irc.moderators.Contains(formattedMessage.user) || irc.trustedUsers.Contains(formattedMessage.user)) && _blacklist.checkForBanWorthyContent(formattedMessage))
                {
                    irc.banMessage(formattedMessage.user);
                    if (irc.filteringRespond) irc.sendChatMessage("And he/she is gone! FrankerZ");
                    return true;
                }
                //the goal here is going to be trying to group things
                if (!formattedMessage.message.StartsWith("!") || irc.ignorelist.Contains(formattedMessage.user))
                {
                    //literally nothing else happens in your code if this is false
                    return true;
                }
                cvarflag = true;//check if _ANYTHING_ matched.
                if (irc.vocalMode)
                {
                    if (irc.moderators.Contains(formattedMessage.user) && check_lazy("!help")) irc.sendChatMessage("The list of commands is available at https://github.com/SuiMachine/SuiBot_Console/wiki/List-of-all-commands");
                    if (irc.moderators.Contains(formattedMessage.user) && check_lazy("!commands")) irc.sendChatMessage("The list of commands is available at https://github.com/SuiMachine/SuiBot_Console/wiki/List-of-all-commands");
                    if (check_lazy("!ask ")) _ask.answerAsk(irc, formattedMessage);
                    if (check_lazy("!addCvar ")) _customCvars.addCustomCvar(irc, formattedMessage);
                    if (check_lazy("!removeCvar ")) _customCvars.removeCustomCvar(irc, formattedMessage);
                    if (check_lazy("!customCvars")) _customCvars.showCustomCvars(irc, formattedMessage);
                }
                if (irc.quoteEnabled)
                {
                    if (check_lazy("!addquote ")) _quotes.addQuote(irc, formattedMessage);
                    if (check_lazy("!quoteID ")) _quotes.getQuotebyID(irc, formattedMessage);
                    if (check_lazy("!quote")) _quotes.getQuote(irc, formattedMessage.message);
                    if (check_lazy("!removeQuote")) _quotes.removeQuote(irc, formattedMessage);
                    if (check_lazy("!getNumberOfQuotes")) _quotes.getNumberOfQuotes(irc);
                }
                if (irc.intervalMessagesEnabled)
                {
                    if (check_lazy("!intervalMessageAdd")) _intervals.AddIntervalMessage(irc, formattedMessage);
                    if (check_lazy("!intervalMessageShow")) _intervals.ShowIntervalMessageID(irc, formattedMessage);
                    if (check_lazy("!intervalMessageRemove")) _intervals.RemoveIntervalMessage(irc, formattedMessage);
                }
                if (irc.slotsEnable)
                {
                    if (check_lazy("!slots ")) _slots.PlaySlots(irc, formattedMessage);
                    if (check_lazy("!coins")) _coins.DisplayCoins(irc, formattedMessage);
                    if (check_lazy("!addCoins ")) _coins.AddCoins(irc, formattedMessage);
                }
                if (irc.voteEnabled)
                {
                    if (check_lazy("!callVote ")) _votes.callVote(irc, formattedMessage);
                    if (check_lazy("!voteOptions ")) _votes.setOptions(irc, formattedMessage);
                    if (check_lazy("!voteOpen")) _votes.voteOpen(irc, formattedMessage);
                    if (check_lazy("!voteClose")) _votes.voteClose(irc, formattedMessage);
                    if (check_lazy("!voteDisplay")) _votes.displayVote(irc, formattedMessage);
                    if (check_lazy("!voteResults")) _votes.displayResults(irc, formattedMessage);
                    if (check_lazy("!vote ")) _votes.Vote(irc, formattedMessage);
                }
                if (irc.deathCounterEnabled)
                {
                    if (check_lazy("!deathCounter")) irc.DeathCounterDisplay(formattedMessage);
                    if (check_lazy("!deathAdd")) irc.DeathCounterAdd(formattedMessage);
                    if (check_lazy("!deathRemove")) irc.DeathCounterRemove(formattedMessage);
                }
                if (irc.viewerPBActive)
                {
                    if (check_lazy("!viewerPB")) _viewerPB.displayViewerPB(formattedMessage);
                }
                if (irc.filteringEnabled)
                {
                    if (check_lazy("!filterAdd ")) _blacklist.AddFilter(formattedMessage);
                    if (check_lazy("!filterRemove ")) _blacklist.RemoveFilter(formattedMessage);
                    if (check_lazy("!allowToPostLinks")) _blacklist.addToAllowedToPostLinks(formattedMessage);
                    if (check_lazy("!resetAllowToPostLinks")) _blacklist.resetFromAllowedToPostLinks(formattedMessage);  //No idea why
                }
                if (irc.leaderBoardEnabled)
                {
                    if (check_lazy("!forceSpeedrunPage")) _jsonStatus.forcedGameFunction(formattedMessage);
                    if (check_lazy("!speedrunName ")) irc.updateSpeedrunName(formattedMessage);

                    if (check_lazy("!pb"))
                    {
                        Thread lbThread = new Thread(new ThreadStart(_leaderboards.getPB));
                        _leaderboards.recieveData(irc, formattedMessage);
                        lbThread.Start();
                    }

                    if (check_exact("!wr") || check_lazy("!wr "))
                    {
                        Thread lbThread = new Thread(new ThreadStart(_leaderboards.getLeaderboard));
                        _leaderboards.recieveData(irc, formattedMessage);
                        lbThread.Start();
                    }
                }
                if (irc.fortuneTellerEnabled)
                {
                    if (check_exact("!fortune") || check_exact("!tellfortune"))
                        _fortuneTeller.FortuneTelling(irc, formattedMessage);
                }

                //ones we do regardless
                if (check_lazy("!ignoreAdd ")) irc.ignoreListAdd(formattedMessage);
                if (check_lazy("!ignoreRemove ")) irc.ignoreListRemove(formattedMessage);
                if (check_lazy("!trustedAdd ")) irc.trustedUserAdd(formattedMessage);
                if (check_lazy("!permit ")) irc.trustedUserAdd(formattedMessage);
                if (check_lazy("!trustedRemove ")) irc.trustedUsersRemove(formattedMessage);

                //mod only!
                if (irc.moderators.Contains(formattedMessage.user))
                {
                    if (check_lazy("!updateJsonInfo")) _jsonStatus.requestUpdate();
                    if (check_lazy("!version")) irc.version();
                    if (check_lazy("!highlight")) irc.createHighlight(formattedMessage, _jsonStatus);
                }
                //supermod only!
                if (irc.supermod.Contains(formattedMessage.user))
                {
                    if (check_lazy("!killBot"))
                    {
                        irc.sendChatMessage("Goodbye! BibleThump");

                        if (irc.filteringEnabled)
                            _blacklist.saveUserInfo();
                        irc.meebyIrc.Disconnect();

                        return false;
                    }
                    if (check_lazy("!reloadBot")) reloadBot();
                }

                //Property
                if (check_lazy("!getProperty")) irc.getParameter(formattedMessage);
                if (check_lazy("!setProperty")) irc.setParameter(formattedMessage);

                if (cvarflag)
                {
                    _customCvars.cvarPerform(irc, formattedMessage);
                }

                return true;
        }
Exemplo n.º 30
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]);
             }
         }
     }
 }