Exemplo n.º 1
0
 public virtual void ShowToChannel(dIRCBot bot, CommandDetails command)
 {
     if (!string.IsNullOrEmpty(Group))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: In group: " + bot.ColorHighlightMajor + Group, 1);
     }
     if (!string.IsNullOrEmpty(Plugin))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: Requires the plugin(s): " + bot.ColorHighlightMajor + Plugin, 1);
     }
     if (!string.IsNullOrEmpty(Warning))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: WARNING: " + bot.ColorHighlightMajor + Warning, 2);
     }
     if (!string.IsNullOrEmpty(Deprecated))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: DEPRECATED: " + bot.ColorHighlightMajor + Deprecated, 2);
     }
     if (!string.IsNullOrEmpty(Video))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: Video on the subject:" + bot.ColorLink + " " + Video, 1);
     }
     if (command.Arguments.Count >= 2 && command.Arguments[1].ToLower().StartsWith("f"))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: Found in internal file: " + FileName, 2);
     }
 }
Exemplo n.º 2
0
        public override void ShowToChannel(dIRCBot bot, CommandDetails command)
        {
            bot.Chat(command.Channel.Name, command.Pinger + bot.ColorGeneral + "Found: " + bot.ColorHighlightMajor + Name + ": " + Short, 2);
            bot.Chat(command.Channel.Name, bot.ColorGeneral + "Syntax: " + bot.ColorHighlightMajor + Info, 2); // TODO Highlight correctly!
            string arg = command.Arguments.Count >= 2 ? command.Arguments[1].ToLower() : "";

            if (arg.StartsWith("a"))
            {
                bot.Chat(command.Channel.Name, bot.ColorGeneral + "Author: " + bot.ColorHighlightMajor + Author, 1);
            }
            if (arg.StartsWith("d"))
            {
                if (bot.Chat(command.Channel.Name, bot.ColorGeneral + "Description: " + bot.ColorHighlightMajor + Description, 3) == 0)
                {
                    bot.Chat(command.Channel.Name, bot.ColorGeneral + "And more..." + bot.ColorLink + " http://mcmonkey.org/denizen/cmds" + Name);
                }
            }
            if (arg.StartsWith("s"))
            {
                bot.Chat(command.Channel.Name, bot.ColorGeneral + "Stability: " + bot.ColorHighlightMajor + Stable, 1);
            }
            if (arg.StartsWith("r"))
            {
                bot.Chat(command.Channel.Name, bot.ColorGeneral + "Required Arguments: " + bot.ColorHighlightMajor + Reqs, 1);
            }
            if (arg.StartsWith("t"))
            {
                int limit = 5;
                foreach (string str in Tags)
                {
                    // TODO: Dig up tag help short description
                    limit = bot.Chat(command.Channel.Name, bot.ColorGeneral + "Tag: " + str, limit);
                }
                if (limit == 0)
                {
                    bot.Chat(command.Channel.Name, bot.ColorGeneral + "And more..." + bot.ColorLink + " http://mcmonkey.org/denizen/cmds" + Name);
                }
            }
            if (arg.StartsWith("u"))
            {
                int limit = 5;
                foreach (string str in Usage)
                {
                    foreach (string use in str.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        limit = bot.Chat(command.Channel.Name, bot.ColorGeneral + "Usage: " + use, limit);
                    }
                }
                if (limit == 0)
                {
                    bot.Chat(command.Channel.Name, bot.ColorGeneral + "And more..." + bot.ColorLink + " http://mcmonkey.org/denizen/cmds" + Name);
                }
            }
            base.ShowToChannel(bot, command);
        }
Exemplo n.º 3
0
 public virtual void ShowToChannel(dIRCBot bot, CommandDetails command)
 {
     if (!string.IsNullOrEmpty(Group))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: In group: " + bot.ColorHighlightMajor + Group, 1);
     }
     if (!string.IsNullOrEmpty(Plugin))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: Requires the plugin(s): " + bot.ColorHighlightMajor + Plugin, 1);
     }
     if (!string.IsNullOrEmpty(Warning))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: WARNING: " + bot.ColorHighlightMajor + Warning, 2);
     }
     if (!string.IsNullOrEmpty(Deprecated))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: DEPRECATED: " + bot.ColorHighlightMajor + Deprecated, 2);
     }
     if (!string.IsNullOrEmpty(Video))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: Video on the subject:" + bot.ColorLink + " " + Video, 1);
     }
     if (command.Arguments.Count >= 2 && command.Arguments[1].ToLower().StartsWith("f"))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: Found in internal file: " + FileName, 2);
     }
 }
Exemplo n.º 4
0
        public void CheckForumFeed()
        {
            string url = dIRCBot.Configuration.ReadString("dircbot.irc-servers." + Bot.ServerName + ".forum.url", null);

            if (url == null || !url.Contains("://"))
            {
                if (!announce)
                {
                    Logger.Output(LogType.INFO, "Not watching forum feed " + Bot.ServerName + " because url is " + url);
                }
                return;
            }
            List <string> channels = dIRCBot.Configuration.ReadStringList("dircbot.irc-servers." + Bot.ServerName + ".forum.channels");

            if (channels == null || channels.Count == 0)
            {
                Logger.Output(LogType.INFO, "Not watching forum feed " + Bot.ServerName + " because no channels");
                return;
            }
            WebRequest request = WebRequest.Create(url);

            request.Timeout = 20000;
            using (WebResponse response = request.GetResponse())
            {
                if (request == null)
                {
                    Logger.Output(LogType.ERROR, "Response null for url " + url);
                    return;
                }
                using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
                {
                    if (reader == null)
                    {
                        Logger.Output(LogType.ERROR, "Reader null for url " + url);
                        return;
                    }
                    SyndicationFeed feed = SyndicationFeed.Load(reader);
                    if (feed == null)
                    {
                        Logger.Output(LogType.ERROR, "Feed null for url " + url);
                        return;
                    }
                    foreach (SyndicationItem item in feed.Items)
                    {
                        if (item == null)
                        {
                            Logger.Output(LogType.ERROR, "Item null for url " + url);
                            continue;
                        }
                        long pdate = item.PublishDate.DateTime.ToFileTimeUtc();
                        if (!pubDatesKnown.Contains(pdate))
                        {
                            pubDatesKnown.Add(pdate);
                            string info = Bot.ColorGeneral + "[Forums] " + Bot.ColorHighlightMinor + item.Authors.First().Name
                                          + Bot.ColorGeneral + " posted: <<" + Bot.ColorHighlightMajor + item.Title.Text + Bot.ColorGeneral + ">>:"
                                          + Bot.ColorLink + " " + (item.Links.Count > 0 ? item.Links.First().Uri.ToString() : "<<no url provided>>");
                            Logger.Output(LogType.INFO, "Found " + info);
                            if (!announce)
                            {
                                Logger.Output(LogType.INFO, "Ignoring...");
                                continue;
                            }
                            foreach (IRCChannel channel in Bot.Channels)
                            {
                                foreach (string chan in channels)
                                {
                                    if (channel.Name.Replace("#", "").ToLowerInvariant() == chan.ToLowerInvariant())
                                    {
                                        Bot.Chat(channel.Name, info, 2);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
 public override void ShowToChannel(dIRCBot bot, CommandDetails command)
 {
     bot.Chat(command.Channel.Name, command.Pinger + bot.ColorGeneral + "Found: " + bot.ColorHighlightMajor + Name + ": " + Short, 2);
     bot.Chat(command.Channel.Name, bot.ColorGeneral + "Syntax: " + bot.ColorHighlightMajor + Info, 2); // TODO Highlight correctly!
     string arg = command.Arguments.Count >= 2 ? command.Arguments[1].ToLower() : "";
     if (arg.StartsWith("a"))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + "Author: " + bot.ColorHighlightMajor + Author, 1);
     }
     if (arg.StartsWith("d"))
     {
         if (bot.Chat(command.Channel.Name, bot.ColorGeneral + "Description: " + bot.ColorHighlightMajor + Description, 3) == 0)
         {
             bot.Chat(command.Channel.Name, bot.ColorGeneral + "And more..." + bot.ColorLink + " http://mcmonkey.org/denizen/cmds" + Name);
         }
     }
     if (arg.StartsWith("s"))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + "Stability: " + bot.ColorHighlightMajor + Stable, 1);
     }
     if (arg.StartsWith("r"))
     {
         bot.Chat(command.Channel.Name, bot.ColorGeneral + "Required Arguments: " + bot.ColorHighlightMajor + Reqs, 1);
     }
     if (arg.StartsWith("t"))
     {
         int limit = 5;
         foreach (string str in Tags)
         {
             // TODO: Dig up tag help short description
             limit = bot.Chat(command.Channel.Name, bot.ColorGeneral + "Tag: " + str, limit);
         }
         if (limit == 0)
         {
             bot.Chat(command.Channel.Name, bot.ColorGeneral + "And more..." + bot.ColorLink + " http://mcmonkey.org/denizen/cmds" + Name);
         }
     }
     if (arg.StartsWith("u"))
     {
         int limit = 5;
         foreach (string str in Usage)
         {
             foreach (string use in str.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
             {
                 limit = bot.Chat(command.Channel.Name, bot.ColorGeneral + "Usage: " + use, limit);
             }
         }
         if (limit == 0)
         {
             bot.Chat(command.Channel.Name, bot.ColorGeneral + "And more..." + bot.ColorLink + " http://mcmonkey.org/denizen/cmds" + Name);
         }
     }
     base.ShowToChannel(bot, command);
 }