コード例 #1
0
        public static void Read(Message msg)
        {
            User user = msg.FromUser;


            if (msg.SaidMessage.Contains("!addcommand") && msg.SaidMessage.IndexOf("!addcommand") == 0 && user.Permission >= 1)
            {
                
                string useStr = msg.SaidMessage.Trim();
                useStr = useStr.Substring(useStr.IndexOf("nd") + 3);
                
                string[] splitUp = useStr.Split(' ');
                string trigger = splitUp[0];
                int triggerLength = trigger.Length;
                string todo = useStr.Substring(triggerLength);
                
                if (!TwitchChatBot.list.AddCommandAlreadyMatches(trigger.Trim()))
                {
                    TwitchChatBot.list.AddCommand(trigger, todo, user);
                }
                
                return;

                
            }

            if (TwitchChatBot.list.MatchesCommandFromCommandList(msg))
            {
                TwitchChatBot.list.FindCommandFromMessage(msg).Execute();
            }
        }
コード例 #2
0
 public void Log(Message msg)
 {
     if (enabled)
     {
         msgUserList.Add(msg);
         msgList.Add(msg.SaidMessage);
     }
     
 }
コード例 #3
0
 public void Add(Message msg)
 {
     try
     {
         messages.Add(msg);
     }
     catch (NullReferenceException exc)
     {
         desigName = TwitchChatBot.ChannelIn.Name;
     }
     
 }
コード例 #4
0
        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);
                }

                    
            }

        }
コード例 #5
0
 public DataPacket(BackgroundPacket pkt, Message msg)
 {
     bPacket = pkt;
     message = msg;
 }
コード例 #6
0
 public void AddCommand(Message msg)
 {
     
 }
コード例 #7
0
 public Command FindCommandFromMessage(Message msg)
 {
     UpdateArray();
     Command ret = null;
     foreach (Command comd in _array)
     {
         if (msg.SaidMessage.Equals(comd.Trigger))
         {
             ret = comd;
         }
     }            
     return ret; 
 }
コード例 #8
0
 public int GetWhereMatches(Message cmd)
 {
     throw new CommandNotFoundException("");
 }
コード例 #9
0
        public bool MatchesCommandFromCommandList(Message cmd)
        {
            UpdateArray();
            foreach (Command comd in _array)
            {
                if (cmd.SaidMessage.Equals(comd.Trigger))
                {
                    return true;
                }

            }
            return false;
        }
コード例 #10
0
 public bool Contains(Message msg)
 {
     return messages.Contains(msg);
 }