コード例 #1
0
        public void Message(string message)
        {
            if (message.Contains("PING :tmi.twitch.tv"))
            {
                irc.sendIrcMessage("PONG :tmi.twitch.tv");
            }

            else if (message.Contains("~"))
            {
                commandHandler.Command(message);
            }

            else if ((message.ToLower().Contains("hotdog") || message.ToLower().Contains("hot dog")) && (message.ToLower().Contains("sandwhich") || message.ToLower().Contains("sandwich")) && message.ToLower().Contains("is") && message.ToLower().Contains(" a "))
            {
                Hotdog();
            }

            else if (message.Contains("PRIVMSG #umber__"))
            {
                if (landmine.Next(5000) == 0)
                {
                    irc.sendChatMessage("/timeout " + message.Substring(1, message.IndexOf("!") - 1) + " 10");
                    irc.sendChatMessage("Oops! " + message.Substring(1, message.IndexOf("!") - 1) + " has stepped on a landmine!");
                }
            }
        }
コード例 #2
0
        public void startVote(string propositionAll)
        {
            if (propositionAll != "")
            {
                string[] msgPropos = propositionAll.Split(' ');
                string   sendPropo = "Vote : ";
                foreach (string propo in msgPropos)
                {
                    sendPropo += "!" + propo + " ";
                    this.propositions.Add("!" + propo, 0);
                }

                Irc.sendChatMessage(sendPropo);
                this.isStartVoting = true;
            }
        }
コード例 #3
0
ファイル: IrcClient.cs プロジェクト: lobosjr/lobotjr
 static void Whisper(Party party, string message, IrcClient whisperClient)
 {
     for (int i = 0; i < party.NumMembers(); i++)
     {
         string toSend = ".w " + party.members.ElementAt(i).name + " " + message;
         whisperClient.sendChatMessage(toSend);
     }
 }
コード例 #4
0
        }//end of mod()

        //returns 1 if the message has a word that is banned
        //if recording is set to 1 it will write to a file whenever someone is timed out

        public int containsBannedWord(string message, string user, IrcClient irc)
        {
            string[] banned = bannedWords.ToArray();
            for (int i = 0; i < banned.Length; i++)
            {
                if (message.Contains(banned[i]))
                {
                    irc.sendChatMessage("record = " + record);
                    if (record == 1)
                    {
                        char[]   spil        = { ':' };
                        string[] userMessage = message.Split(spil);

                        string write = "TimedOut: " + user + "            Word Used = " + banned[i] + "               Complete text = " + userMessage[2];
                        irc.sendChatMessage("write = " + write);
                        timeoutRecord.Flush();
                    }

                    timeout(user, irc);
                    return(1);
                }
            }
            return(0);
        }//end of isBanned
コード例 #5
0
ファイル: Program.cs プロジェクト: DerianDav/TwitchBot
        //takes oauth password from twitch
        static void Main(string[] args)
        {
            IrcClient irc = new IrcClient("irc.twitch.tv", 6667, "nightlurk", "oauth:p9znoj3v2mm3niyxd42o6n4ae5zmgs");

            irc.joinRoom("nightlurk");

            Mod    mod  = new Mod();
            Random rand = new Random();

            while (true)
            {
                string message = irc.readMessage();
                string curUser = irc.getUserName(message);


//                if (message != "")
//                  irc.sendChatMessage(message);

                if (message.Contains("!banRoulette"))
                {
                    int    random = rand.Next();
                    string result;
                    if (random % 6 == 0)
                    {
                        result = "RIP";
                        mod.timeout(curUser, irc);
                    }
                    else
                    {
                        result = "nothing happens.";
                    }
                    irc.sendChatMessage(curUser + " spins the barrel and shoots ... 1 second later and " + result);
                }

                mod.containsBannedWord(message, curUser, irc);
            } //end of while
        }     //end of main
コード例 #6
0
        public void Quote()
        {
            StreamReader quoteReader = new StreamReader(@"C:\Users\nicho\source\repos\MeleeOnlyBot\Quote.txt");

            string quote         = "No quotes have been added yet";
            string line          = "";
            int    quoteNumber   = 0;
            int    quotesVisited = 0;
            var    rng           = new Random();

            while ((line = quoteReader.ReadLine()) != null)
            {
                if (rng.Next(++quotesVisited) == 0)
                {
                    quote       = line;
                    quoteNumber = quotesVisited;
                }
            }

            quoteReader.Close();
            irc.sendChatMessage("#" + quoteNumber + ": " + quote);
        }
コード例 #7
0
        static void Main(string[] args)
        {
restrt:

            Console.WriteLine("Welcome to the Pok" + '\u00E9' + "bot console application!");
            Console.WriteLine("**Make sure to connect your bot via the LoginInfo.txt file**");
            Console.WriteLine("The bot works in chat and on the console (!pokedex not required for console)\n");

            //start a new thread to find any keyboard input
            Thread t = new Thread(readKeyboard);

            t.Start();

            Thread.Sleep(1);

            //Scan "LoginInfo.txt "file for user login info
            string       channelMain = "", passMain = "", channel = "";
            string       targetFile = Directory.GetCurrentDirectory() + @"\LoginInfo.txt";
            StreamReader file       = new StreamReader(targetFile, true);

            for (int i = 0; i < 3; i++)
            {
                if (i == 0)
                {
                    channelMain = file.ReadLine();
                }
                if (i == 1)
                {
                    passMain = file.ReadLine();
                }
                if (i == 2)
                {
                    channel = file.ReadLine();
                }
            }

            file.Close();

refresh:                                         //jump to here if null message is received from stream

            DateTime lastMessage = DateTime.Now; //Used to delay messages to counter bans

            GC.Collect();
            //Connect to twitch irc server with login info
            IrcClient irc = new IrcClient("irc.twitch.tv", 6667, channelMain, passMain);

            irc.joinRoom(channel);
            //Infinite loop to check any keyboard or stream input
            while (true)
            {
                bool   enter   = false;
                bool   advance = false; //Used to know if a picture was updated
                string message = irc.readMessage();

                //Restart program if boolean value changes mid-loop
                if (restart == true)
                {
                    restart = false;
                    t.Join();
                    Console.Clear();
                    goto restrt;
                }


                //Now check for any irc messages and respond appropriately
                if (message == null)
                {
                    //Caught this stupid guy giving me problems!
                    //Console.Clear();
                    //Console.WriteLine("We hit a null message");
                    GC.Collect();
                    goto refresh;
                }
                if (message.Contains("!pokedex add"))
                {
                    irc.sendChatMessage("Adding name to database...");
                    lastMessage = DateTime.Now;
                    addName(message, lastMessage);//add name to data base
                    enter = true;
                }
                if ((message.Contains("!pokedex") || message.Contains("!pdx")) && enter == false)
                {
                    lastMessage = DateTime.Now;
                    advance     = updatePic(message, lastMessage);//update pokemon.png if pokemon is found
                    if (advance == false)
                    {
                        advance = checkNames(message); //Look for a nickname and update
                    }
                    if (advance == true)
                    {
                        irc.sendChatMessage("Pok" + '\u00E9' + "dex updated"); //Let chat know we found the nickname
                    }
                }

                GC.Collect();
            }
        }
コード例 #8
0
        /// <summary>
        /// Assumes that message starts with a command
        /// </summary>
        /// <param name="username"></param>
        /// <param name="message"></param>
        private static void handleCommand(string username, string message)
        {
            Regex r = new Regex(@"^!\w+");

            irc.sendChatMessage(CommandManager.RunCommand(r.Match(message).Value, message));
        }
コード例 #9
0
        }//end of isBanned

        public void timeout(string user, IrcClient irc)
        {
            irc.sendChatMessage(".timeout " + user);
            irc.sendChatMessage(".unban " + user);
        }
コード例 #10
0
ファイル: IrcClient.cs プロジェクト: lobosjr/lobotjr
        static void Whisper(string user, string message, IrcClient whisperClient)
        {
            string toSend = ".w " + user + " " + message;

            whisperClient.sendChatMessage(toSend);
        }
コード例 #11
0
 private static void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     irc.sendChatMessage("/me BIENVENUE SUR MA CHAINE !");
 }