本文整理汇总了C#中Channel.RetrieveObject方法的典型用法代码示例。如果您正苦于以下问题:C# Channel.RetrieveObject方法的具体用法?C# Channel.RetrieveObject怎么用?C# Channel.RetrieveObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel.RetrieveObject方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Extension_DumpHtml
public override string Extension_DumpHtml(Channel channel)
{
string HTML = "";
DebugLog("Getting html for " + channel.Name);
try
{
if (GetConfig(channel, "RC.Enabled", false))
{
RecentChanges rc = (RecentChanges)channel.RetrieveObject("RC");
if (rc != null)
{
HTML = rc.ToTable();
}
else
{
Syslog.ErrorLog("NULL rc for " + channel.Name);
}
}
else
{
DebugLog("RC is disabled for " + channel.Name, 2);
}
}
catch (Exception fail)
{
HandleException(fail);
}
return HTML;
}
示例2: Hook_Channel
public override void Hook_Channel(Channel channel)
{
if (channel.RetrieveObject("rss") == null)
{
channel.RegisterObject(new Feed(channel), "rss");
}
}
示例3: Extension_DumpHtml
public override string Extension_DumpHtml(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.RssProviders)
{
foreach (Feed.Subscription feed in list.RssProviders)
{
HTML += "\n<tr><td>" + feed.Name + "</td><td><a href=\"" + feed.URL + "\">" + feed.URL + "</a></td><td>" + feed.template + "</td><td>" + (!feed.disabled) + "</td></tr>";
}
}
HTML += "</table>\n";
}
return HTML;
}
示例4: Extension_DumpHtml
public override string Extension_DumpHtml(Channel channel)
{
string HTML = "";
Infobot info = (Infobot)channel.RetrieveObject("Infobot");
if (info != null)
{
List<Infobot.InfobotKey> list = new List<Infobot.InfobotKey>();
List<Infobot.InfobotAlias> aliases = new List<Infobot.InfobotAlias>();
lock (info)
{
if (GetConfig(channel, "Infobot.Sorted", false))
{
list = info.SortedItem();
}
else
{
list.AddRange(info.Keys);
}
aliases.AddRange(info.Aliases);
}
string JSON_blob = Newtonsoft.Json.JsonConvert.SerializeObject(list);
JSON_blob += "\n\n" + Newtonsoft.Json.JsonConvert.SerializeObject(aliases);
string JSON_file = Configuration.Paths.DumpDir + "/" + channel.Name + "_dump.js";
File.WriteAllText(JSON_file, JSON_blob);
HTML += "JSON blob: <a href=\"" + System.Web.HttpUtility.UrlEncode(channel.Name) + "_dump.js\">open</a>";
HTML += "\n<table border=1 class=\"infobot\" width=100%>\n<tr><th width=10%>Key</th><th>Value</th></tr>\n";
if (list.Count > 0)
{
foreach (Infobot.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)
{
foreach (Infobot.InfobotAlias data in info.Aliases)
{
HTML += Core.HTML.AddLink(data.Name, data.Key);
}
}
HTML += "</table><br />\n";
}
return HTML;
}
示例5: Hook_PRIV
public override void Hook_PRIV(Channel channel, libirc.UserInfo invoker, string message)
{
if (message.StartsWith(Configuration.System.CommandPrefix + "RC-"))
{
if (channel.SystemUsers.IsApproved(invoker, "recentchanges-remove"))
{
if (GetConfig(channel, "RC.Enabled", false))
{
string[] a = message.Split(' ');
if (a.Length < 3)
{
IRC.DeliverMessage(messages.Localize("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.RemovePage(wiki, Page);
}
return;
}
IRC.DeliverMessage(messages.Localize("Feed3", channel.Language), channel);
return;
}
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel);
}
return;
}
if (message.StartsWith(Configuration.System.CommandPrefix + "RC+ "))
{
if (channel.SystemUsers.IsApproved(invoker, "recentchanges-add"))
{
if (GetConfig(channel, "RC.Enabled", false))
{
string[] a = message.Split(' ');
if (a.Length < 3)
{
IRC.DeliverMessage(messages.Localize("Feed4", channel.Language) + invoker.Nick + messages.Localize("Feed5", channel.Language), channel);
return;
}
string wiki = a[1];
string Page = a[2];
if (wiki.Contains("_"))
{
IRC.DeliverMessage("Underscore in wiki name is not supported, new format is for example: en.wikipedia.org instead of en_wikipedia", channel);
return;
}
RecentChanges rc = (RecentChanges)channel.RetrieveObject("RC");
if (rc != null)
{
rc.MonitorPage(wiki, Page);
}
return;
}
IRC.DeliverMessage(messages.Localize("Feed3", channel.Language), channel);
return;
}
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel);
}
return;
}
}
示例6: Hook_ChannelDrop
public override void Hook_ChannelDrop(Channel chan)
{
RecentChanges rc = (RecentChanges)chan.RetrieveObject("RC");
if (rc != null && RecentChanges.recentChangesList.Contains(rc))
RecentChanges.recentChangesList.Remove(rc);
if (File.Exists(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + chan.Name + ".list"))
{
Log("Removing db of " + chan.Name + " RC feed");
File.Delete(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + chan.Name + ".list");
}
}
示例7: Hook_Channel
public override void Hook_Channel(Channel channel)
{
if (channel.RetrieveObject("RC") == null)
{
channel.RegisterObject(new RecentChanges(channel), "RC");
}
}
示例8: Hook_SetConfig
public override bool Hook_SetConfig(Channel chan, libirc.UserInfo invoker, string config, string value)
{
bool _temp_a;
switch (config)
{
case "infobot-trim-white-space-in-name":
if (bool.TryParse(value, out _temp_a))
{
SetConfig(chan, "Infobot.Trim-white-space-in-name", _temp_a);
IRC.DeliverMessage(messages.Localize("configuresave", chan.Language, new List<string> { value, config }), chan.Name);
chan.SaveConfig();
return true;
}
IRC.DeliverMessage(messages.Localize("configure-va", chan.Language, new List<string> { config, value }), chan.Name);
return true;
case "infobot-auto-complete":
if (bool.TryParse(value, out _temp_a))
{
SetConfig(chan, "Infobot.auto-complete", _temp_a);
IRC.DeliverMessage(messages.Localize("configuresave", chan.Language, new List<string> { value, config }), chan.Name);
chan.SaveConfig();
return true;
}
IRC.DeliverMessage(messages.Localize("configure-va", chan.Language, new List<string> { config, value }), chan.Name);
return true;
case "infobot-sorted":
if (bool.TryParse(value, out _temp_a))
{
SetConfig(chan, "Infobot.Sorted", _temp_a);
IRC.DeliverMessage(messages.Localize("configuresave", chan.Language, new List<string> { value, config }), chan.Name);
chan.SaveConfig();
return true;
}
IRC.DeliverMessage(messages.Localize("configure-va", chan.Language, new List<string> { config, value }), chan.Name);
return true;
case "infobot-help":
if (bool.TryParse(value, out _temp_a))
{
SetConfig(chan, "Infobot.Help", _temp_a);
IRC.DeliverMessage(messages.Localize("configuresave", chan.Language, new List<string> { value, config }), chan.Name);
chan.SaveConfig();
return true;
}
IRC.DeliverMessage(messages.Localize("configure-va", chan.Language, new List<string> { config, value }), chan.Name);
return true;
case "infobot-case":
if (bool.TryParse(value, out _temp_a))
{
SetConfig(chan, "Infobot.Case", _temp_a);
IRC.DeliverMessage(messages.Localize("configuresave", chan.Language, new List<string> { value, config }), chan.Name);
chan.SaveConfig();
Infobot infobot = (Infobot)chan.RetrieveObject("Infobot");
if (infobot != null)
{
infobot.Sensitive = _temp_a;
}
return true;
}
IRC.DeliverMessage(messages.Localize("configure-va", chan.Language, new List<string> { config, value }), chan.Name);
return true;
}
return false;
}
示例9: Hook_PRIV
public override void Hook_PRIV(Channel channel, libirc.UserInfo invoker, string message)
{
// "\uff01" is the full-width version of "!".
if ((message.StartsWith("!") || message.StartsWith("\uff01")) && GetConfig(channel, "Infobot.Enabled", true))
{
while (Unwritable)
{
Thread.Sleep(10);
}
Unwritable = true;
Infobot.InfoItem item = new Infobot.InfoItem
{
Channel = channel,
Name = "!" + message.Substring(1),
User = invoker,
};
jobs.Add(item);
Unwritable = false;
}
Infobot infobot = null;
if (message.StartsWith(Configuration.System.CommandPrefix))
{
infobot = (Infobot)channel.RetrieveObject("Infobot");
if (infobot == null)
{
Syslog.Log("Object Infobot in " + channel.Name + " doesn't exist", true);
}
if (GetConfig(channel, "Infobot.Enabled", true))
{
if (infobot != null)
{
infobot.Find(message, channel);
infobot.RSearch(message, channel);
}
}
}
if (Snapshots)
{
if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-recovery "))
{
if (channel.SystemUsers.IsApproved(invoker, PermissionRestoreSnapshot))
{
string name = message.Substring("@infobot-recovery ".Length);
if (!GetConfig(channel, "Infobot.Enabled", true))
{
IRC.DeliverMessage("Infobot is not enabled in this channel", channel, libirc.Defs.Priority.Low);
return;
}
if (infobot != null)
{
infobot.RecoverSnapshot(channel, name);
}
return;
}
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, libirc.Defs.Priority.Low);
}
return;
}
if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-snapshot "))
{
if (channel.SystemUsers.IsApproved(invoker, PermissionSnaphot))
{
string name = message.Substring("@infobot-snapshot ".Length);
if (!GetConfig(channel, "Infobot.Enabled", true))
{
IRC.DeliverMessage("Infobot is not enabled in this channel", channel, libirc.Defs.Priority.Low);
return;
}
if (infobot != null)
{
infobot.CreateSnapshot(channel, name);
}
return;
}
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, libirc.Defs.Priority.Low);
}
return;
}
if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-set-raw "))
{
if (channel.SystemUsers.IsApproved(invoker, PermissionAdd))
{
string name = message.Substring("@infobot-set-raw ".Length);
if (!GetConfig(channel, "Infobot.Enabled", true))
{
IRC.DeliverMessage("Infobot is not enabled in this channel", channel, libirc.Defs.Priority.Low);
return;
}
if (infobot != null)
{
infobot.SetRaw(name, invoker.Nick, channel);
//.........这里部分代码省略.........
示例10: Hook_Channel
public override void Hook_Channel(Channel channel)
{
Syslog.Log("Loading " + channel.Name);
if (channel == null)
{
Syslog.Log("NULL");
}
if (Snapshots)
{
try
{
if (Directory.Exists(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name) == false)
{
Syslog.Log("Creating directory for infobot for " + channel.Name);
Directory.CreateDirectory(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name);
}
}
catch (Exception fail)
{
Core.HandleException(fail, "infobot");
}
}
if (channel.RetrieveObject("Infobot") == null)
{
// sensitivity
bool cs = GetConfig(channel, "Infobot.Case", true);
channel.RegisterObject(new Infobot(getDB(ref channel), channel, this, cs), "Infobot");
}
}
示例11: Hook_PRIV
public override void Hook_PRIV(Channel channel, libirc.UserInfo invoker, string message)
{
if (GetConfig(channel, "Statistics.Enabled", false))
{
Statistics st = (Statistics)channel.RetrieveObject("Statistics");
if (st != null)
{
st.Stat(invoker.Nick, message, invoker.Host);
}
}
if (message == Configuration.System.CommandPrefix + "statistics-off")
{
if (channel.SystemUsers.IsApproved(invoker, "admin"))
{
if (!GetConfig(channel, "Statistics.Enabled", false))
{
IRC.DeliverMessage(messages.Localize("StatE2", channel.Language), channel);
return;
}
SetConfig(channel, "Statistics.Enabled", false);
channel.SaveConfig();
IRC.DeliverMessage(messages.Localize("Stat-off", channel.Language), channel);
return;
}
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel);
}
return;
}
if (message == Configuration.System.CommandPrefix + "statistics-reset")
{
if (channel.SystemUsers.IsApproved(invoker, "admin"))
{
Statistics st = (Statistics)channel.RetrieveObject("Statistics");
if (st != null)
{
st.Delete();
}
IRC.DeliverMessage(messages.Localize("Statdt", channel.Language), channel);
return;
}
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel);
}
return;
}
if (message == Configuration.System.CommandPrefix + "statistics-on")
{
if (channel.SystemUsers.IsApproved(invoker, "admin"))
{
if (GetConfig(channel, "Statistics.Enabled", false))
{
IRC.DeliverMessage(messages.Localize("StatE1", channel.Language), channel);
return;
}
SetConfig(channel, "Statistics.Enabled", true);
channel.SaveConfig();
IRC.DeliverMessage(messages.Localize("Stat-on", channel.Language), channel);
return;
}
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name);
}
}
}
示例12: Hook_Channel
public override void Hook_Channel(Channel channel)
{
if (channel.RetrieveObject("Statistics") == null)
{
channel.RegisterObject(new Statistics(channel), NAME);
}
}
示例13: Extension_DumpHtml
public override string Extension_DumpHtml(Channel channel)
{
StringBuilder builder = new StringBuilder();
if (GetConfig(channel, "Statistics.Enabled", false))
{
Statistics list = (Statistics) channel.RetrieveObject(NAME);
if (list != null)
{
builder.AppendLine("<br />");
builder.AppendLine("<h4>Most active users :)</h4>");
builder.AppendLine("<br />");
builder.AppendLine();
builder.AppendLine("<table class=\"infobot\" width=100% border=1>");
builder.AppendLine(
"<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;
}
TimeSpan uptime = DateTime.Now - user.logging_since;
float average = (user.messages/(float) (uptime.Days + 1));
if (user.URL != "")
{
builder.AppendFormat(
"<tr><td>{0}.</td><td><a target=\"_blank\" href=\"{1}\">{2}</a></td><td>{3}</td><td>{4}</td><td>{5}</td></tr>\n",
id, user.URL, user.user, average, user.messages, user.logging_since
);
}
else
{
builder.AppendFormat("<tr><td>{0}.</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td></tr>\n",
id, user.user, average, user.messages, user.logging_since);
}
builder.AppendLine();
}
}
TimeSpan uptime_total = DateTime.Now - startime;
float average2 = (float) totalms/(1 + uptime_total.Days);
builder.AppendFormat("<tr><td>N/A</td><th>Total:</th><th>{0}</th><th>{1}</th><td>N/A</td></tr>\n", average2, totalms);
builder.AppendLine();
builder.AppendLine("</table>");
}
}
return builder.ToString();
}
示例14: Hook_PRIV
public override void Hook_PRIV(Channel channel, libirc.UserInfo invoker, string message)
{
if (message.StartsWith(Configuration.System.CommandPrefix + "rss- "))
{
if (channel.SystemUsers.IsApproved(invoker, "trust"))
{
string item = message.Substring("@rss+ ".Length);
Feed feed = (Feed)channel.RetrieveObject("rss");
if (feed != null)
{
feed.RemoveItem(item);
}
return;
}
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name);
}
}
if (message.StartsWith(Configuration.System.CommandPrefix + "rss-setstyle "))
{
if (channel.SystemUsers.IsApproved(invoker, "trust"))
{
string item = message.Substring("@rss-setstyle ".Length);
if (item.Contains(" "))
{
string id = item.Substring(0, item.IndexOf(" "));
string ur = item.Substring(item.IndexOf(" ") + 1);
Feed feed = (Feed)channel.RetrieveObject("rss");
if (feed != null)
{
feed.StyleItem(id, ur);
}
return;
}
if (item != "")
{
Feed feed = (Feed)channel.RetrieveObject("rss");
if (feed != null)
{
feed.StyleItem(item, "");
}
return;
}
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("Rss5", channel.Language), channel.Name);
}
}
else
{
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name);
}
}
}
if (message.StartsWith(Configuration.System.CommandPrefix + "rss-search+ "))
{
if (channel.SystemUsers.IsApproved(invoker, "trust"))
{
string item = message.Substring("@rss-search+ ".Length);
Feed feed = (Feed)channel.RetrieveObject("rss");
if (feed != null)
{
lock (feed.ScannerMatches)
{
if (feed.ScannerMatches.Contains(item))
{
IRC.DeliverMessage("This item is already being searched", channel);
return;
}
IRC.DeliverMessage("This item is now searched", channel);
feed.ScannerMatches.Add(item);
return;
}
}
IRC.DeliverMessage("Error, this channel doesn't have RC feed", channel);
return;
}
if (!channel.SuppressWarnings)
{
IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, libirc.Defs.Priority.Low);
}
}
if (message.StartsWith(Configuration.System.CommandPrefix + "rss-search- "))
{
if (channel.SystemUsers.IsApproved(invoker, "trust"))
{
string item = message.Substring("@rss-search+ ".Length);
Feed feed = (Feed)channel.RetrieveObject("rss");
if (feed != null)
{
lock (feed.ScannerMatches)
{
if (feed.ScannerMatches.Contains(item))
{
feed.ScannerMatches.Remove(item);
IRC.DeliverMessage("This item was removed", channel);
return;
//.........这里部分代码省略.........