示例#1
0
 public Message(string msg, User usr, DateTime cT, int currentTick)
 {
     info = msg;
     user = usr;
     time = cT;
     atTick = currentTick;
 }
        public MessageWithUserList()
        {
            
            try
            {
                string something = File.ReadAllText(desigName + "_Ulogs");
            }
            catch(FileNotFoundException exc)
            {
                int j = 0;
                File.Create(desigName + "_Ulogs");
                int i = 0;
                
            }
            catch(IOException exc)
            {
                File.WriteAllText(desigName + "_Ulogs", Environment.NewLine);
                desigName = TwitchChatBot.ChannelIn.Name.ToLower();
                int j = 0;
                File.Create(desigName + "_Ulogs");
                int i = 0;
                File.WriteAllText(desigName + "_Ulogs", Environment.NewLine);
                //TwitchChatBot.LogError(exc.ToString());
            }

            String allTextInFile = File.ReadAllText(desigName + "_Ulogs");
            String[] linesOfText = allTextInFile.Split(Environment.NewLine.ToCharArray());
            
            foreach (String msg in linesOfText)
            {
                if (msg.Contains("LOG_MESSAGE_FROMUSER"))
                {
                    string user = msg.Substring(0, msg.IndexOf("said") - 1);
                    User usr = new User(user);
                    string month = msg.Substring(msg.IndexOf("DT1=") + 4, msg.IndexOf("DT2=") - msg.IndexOf("DT1="));
                    string day = msg.Substring(msg.IndexOf("DT2=") + 4, msg.IndexOf("DT3=") - msg.IndexOf("DT2="));
                    string year = msg.Substring(msg.IndexOf("DT3=") + 4, msg.Trim().Length - msg.IndexOf("DT3="));
                    int monthNum = int.Parse(month);
                    int dayNum = int.Parse(day);
                    int yearNum = int.Parse(year);
                    DateTime dt = new DateTime(yearNum, monthNum, dayNum);
                    string cutOff = msg.Substring(msg.IndexOf(":") + 2, msg.Trim().Length - msg.IndexOf("at" + dt.ToString()));
                    Message mesg = new Message(cutOff, usr, dt);
                    messages.Add(mesg);
                }

                    
            }

        }
示例#3
0
 public static Command Timeout(User user)
 {
     return new Command("!timeout", "/timeout " + user.Name + " 120"); 
 }
 public void AddCommand(string trigger, string todo, User user)
 {
     Command cmd = new Command(trigger, todo);
     AddCommand(cmd, user);
     
     
 }
 public void AddCommand(Command cmd, User user)
 {
     if (user.Permission >= 1 && !AddCommandAlreadyMatches(cmd.Trigger))
     {
         commands.Add(cmd);
         CommandsFile file = new CommandsFile(TwitchChatBot.ChannelIn.Name.ToLower() + "_commands");
         file.Add(cmd);
         
         RemoveCommand("!list");
         _toString = ToString();
         commands.Add(new Command("!list", _toString + " and list."));
         UpdateArray();
     }
     
 }
 public void Timeout(User user)
 {
     Command.Timeout(user).Execute();
 }
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            ticksTilSecond = (double)1000 / (double)timer1.Interval;
            if ((double) Ticks % ticksTilSecond == 0)
            {
                seconds++;
            }
            if (seconds % 60 == 0)
            {
                seconds = 0;
                minutes++;
            }
            if (minutes % 60 == 0)
            {
                minutes = 0;
                hours++;
            }

            if (TwitchChatBot.UseBot == null)
            {
                throw new BotNotFoundException("Obviously you messed up Noah.");
            }


            try
            {
                if (lastTimeTicked == currentTicks)
                {
                    
                }
                else //if (InputCount < 15)
                {
                    lastTimeTicked = currentTicks;

                    if (client.Available > 0 || reader.Peek() > 0)
                    {
                        string message = reader.ReadLine();
                        if (Connected)
                        {
                            if (message.Contains("!") && message.Contains("@"))
                            {
                                string user = message.Substring(1, message.IndexOf("!") - 1);
                                if (!user.ToLower().Equals("lezrecbot"))
                                {
                                    User messageUser = new User(user);
                                    if (messageUser.Name.Equals(ChannelOwner.Name))
                                    {
                                        messageUser = ChannelOwner;
                                    }
                                    else if (messageUser.Name.Equals(Developer.Name))
                                    {
                                        messageUser = Developer;
                                    }
                                    string saidMessage = message.Substring(message.IndexOf("#" + ChannelIn.Name));
                                    saidMessage = saidMessage.Substring(message.IndexOf(":") + 1).Trim();
                                    saidMessage = saidMessage.Substring(saidMessage.IndexOf(":") + 1);
                                    Message msg = new Message(saidMessage, messageUser, DateTime.Now);
                                    InputCount++;
                                    Log(msg);
                                    MessageReader.Read(msg);
                                    logger.Log(msg);
                                    //logger.Log(saidMessage);
                                    lastSinceRippedToTxt++;

                                    //if (message.ToLower().Contains("lezrecbot i think you're stupid"))
                                    //{
                                     //   LezrecBotSendChatMessage(user + ". I think the same about you!");
                                   // }

                                    
                                }

                            }


                        }

                        if (!message.Contains("USERSTATE"))
                        {
                            label1.Text += $"\r\n{message}";
                        }
                        
                    }

                }
                    
                
                if (!Connected && currentTicks >= 5)
                {
                    SendIRCMessage("CAP REQ :twitch.tv/commands");
                }


                if (!Connected && currentTicks >= 10)
                {
                    Reconnect(ChannelIn);
                    //LezrecBotSendChatMessage("Hello! I am LezrecBot!");
                    LezrecBotSendChatMessage("MrDestructoid beep boo- I mean I'm a normal viewer Kappa");
                }

                if (currentTicks == 20)
                {
                    Whisper("lezrecop", "ok so dis work");
                }

            }
            catch(BotNotFoundException exc)
            {
                label1.Text += $"\r\n{exc.ToString()}";
                TwitchChatBot.UseBot = new TwitchChatBot("irc.twitch.tv", 6667);
            }

            catch(Exception exc)
            {
                if (errorTicks > 200)
                {
                    Application.Exit();
                }
                label1.Text += $"\r\nERROR ERROR BEEP BOOP";
                label1.Text += $"\r\n{exc.StackTrace}";
                textBox1.Text = $"!!!!!!!!!!!!!!!!!!!!!!";
                errorTicks++;

            }
            
            currentTicks++;

        }
 public BackgroundPacket(Channel ch, User usr)
 {
     channel = ch;
     user = usr;
 }
示例#9
0
 public Message(string msg, User usr, DateTime cT)
 {
     info = msg;
     user = usr;
     time = cT;
 }