本文整理汇总了C#中IrcClient.OnServerInfoRecieved方法的典型用法代码示例。如果您正苦于以下问题:C# IrcClient.OnServerInfoRecieved方法的具体用法?C# IrcClient.OnServerInfoRecieved怎么用?C# IrcClient.OnServerInfoRecieved使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IrcClient
的用法示例。
在下文中一共展示了IrcClient.OnServerInfoRecieved方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleISupport
public static void HandleISupport(IrcClient client, IrcMessage message)
{
if (client.ServerInfo == null)
client.ServerInfo = new ServerInfo();
foreach (var item in message.Parameters)
{
string key, value;
if (!item.Contains("="))
{
key = item;
value = null;
}
else
{
key = item.Remove(item.IndexOf('='));
value = item.Substring(item.IndexOf('=') + 1);
}
// TODO: Consider doing this differently
// TODO: Allow users to specify other things to handle
if (value != null)
{
switch (key.ToUpper())
{
case "PREFIX":
var modes = value.Substring(1, value.IndexOf(')') - 1);
var prefixes = value.Substring(value.IndexOf(')') + 1);
client.ServerInfo.Prefixes = new[] {modes, prefixes};
break;
case "CHANTYPES":
client.ServerInfo.ChannelTypes = value.ToCharArray();
break;
case "CHANMODES":
var chanModeGroups = value.Split(',');
client.ServerInfo.SupportedChannelModes.ChannelLists = chanModeGroups[0];
client.ServerInfo.SupportedChannelModes.ParameterizedSettings = chanModeGroups[1];
client.ServerInfo.SupportedChannelModes.OptionallyParameterizedSettings = chanModeGroups[2];
client.ServerInfo.SupportedChannelModes.Settings = chanModeGroups[3];
break;
case "MODES":
client.ServerInfo.MaxModesPerCommand = int.Parse(value);
break;
case "MAXCHANNELS": // TODO: CHANLIMIT
client.ServerInfo.MaxChannelsPerUser = int.Parse(value);
break;
case "NICKLEN":
client.ServerInfo.MaxNickLength = int.Parse(value);
break;
case "MAXLIST":
var limits = value.Split(',');
client.ServerInfo.ModeListLimits = new ServerInfo.ModeListLimit[limits.Length];
for (int i = 0; i < limits.Length; i++)
{
var limitedModes = limits[i].Remove(limits[i].IndexOf(':'));
var limit = int.Parse(limits[i].Substring(limits[i].IndexOf(':') + 1));
foreach (var mode in limitedModes)
client.ServerInfo.ModeListLimits[i] = new ServerInfo.ModeListLimit(mode, limit);
}
break;
case "NETWORK":
client.ServerInfo.NetworkName = value;
break;
case "EXCEPTS":
client.ServerInfo.SupportsBanExceptions = value[0];
break;
case "INVEX":
client.ServerInfo.SupportsInviteExceptions = value[0];
break;
case "TOPICLEN":
client.ServerInfo.MaxTopicLength = int.Parse(value);
break;
case "KICKLEN":
client.ServerInfo.MaxKickCommentLength = int.Parse(value);
break;
case "CHANNELLEN":
client.ServerInfo.MaxChannelNameLength = int.Parse(value);
break;
case "AWAYLEN":
client.ServerInfo.MaxAwayLength = int.Parse(value);
break;
}
}
}
client.OnServerInfoRecieved(new SupportsEventArgs(client.ServerInfo));
}