Пример #1
0
        public void HandleMessage(Message m)
        {
            //only handle commands we want
            if (!m.MessageString.StartsWith("!"))
            {
                foreach(IIOInterface i in interfaces)
                {
                    if (i.IsSource(m.Source))
                        continue;
                    i.SendMessage(m.Name + ": " + m.MessageString);
                }
            }

            String command = m.MessageString.Substring(1);

            if (isMuted && !command.StartsWith("unmute"))
                return;

            foreach (Module module in modules)
            {
                if (module.Contains(command))
                {
                    String result = module.RunCommand(m);
                    SendMessageToAllInterfaces(result);
                    break;
                }
            }
        }
Пример #2
0
        private Message HandleSystemMessage(Message message)
        {
            if (message.Type == "Ping")
            {
                Message reply = message.CreateReplyMessage();
                reply.Type = "Ping";
                return reply;
            }
            else if (message.Type == "DeleteUserData")
            {
                // Implement user deletion here
                // If we handle user deletion, return a real message
            }
            else if (message.Type == "BotAddedToConversation")
            {
            }
            else if (message.Type == "BotRemovedFromConversation")
            {
            }
            else if (message.Type == "UserAddedToConversation")
            {
            }
            else if (message.Type == "UserRemovedFromConversation")
            {
            }
            else if (message.Type == "EndOfConversation")
            {
            }

            return null;
        }
Пример #3
0
 public String RunCommand(Message m)
 {
     String[] tokens = m.MessageString.Substring(1).Split(' ');
     Command command = commands.Find(x => tokens[0] == x.Name);
     if (command.IsAdminOnly && !m.Admin)
         return "Sorry, this command requires admin privileges. Try !admins.";
     if (command.RequiresSender)
         command.Sender = m.Name;
     if (tokens.Length == 1)
         return command.Execute(null);
     else
     {
         String[] args = tokens.Skip(1).ToArray();
         return command.Execute(args);
     }
 }
Пример #4
0
 public static void LogMessage(Message m, ConsoleColor color)
 {
     Console.ForegroundColor = color;
     Console.WriteLine(m.Name + ": " + m.MessageString);
 }