示例#1
0
 public override string Extension_DumpHtml(config.channel channel)
 {
     string HTML = "";
     if (GetConfig(channel, "Rss.Enable", false))
     {
         Feed list = (Feed)channel.RetrieveObject("rss");
         if (list == null)
         {
             return "";
         }
         if (GetConfig(channel, "Rss.Enable", false) != true)
         {
             return HTML;
         }
         HTML += "<h4>Rss feed</h4><br>";
         HTML += "\n<br>\n<h4>Rss</h4>\n<br>\n\n<table class=\"infobot\" width=100% border=1>";
         HTML += "<tr><th>Name</th><th>URL</th><th>Text</th><th>Enabled</th></tr>";
         lock (list.Content)
         {
             foreach (Feed.item feed in list.Content)
             {
                 HTML += "\n<tr><td>" + feed.name + "</td><td><a href=\"" + feed.URL + "\">" + feed.URL + "</a></td><td>" + feed.message + "</td><td>" + (!feed.disabled).ToString() + "</td></tr>";
             }
         }
         HTML += "</table>\n";
     }
     return HTML;
 }
示例#2
0
 public override void Hook_Channel(config.channel channel)
 {
     if (channel.RetrieveObject("Statistics") == null)
     {
         channel.RegisterObject(new Statistics(channel), NAME);
     }
 }
示例#3
0
 public override void Hook_PRIV(config.channel channel, User invoker, string message)
 {
     if (message.StartsWith("!") && message.Contains("|"))
     {
         DebugLog("Parsing: " + message, 6);
         string user = message.Substring(message.IndexOf("|") + 1);
         user = user.Trim();
         DebugLog("Parsed user - " + user, 6);
         if (user.Contains(" "))
         {
             user = user.Substring(0, user.IndexOf(" "));
         }
         if (user != "")
         {
             DebugLog("Adding user to list " + user, 6);
             Ring.Add(new Buffer.Item(invoker.Nick, user));
         }
     }
     else
     {
         message = message.ToLower();
         if (message.Contains(channel.instance.Nick) && !message.Contains("thanks to") && (message.Contains("thanks") || message.Contains("thank you")) && !message.Contains("no thank"))
         {
             string response = "Hey " + invoker.Nick + ", you are welcome!";
             Buffer.Item x = Ring.getUser(invoker.Nick);
             DebugLog("Checking if user was recently informed using infobot");
             if (x != null)
             {
                 response = "Hey " + invoker.Nick + ", you are welcome, but keep in mind I am just a stupid bot, it was actually " + x.User + " who helped you :-)";
                 Ring.Delete(x);
             }
             core.irc._SlowQueue.DeliverMessage(response, channel);
         }
     }
 }
示例#4
0
 public override void Hook_Channel(config.channel channel)
 {
     if (channel.RetrieveObject("RC") == null)
     {
         channel.RegisterObject(new RecentChanges(channel), "RC");
     }
 }
示例#5
0
 public override void Hook_Channel(config.channel channel)
 {
     if (channel.RetrieveObject("rss") == null)
     {
         channel.RegisterObject(new Feed(channel), "rss");
     }
 }
示例#6
0
 public override void Hook_Nick(config.channel channel, User Target, string OldNick)
 {
     Notification result = Notification.RetrieveTarget(Target.Nick);
     while (result != null)
     {
         core.irc._SlowQueue.DeliverMessage(result.Source_Name + "! " + OldNick + " just changed nicknames to " + Target.Nick + " which you wanted to talk with, in " + channel.Name + ". This message was delivered to you because you asked me to notify you about this user's activity. For more information, see http://meta.wikimedia.org/wiki/WM-Bot", result.Source_Name, IRC.priority.low);
         lock (Notification.NotificationList)
         {
             Notification.NotificationList.Remove(result);
         }
         result = Notification.RetrieveTarget(Target.Nick);
     }
     result = Notification.RetrieveTarget(OldNick);
     while (result != null)
     {
         core.irc._SlowQueue.DeliverMessage(result.Source_Name + "! " + OldNick + " just changed a nickname to " + Target.Nick + " which you wanted to talk with, in " + channel.Name + ". This message was delivered to you because you asked me to notify you about this user's activity. For more information, see http://meta.wikimedia.org/wiki/WM-Bot", result.Source_Name, IRC.priority.low);
         lock (Notification.NotificationList)
         {
             Notification.NotificationList.Remove(result);
         }
         result = Notification.RetrieveTarget(OldNick);
     }
     if (Target.Nick.ToLower() != OldNick.ToLower())
     {
         result = Notification.RetrieveSource(OldNick);
         while (result != null)
         {
             result.Source_Name = Target.Nick;
             result = Notification.RetrieveSource(OldNick);
         }
     }
 }
示例#7
0
 /// <summary>
 /// Join channel
 /// </summary>
 /// <param name="chan">Channel</param>
 /// <param name="user">User</param>
 /// <param name="host">Host</param>
 /// <param name="message">Message</param>
 public static void addChannel(config.channel chan, string user, string host, string message)
 {
     try
     {
         if (message.StartsWith(config.CommandPrefix + "add"))
         {
             if (chan.Users.IsApproved(user, host, "admin"))
             {
                 while (!core.FinishedJoining)
                 {
                     core.Log("Postponing request to join because bot is still loading", true);
                     Thread.Sleep(2000);
                 }
                 if (message.Contains(" "))
                 {
                     string channel = message.Substring(message.IndexOf(" ") + 1);
                     if (!validFile(channel) || (channel.Contains("#") == false))
                     {
                         irc._SlowQueue.DeliverMessage(messages.get("InvalidName", chan.Language), chan.Name);
                         return;
                     }
                     lock (config.channels)
                     {
                         foreach (config.channel cu in config.channels)
                         {
                             if (channel == cu.Name)
                             {
                                 irc._SlowQueue.DeliverMessage(messages.get("ChannelIn", chan.Language), chan.Name);
                                 return;
                             }
                         }
                     }
                     bool existing = config.channel.channelExist(channel);
                     config.channel xx = new config.channel(channel);
                     lock (config.channels)
                     {
                         config.channels.Add(xx);
                     }
                     config.Save();
                     xx.instance.irc.SendData("JOIN " + channel);
                     Thread.Sleep(100);
                     config.channel Chan = getChannel(channel);
                     if (!existing)
                     {
                         Chan.Users.addUser("admin", IRCTrust.normalize(user) + "!.*@" + IRCTrust.normalize(host));
                     }
                     return;
                 }
                 irc.Message(messages.get("InvalidName", chan.Language), chan.Name);
                 return;
             }
             irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", chan.Language), chan.Name);
         }
     }
     catch (Exception b)
     {
         handleException(b);
     }
 }
示例#8
0
 public override void Hook_PRIV(config.channel channel, User invoker, string message)
 {
     if (message == "@replag")
     {
         core.irc._SlowQueue.DeliverMessage("Replication lag is approximately " + GetReplag(), channel);
         return;
     }
 }
示例#9
0
 public override void Hook_ChannelDrop(config.channel chan)
 {
     if (File.Exists(variables.config + Path.DirectorySeparatorChar + chan.Name + ".list"))
     {
         core.Log("RC: Removing db of " + chan.Name + " RC feed");
         File.Delete(variables.config + Path.DirectorySeparatorChar + chan.Name + ".list");
     }
 }
示例#10
0
        public string Format(string name_url, string url, string page, string username, string link, string summary, config.channel chan)
        {
            if (GetConfig(chan, "RC.Template", "") == "")
            {
                return messages.get("fl", chan.Language, new List<string> { "12" + name_url + "", "" + page + "", "" + username + "", url + "?diff=" + link, summary });
            }

            return GetConfig(chan, "RC.Template", "").Replace("$wiki", name_url).Replace("$url", url).Replace("$link", link).Replace("$username", username).Replace("$page", page).Replace("$summary", summary);
        }
示例#11
0
文件: RC.cs 项目: atdt/wikimedia-bot
 public RecentChanges(config.channel _channel)
 {
     channel = _channel;
     changed = false;
     Load();
     lock (rc)
     {
         rc.Add(this);
     }
 }
示例#12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="channel"></param>
 public HtmlDump(config.channel channel)
 {
     dumpname = config.DumpDir + "/" + channel.Name + ".htm";
     if (!System.IO.Directory.Exists(config.DumpDir))
     {
         core.Log("Creating a directory for dump");
         System.IO.Directory.CreateDirectory(config.DumpDir);
     }
     Channel = channel;
 }
示例#13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="chan">Channel</param>
 /// <param name="user">User</param>
 /// <param name="host">Host</param>
 /// <param name="message">Message</param>
 public static void addChannel(config.channel chan, string user, string host, string message)
 {
     try
     {
         if (message.StartsWith("@add"))
         {
             if (chan.Users.isApproved(user, host, "admin"))
             {
                 if (message.Contains(" "))
                 {
                     string channel = message.Substring(message.IndexOf(" ") + 1);
                     if (!validFile(channel) || (channel.Contains("#") == false))
                     {
                         irc._SlowQueue.DeliverMessage(messages.get("InvalidName", chan.Language), chan.Name);
                         return;
                     }
                     lock (config.channels)
                     {
                         foreach (config.channel cu in config.channels)
                         {
                             if (channel == cu.Name)
                             {
                                 irc._SlowQueue.DeliverMessage(messages.get("ChannelIn", chan.Language), chan.Name);
                                 return;
                             }
                         }
                     }
                     bool existing = config.channel.channelExist(channel);
                     lock (config.channels)
                     {
                         config.channels.Add(new config.channel(channel));
                     }
                     config.Save();
                     irc.wd.WriteLine("JOIN " + channel);
                     irc.wd.Flush();
                     Thread.Sleep(100);
                     config.channel Chan = getChannel(channel);
                     if (!existing)
                     {
                         Chan.Users.addUser("admin", IRCTrust.normalize(user) + "!.*@" + IRCTrust.normalize(host));
                     }
                     return;
                 }
                 irc.Message(messages.get("InvalidName", chan.Language), chan.Name);
                 return;
             }
             irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", chan.Language), chan.Name);
             return;
         }
     }
     catch (Exception b)
     {
         handleException(b);
     }
 }
示例#14
0
 public override string Extension_DumpHtml(config.channel channel)
 {
     string HTML = "";
     if (Module.GetConfig(channel, "Statistics.Enabled", false))
     {
         Statistics list = (Statistics)channel.RetrieveObject(NAME);
         if (list != null)
         {
             HTML += "\n<br>\n<h4>Most active users :)</h4>\n<br>\n\n<table class=\"infobot\" width=100% border=1>";
             HTML += "<tr><td>N.</td><th>Nick</th><th>Messages (average / day)</th><th>Number of posted messages</th><th>Active since</th></tr>";
             int id = 0;
             int totalms = 0;
             DateTime startime = DateTime.Now;
             lock (list.data)
             {
                 list.data.Sort();
                 list.data.Reverse();
                 foreach (Statistics.list user in list.data)
                 {
                     id++;
                     totalms += user.messages;
                     if (id > 100)
                     {
                         continue;
                     }
                     if (startime > user.logging_since)
                     {
                         startime = user.logging_since;
                     }
                     System.TimeSpan uptime = System.DateTime.Now - user.logging_since;
                     float average = user.messages;
                     average = ((float)user.messages / (float)(uptime.Days + 1));
                     if (user.URL != "")
                     {
                         HTML += "<tr><td>" + id.ToString() + ".</td><td><a target=\"_blank\" href=\"" + user.URL + "\">" + user.user + "</a></td><td>" + average.ToString() + "</td><td>" + user.messages.ToString() + "</td><td>" + user.logging_since.ToString() + "</td></tr>";
                     }
                     else
                     {
                         HTML += "<tr><td>" + id.ToString() + ".</td><td>" + user.user + "</td><td>" + average.ToString() + "</td><td>" + user.messages.ToString() + "</td><td>" + user.logging_since.ToString() + "</td></tr>";
                     }
                     HTML += "  \n";
                 }
             }
             System.TimeSpan uptime_total = System.DateTime.Now - startime;
             float average2 = totalms;
             average2 = (float)totalms / (1 + uptime_total.Days);
             HTML += "<tr><td>N/A</td><th>Total:</th><th>" + average2.ToString() + "</th><th>" + totalms.ToString() + "</th><td>N/A</td></tr>";
             HTML += "  \n";
             HTML += "</table>";
         }
     }
     return HTML;
 }
示例#15
0
 public override void Hook_Kick(config.channel channel, User source, User user)
 {
     Notification result = Notification.RetrieveTarget(user.Nick);
     while (result != null)
     {
         core.irc._SlowQueue.DeliverMessage(result.Source_Name + "! " + user.Nick + " just got kicked from " + channel.Name + ". This message was delivered to you because you asked me to notify you about this user's activity. For more information, see http://meta.wikimedia.org/wiki/WM-Bot", result.Source_Name, IRC.priority.low);
         lock (Notification.NotificationList)
         {
             Notification.NotificationList.Remove(result);
         }
         result = Notification.RetrieveTarget(user.Nick);
     }
 }
示例#16
0
        public override string Extension_DumpHtml(config.channel channel)
        {
            string HTML = "";

            if (GetConfig(channel, "RC.Enabled", false))
            {
                RecentChanges rc = (RecentChanges)channel.RetrieveObject("RC");
                if (rc != null)
                {
                    HTML = rc.ToTable();
                }
            }
            return HTML;
        }
示例#17
0
 public static bool Linkable(config.channel host, config.channel guest)
 {
     if (host == null)
     {
         return false;
     }
     if (guest == null)
     {
         return false;
     }
     if (host.sharedlink.Contains(guest))
     {
         return true;
     }
     return false;
 }
示例#18
0
 public void GetOp(config.channel chan)
 {
     if (!GetConfig(chan, "OP.Permanent", false))
     {
         chan.instance.irc._SlowQueue.Send("CS op " + chan.Name, IRC.priority.high);
         return;
     }
     // get our user
     User user = chan.RetrieveUser(chan.instance.Nick);
     if (user == null)
     {
         chan.instance.irc._SlowQueue.Send("CS op " + chan.Name, IRC.priority.high);
         return;
     }
     if (!user.IsOperator)
     {
         chan.instance.irc._SlowQueue.Send("CS op " + chan.Name, IRC.priority.high);
     }
 }
示例#19
0
 public override string Extension_DumpHtml(config.channel channel)
 {
     string HTML = "";
     infobot_core info = (infobot_core)channel.RetrieveObject("Infobot");
     if (info != null)
     {
         HTML += "\n<table border=1 class=\"infobot\" width=100%>\n<tr><th width=10%>Key</th><th>Value</th></tr>\n";
         List<infobot_core.InfobotKey> list = new List<infobot_core.InfobotKey>();
         info.locked = true;
         lock (info.Keys)
         {
             if (Module.GetConfig(channel, "Infobot.Sorted", false) != false)
             {
                 list = info.SortedItem();
             }
             else
             {
                 list.AddRange(info.Keys);
             }
         }
         if (info.Keys.Count > 0)
         {
             foreach (infobot_core.InfobotKey Key in list)
             {
                 HTML += core.HTML.AddKey(Key.Key, Key.Text);
             }
         }
         HTML += "</table>\n";
         HTML += "<h4>Aliases</h4>\n<table class=\"infobot\" border=1 width=100%>\n";
         lock (info.Alias)
         {
             foreach (infobot_core.InfobotAlias data in info.Alias)
             {
                 HTML += core.HTML.AddLink(data.Name, data.Key);
             }
         }
         HTML += "</table><br>\n";
         info.locked = false;
     }
     return HTML;
 }
示例#20
0
        public override void Hook_PRIV(config.channel channel, User invoker, string message)
        {
            chanLog(message, channel, invoker.Nick, invoker.Host);
            if (message == "@logon")
            {
                if (channel.Users.isApproved(invoker.Nick, invoker.Host, "admin"))
                {
                    if (Module.GetConfig(channel, "Logging.Enabled", false))
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("ChannelLogged", channel.Language), channel.Name);
                        return;
                    }
                    else
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("LoggingOn", channel.Language), channel.Name);
                        Module.SetConfig(channel, "Logging.Enabled", true);
                        channel.SaveConfig();
                        return;
                    }
                }
                if (!channel.suppress_warnings)
                {
                    core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low);
                }
                return;
            }

            if (message == "@logoff")
            {
                if (channel.Users.isApproved(invoker.Nick, invoker.Host, "admin"))
                {
                    if (!Module.GetConfig(channel, "Logging.Enabled", false))
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("LogsE1", channel.Language), channel.Name);
                        return;
                    }
                    else
                    {
                        Module.SetConfig(channel, "Logging.Enabled", false);
                        channel.SaveConfig();
                        core.irc._SlowQueue.DeliverMessage(messages.get("NotLogged", channel.Language), channel.Name);
                        return;
                    }
                }
                if (!channel.suppress_warnings)
                {
                    core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low);
                }
                return;
            }
        }
示例#21
0
 public override void Hook_OnSelf(config.channel channel, User self, string message)
 {
     chanLog(message, channel, config.username, "");
 }
示例#22
0
 public override void Hook_ACTN(config.channel channel, User invoker, string message)
 {
     chanLog(message, channel, invoker.Nick, invoker.Host, false);
 }
示例#23
0
 public override bool Hook_SetConfig(config.channel chan, User invoker, string config, string value)
 {
     switch (config)
     {
         case "recent-changes-template":
             if (value != "null")
             {
                 Module.SetConfig(chan, "RC.Template", value);
                 core.irc._SlowQueue.DeliverMessage(messages.get("configuresave", chan.Language, new List<string> { value, config }), chan);
                 chan.SaveConfig();
                 return true;
             }
             else
             {
                 Module.SetConfig(chan, "RC.Template", "");
                 core.irc._SlowQueue.DeliverMessage(messages.get("configuresave", chan.Language, new List<string> { "null", config }), chan);
                 chan.SaveConfig();
                 return true;
             }
     }
     return false;
 }
示例#24
0
        public override void Hook_PRIV(config.channel channel, User invoker, string message)
        {
            if (message.StartsWith(config.CommandPrefix + "RC-"))
            {
                if (channel.Users.IsApproved(invoker, "trust"))
                {
                    if (GetConfig(channel, "RC.Enabled", false))
                    {
                        string[] a = message.Split(' ');
                        if (a.Length < 3)
                        {
                            core.irc._SlowQueue.DeliverMessage(messages.get("Feed8", channel.Language, new List<string> { invoker.Nick }), channel.Name);
                            return;
                        }
                        string wiki = a[1];
                        string Page = a[2];
                        RecentChanges rc = (RecentChanges)channel.RetrieveObject("RC");
                        if (rc != null)
                        {
                            rc.removeString(wiki, Page);
                        }
                        return;
                    }
                    else
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("Feed3", channel.Language), channel.Name);
                        return;
                    }
                }
                if (!channel.suppress_warnings)
                {
                    core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low);
                }
                return;
            }

            if (message.StartsWith(config.CommandPrefix + "recentchanges- "))
            {
                if (channel.Users.IsApproved(invoker, "root"))
                {
                    if (GetConfig(channel, "RC.Enabled", false))
                    {
                        if (!message.Contains(" "))
                        {
                            if (!channel.suppress_warnings)
                            {
                                core.irc._SlowQueue.DeliverMessage(messages.get("InvalidWiki", channel.Language), channel.Name);
                            }
                            return;
                        }
                        string _channel = message.Substring(message.IndexOf(" ") + 1);
                        if (RecentChanges.DeleteChannel(channel, _channel))
                        {
                            core.irc._SlowQueue.DeliverMessage(messages.get("Wiki-", channel.Language), channel.Name, IRC.priority.high);
                        }
                        return;
                    }
                    else
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("Feed3", channel.Language), channel.Name);
                        return;
                    }
                }
                if (!channel.suppress_warnings)
                {
                    core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low);
                }
                return;
            }

            if (message.StartsWith(config.CommandPrefix + "RC+ "))
            {
                if (channel.Users.IsApproved(invoker, "trust"))
                {
                    if (GetConfig(channel, "RC.Enabled", false))
                    {
                        string[] a = message.Split(' ');
                        if (a.Length < 3)
                        {
                            core.irc._SlowQueue.DeliverMessage(messages.get("Feed4", channel.Language) + invoker.Nick + messages.get("Feed5", channel.Language), channel.Name);
                            return;
                        }
                        string wiki = a[1];
                        string Page = a[2];
                        RecentChanges rc = (RecentChanges)channel.RetrieveObject("RC");
                        if (rc != null)
                        {
                            rc.insertString(wiki, Page);
                        }
                        return;
                    }
                    else
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("Feed3", channel.Language), channel.Name);
                        return;
                    }
                }
                if (!channel.suppress_warnings)
                {
                    core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low);
                }
                return;
            }

            if (message == config.CommandPrefix + "recentchanges-off")
            {
                if (channel.Users.IsApproved(invoker, "admin"))
                {
                    if (!GetConfig(channel, "RC.Enabled", false))
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("Feed6", channel.Language), channel.Name);
                        return;
                    }
                    else
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("Feed7", channel.Language), channel.Name);
                        SetConfig(channel, "RC.Enabled", false);
                        channel.SaveConfig();
                        return;
                    }
                }
                if (!channel.suppress_warnings)
                {
                    core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low);
                }
                return;
            }

            if (message == config.CommandPrefix + "recentchanges-on")
            {
                if (channel.Users.IsApproved(invoker, "recentchanges-manage"))
                {
                    if (GetConfig(channel, "RC.Enabled", false))
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("Feed1", channel.Language), channel.Name);
                        return;
                    }
                    else
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("Feed2", channel.Language), channel.Name);
                        SetConfig(channel, "RC.Enabled", true);
                        channel.SaveConfig();
                        config.Save();
                        return;
                    }
                }
                if (!channel.suppress_warnings)
                {
                    core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low);
                }
                return;
            }

            if (message.StartsWith(config.CommandPrefix + "recentchanges+"))
            {
                if (channel.Users.IsApproved(invoker, "recentchanges-manage"))
                {
                    if (GetConfig(channel, "RC.Enabled", false))
                    {
                        if (!message.Contains(" "))
                        {
                            if (!channel.suppress_warnings)
                            {
                                core.irc._SlowQueue.DeliverMessage(messages.get("InvalidWiki", channel.Language), channel.Name);
                            }
                            return;
                        }
                        string _channel = message.Substring(message.IndexOf(" ") + 1);
                        if (RecentChanges.InsertChannel(channel, _channel))
                        {
                            core.irc._SlowQueue.DeliverMessage(messages.get("Wiki+", channel.Language), channel.Name);
                        }
                        return;
                    }
                    else
                    {
                        core.irc._SlowQueue.DeliverMessage(messages.get("Feed3", channel.Language), channel.Name);
                        return;
                    }
                }
                if (!channel.suppress_warnings)
                {
                    core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low);
                }
                return;
            }
        }
示例#25
0
 public override bool Hook_GetConfig(config.channel chan, User invoker, string config)
 {
     switch (config)
     {
         case "recent-changes-template":
             core.irc._SlowQueue.DeliverMessage("Value of " + config + " is: " + GetConfig(chan, "RC.Template", "<default value>"), chan);
             return true;
     }
     return false;
 }
示例#26
0
 public Feed(config.channel _owner)
 {
     DB = variables.config + "/" + _owner.Name + "_feed.xml";
     owner = _owner;
     Load();
 }
示例#27
0
 public override void Hook_Channel(config.channel channel)
 {
     core.Log("Loading " + channel.Name);
     if (channel == null)
     {
         core.Log("NULL");
     }
     if (Snapshots)
     {
         try
         {
             if (Directory.Exists(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name) == false)
             {
                 core.Log("Creating directory for infobot for " + channel.Name);
                 Directory.CreateDirectory(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name);
             }
         }
         catch (Exception fail)
         {
             core.handleException(fail);
         }
     }
     if (channel.RetrieveObject("Infobot") == null)
     {
         // sensitivity
         bool cs = Module.GetConfig(channel, "Infobot.Case", true);
         channel.RegisterObject(new infobot_core(getDB(ref channel), channel.Name, cs), "Infobot");
     }
 }
示例#28
0
        /// <summary>
        /// Log file
        /// </summary>
        /// <param name="message">Message</param>
        /// <param name="channel">Channel</param>
        /// <param name="user">User</param>
        /// <param name="host">Host</param>
        /// <param name="noac">Action (if true it's logged as message, if false it's action)</param>
        public void chanLog(string message, config.channel channel, string user, string host, bool noac = true)
        {
            try
            {
                if (Module.GetConfig(channel, "Logging.Enabled", false))
                {
                    lock (jobs)
                    {
                        string log;
                        string URL = core.Host.Host2Name(host);
                        string srcs = "";
                        string messagehtml = System.Web.HttpUtility.HtmlEncode(message);
                        updateHttp(ref messagehtml);
                        //updateBold(ref messagehtml);
                        if (!noac)
                        {
                            if (URL != "")
                            {
                                srcs = "<font class=\"date\"><b>" + timedateToString(DateTime.Now.Hour) + ":" +
                                    timedateToString(DateTime.Now.Minute) + ":" +
                                    timedateToString(DateTime.Now.Second) + "</b></font><font>* <a target=\"_blank\" href=\"" + URL + "\">" + user +
                                    "</a> " + messagehtml + "</font><br>\n";
                            }
                            else
                            {
                                srcs = "<font class=\"date\"><b>" + timedateToString(DateTime.Now.Hour) + ":" +
                                    timedateToString(DateTime.Now.Minute) + ":" +
                                    timedateToString(DateTime.Now.Second) + "</b></font><font>* " + user + " " +
                                    messagehtml + "</font><br>\n";
                            }
                            log = "[" + timedateToString(DateTime.Now.Hour) + ":" +
                                timedateToString(DateTime.Now.Minute) + ":" +
                                timedateToString(DateTime.Now.Second) + "] * " +
                                user + " " + message + "\n";
                        }
                        else
                        {
                            if (URL != "")
                            {
                                srcs = "<font class=\"date\"><b>" + timedateToString(DateTime.Now.Hour) + ":" +
                                        timedateToString(DateTime.Now.Minute) + ":" +
                                        timedateToString(DateTime.Now.Second) + "</b></font><font class=\"nick\"><b> &lt;<a target=\"_blank\" href=\"" + URL +
                                        "\">" + user + "</a>&gt; </b></font><font>" + messagehtml + "</font><br>\n";
                            }
                            else
                            {
                                srcs = "<font class=\"date\"><b>" + timedateToString(DateTime.Now.Hour) + ":" +
                                        timedateToString(DateTime.Now.Minute) + ":" +
                                        timedateToString(DateTime.Now.Second) + "</b></font><font class=\"nick\"><b> &lt;" + user + "&gt; </b></font><font>" +
                                        messagehtml + "</font><br>\n";
                            }

                            log = "[" + timedateToString(DateTime.Now.Hour) + ":"
                                + timedateToString(DateTime.Now.Minute) + ":" +
                                timedateToString(DateTime.Now.Second) + "] " + "<" +
                                user + ">\t " + message + "\n";
                        }
                        Job line = new Job();
                        line.ch = channel;
                        line.time = DateTime.Now;
                        line.HTML = srcs;
                        line.message = log;
                        jobs.Add(line);
                    }
                }
            }
            catch (Exception er)
            {
                // nothing
                handleException(er);
            }
        }
示例#29
0
 private bool writeLog(string message, string html, config.channel channel, System.DateTime _datetime)
 {
     try
     {
         System.IO.File.AppendAllText(config.path_txt + channel.LogDir + _datetime.Year + timedateToString(_datetime.Month) + timedateToString(_datetime.Day) + ".txt", message);
         System.IO.File.AppendAllText(config.path_htm + channel.LogDir + _datetime.Year + timedateToString(_datetime.Month) + timedateToString(_datetime.Day) + ".htm", html);
         return true;
     }
     catch (Exception er)
     {
         // nothing
         Log("Unable to write to log files, delaying write!", true);
         Console.WriteLine(er.Message);
     }
     return false;
 }
示例#30
0
        public string Format(string name_url, string url, string page, string username, string link, string summary, config.channel chan, bool bot, bool New, bool minor)
        {
            if (GetConfig(chan, "RC.Template", "") == "")
            {
                if (!New)
                {
                    return messages.get("fl", chan.Language, new List<string> { "12" + name_url + "", "" + page + "", "" + username + "", url + "?diff=" + link, summary });
                }
                return messages.get("fl", chan.Language, new List<string> { "12" + name_url + "", "" + page + "", "" + username + "", url + "?title=" + name_url, summary });
            }

            string action = "modified";
            string flags = "";

            if (minor)
            {
                flags += "minor edit, ";
            }

            if (New)
            {
                flags += "new page, ";
                action = "created";
            }

            if (bot)
            {
                flags += "bot edit";
            }

            if (flags.EndsWith(", "))
            {
                flags = flags.Substring(0, flags.Length - 2);
            }

            string fu = url + "?diff=" + link;
            if (New)
            {
                fu = url + "?title=" + System.Web.HttpUtility.UrlEncode(page).Replace("+", "_");
            }

            return GetConfig(chan, "RC.Template", "").Replace("$wiki", name_url)
                   .Replace("$encoded_wiki_page", System.Web.HttpUtility.UrlEncode(page).Replace("+", "_").Replace("%3a", ":").Replace("%2f", "/").Replace("%28", "(").Replace("%29", ")"))
                   .Replace("$encoded_wiki_username", System.Web.HttpUtility.UrlEncode(username).Replace("+", "_").Replace("%3a", ":").Replace("%2f", "/").Replace("%28", "(").Replace("%29", ")"))
                   .Replace("$encoded_page", System.Web.HttpUtility.UrlEncode(page))
                   .Replace("$encoded_username", System.Web.HttpUtility.UrlEncode(username))
                   .Replace("$url", url)
                   .Replace("$link", link)
                   .Replace("$fullurl", fu)
                   .Replace("$username", username)
                   .Replace("$page", page)
                   .Replace("$summary", summary)
                   .Replace("$flags", flags)
                   .Replace("$action", action);
        }