当前位置: 首页>>代码示例>>C#>>正文


C# IrcClient.OnServerInfoReceived方法代码示例

本文整理汇总了C#中IrcClient.OnServerInfoReceived方法的典型用法代码示例。如果您正苦于以下问题:C# IrcClient.OnServerInfoReceived方法的具体用法?C# IrcClient.OnServerInfoReceived怎么用?C# IrcClient.OnServerInfoReceived使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IrcClient的用法示例。


在下文中一共展示了IrcClient.OnServerInfoReceived方法的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.OnServerInfoReceived(new SupportsEventArgs(client.ServerInfo));
        }
开发者ID:Roytazz,项目名称:TwitchLib,代码行数:91,代码来源:ServerHandlers.cs


注:本文中的IrcClient.OnServerInfoReceived方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。