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


C# Core.Channel方法代码示例

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


在下文中一共展示了Core.Channel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

        protected override void Parse(Core.Server aServer, string aRawData, string aMessage, string[] aCommands)
        {
            ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType + "(" + aServer.Name + ")");

            string tUserName = aCommands[0].Split('!')[0];
            Channel tChan = aServer.Channel(aCommands[2]);

            Bot tBot = aServer.Bot(tUserName);

            #region VERSION

            if (aMessage == "VERSION")
            {
                log.Info("Parse() VERSION: " + Settings.Instance.IrcVersion);
                FireSendData(aServer, "NOTICE " + tUserName + " :\u0001VERSION " + Settings.Instance.IrcVersion + "\u0001");
                return;
            }

                #endregion

                #region XGVERSION

            if (aMessage == "XGVERSION")
            {
                log.Info("Parse() XGVERSION: " + Settings.Instance.XgVersion);
                FireSendData(aServer, "NOTICE " + tUserName + " :\u0001XGVERSION " + Settings.Instance.XgVersion + "\u0001");
                return;
            }

                #endregion

                #region DCC DOWNLOAD MESSAGE

            if (aMessage.StartsWith("DCC") && tBot != null)
            {
                Packet tPacket = tBot.OldestActivePacket();
                if (tPacket != null)
                {
                    if (tPacket.Connected)
                    {
                        log.Error("Parse() ignoring dcc from " + tBot + " because " + tPacket + " is already connected");
                    }
                    else
                    {
                        bool isOk = false;

                        int tPort = 0;
                        Int64 tChunk = 0;

                        string[] tDataList = aMessage.Split(' ');
                        if (tDataList[1] == "SEND")
                        {
                            log.Info("Parse() DCC from " + tBot);

                            // if the name of the file contains spaces, we have to replace em
                            if (aMessage.StartsWith("DCC SEND \""))
                            {
                                Match tMatch = Regex.Match(aMessage, "DCC SEND \"(?<packet_name>.+)\"(?<bot_data>[^\"]+)$");
                                if (tMatch.Success)
                                {
                                    aMessage = "DCC SEND " + tMatch.Groups["packet_name"].ToString().Replace(" ", "_").Replace("'", "") + tMatch.Groups["bot_data"];
                                    tDataList = aMessage.Split(' ');
                                }
                            }

                            #region IP CALCULATING

                            try
                            {
                                // this works not in mono?!
                                tBot.Ip = IPAddress.Parse(tDataList[3]);
                            }
                            catch (FormatException)
                            {
                                #region WTF - FLIP THE IP BECAUSE ITS REVERSED?!

                                string ip;
                                try
                                {
                                    ip = new IPAddress(long.Parse(tDataList[3])).ToString();
                                }
                                catch (Exception ex)
                                {
                                    log.Fatal("Parse() " + tBot + " - can not parse bot ip from string: " + aMessage, ex);
                                    return;
                                }
                                string realIp = "";
                                int pos = ip.LastIndexOf('.');
                                try
                                {
                                    realIp += ip.Substring(pos + 1) + ".";
                                    ip = ip.Substring(0, pos);
                                    pos = ip.LastIndexOf('.');
                                    realIp += ip.Substring(pos + 1) + ".";
                                    ip = ip.Substring(0, pos);
                                    pos = ip.LastIndexOf('.');
                                    realIp += ip.Substring(pos + 1) + ".";
                                    ip = ip.Substring(0, pos);
                                    pos = ip.LastIndexOf('.');
                                    realIp += ip.Substring(pos + 1);
//.........这里部分代码省略.........
开发者ID:sstraus,项目名称:xdcc-grabscher,代码行数:101,代码来源:PrivateMessage.cs

示例2: Parse

        protected override void Parse(Core.Server aServer, string aRawData, string aMessage, string[] aCommands)
        {
            ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType + "(" + aServer.Name + ")");

            string tUserName = aCommands[0].Split('!')[0];
            string tComCodeStr = aCommands[1];
            string tChannelName = aCommands[2];

            Channel tChan = aServer.Channel(tChannelName);
            Bot tBot = aServer.Bot(tUserName);

            if (tBot != null)
            {
                tBot.LastContact = DateTime.Now;
            }

            #region PRIVMSG

            if (tComCodeStr == "PRIVMSG")
            {
                _privateMessage.ParseData(aServer, aRawData);
                return;
            }

                #endregion

                #region NOTICE

            if (tComCodeStr == "NOTICE")
            {
                if (tUserName.ToLower() == "nickserv")
                {
                    _nickserv.ParseData(aServer, aRawData);
                }
                else
                {
                    _notice.ParseData(aServer, aRawData);
                }
                return;
            }

                #endregion

                #region NICK

            if (tComCodeStr == "NICK")
            {
                if (tBot != null)
                {
                    tBot.Name = aMessage;
                    log.Info("con_DataReceived() bot " + tUserName + " renamed to " + tBot);
                }
                else if (tUserName == Settings.Instance.IrcNick)
                {
                    // what should i do now?!
                    log.Error("con_DataReceived() wtf? i was renamed to " + aMessage);
                }
            }

                #endregion

                #region KICK

            else if (tComCodeStr == "KICK")
            {
                if (tChan != null)
                {
                    tUserName = aCommands[3];
                    if (tUserName == Settings.Instance.IrcNick)
                    {
                        tChan.Connected = false;
                        log.Warn("con_DataReceived() kicked from " + tChan + (aCommands.Length >= 5 ? " (" + aCommands[4] + ")" : "") + " - rejoining");
                        log.Warn("con_DataReceived() " + aRawData);
                        FireJoinChannel(aServer, tChan);

                        // statistics
                        Statistic.Instance.Increase(StatisticType.ChannelsKicked);
                    }
                    else
                    {
                        tBot = aServer.Bot(tUserName);
                        if (tBot != null)
                        {
                            tBot.Connected = false;
                            tBot.LastMessage = "kicked from " + tChan;
                            log.Info("con_DataReceived() " + tBot + " is offline");
                        }
                    }
                }
            }

                #endregion

                #region KILL

            else if (tComCodeStr == "KILL")
            {
                tUserName = aCommands[2];
                if (tUserName == Settings.Instance.IrcNick)
                {
//.........这里部分代码省略.........
开发者ID:sstraus,项目名称:xdcc-grabscher,代码行数:101,代码来源:Parser.cs

示例3: Parse

        protected override void Parse(Core.Server aServer, string aRawData, string aMessage, string[] aCommands)
        {
            ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType + "(" + aServer.Name + ")");

            Bot tBot = aServer.Bot(aCommands[0].Split('!')[0]);
            Channel tChan = aServer.Channel(aCommands[2]);

            string tComCodeStr = aCommands[1];
            int tComCode;
            if (int.TryParse(tComCodeStr, out tComCode))
            {
                switch (tComCode)
                {
                        #region 4

                    case 4: //
                        aServer.Connected = true;
                        aServer.Commit();
                        break;

                        #endregion

                        #region RPL_WHOISCHANNELS

                    case 319: // RPL_WHOISCHANNELS
                        tBot = aServer.Bot(aCommands[3]);
                        if (tBot != null)
                        {
                            string chanName = "";
                            bool addChan = true;
                            string[] tChannelList = aRawData.Split(':')[2].Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
                            foreach (string chan in tChannelList)
                            {
                                chanName = "#" + chan.Split('#')[1];
                                if (aServer.Channel(chanName) != null)
                                {
                                    addChan = false;
                                    FireRequestFromBot(aServer, tBot);
                                    break;
                                }
                            }
                            if (addChan)
                            {
                                log.Info("Parse() auto adding channel " + chanName);
                                aServer.AddChannel(chanName);
                            }
                        }
                        break;

                        #endregion

                        #region RPL_NAMREPLY

                    case 353: // RPL_NAMREPLY
                        tChan = aServer.Channel(aCommands[4]);
                        if (tChan != null)
                        {
                            string[] tUsers = aMessage.Split(' ');
                            foreach (string user in tUsers)
                            {
                                string tUser = Regex.Replace(user, "^(@|!|%|\\+){1}", "");
                                tBot = tChan.Bot(tUser);
                                if (tBot != null)
                                {
                                    tBot.Connected = true;
                                    tBot.LastMessage = "joined channel " + tChan.Name;
                                    if (tBot.State != Bot.States.Active)
                                    {
                                        tBot.State = Bot.States.Idle;
                                    }
                                    log.Info("Parse() " + tBot + " is online");
                                    tBot.Commit();
                                    FireRequestFromBot(aServer, tBot);
                                }
                            }
                        }
                        break;

                        #endregion

                        #region RPL_ENDOFNAMES

                    case 366: // RPL_ENDOFNAMES
                        tChan = aServer.Channel(aCommands[3]);
                        if (tChan != null)
                        {
                            tChan.ErrorCode = 0;
                            tChan.Connected = true;
                            log.Info("Parse() joined " + tChan);
                        }

                        // statistics
                        Statistic.Instance.Increase(StatisticType.ChannelConnectsOk);
                        break;

                        #endregion

                        #region RPL_ENDOFMOTD | ERR_NOMOTD

                    case 376: // RPL_ENDOFMOTD
//.........这里部分代码省略.........
开发者ID:sstraus,项目名称:xdcc-grabscher,代码行数:101,代码来源:IntValue.cs


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