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


C# IrcClient.MessageParser方法代码示例

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


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

示例1: MessageParser

        public void MessageParser()
        {
            var client = new IrcClient();

            var rawline = ":irc.example.com 001 meebey3 :Welcome to the EFnet Internet Relay Chat Network meebey3";
            var msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.Welcome, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual("Welcome to the EFnet Internet Relay Chat Network meebey3", msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":irc.example.com 002 meebey3 :Your host is irc.example.com[127.0.0.1/6667], running version hybrid-7.2.2+oftc1.6.9";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.YourHost, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual("Your host is irc.example.com[127.0.0.1/6667], running version hybrid-7.2.2+oftc1.6.9", msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":irc.example.com 003 meebey3 :This server was created Aug  7 2011 at 12:43:41";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.Created, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual("This server was created Aug  7 2011 at 12:43:41", msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":irc.example.com 004 meebey3 irc.example.com hybrid-7.2.2+oftc1.6.9 CDGPRSabcdfgiklnorsuwxyz biklmnopstveI bkloveI";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.MyInfo, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual(null, msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":irc.example.com 005 meebey3 CALLERID CASEMAPPING=rfc1459 DEAF=D KICKLEN=160 MODES=4 NICKLEN=30 PREFIX=(ov)@+ [email protected]+ TOPICLEN=390 NETWORK=EFnet MAXLIST=beI:25 MAXTARGETS=4 CHANTYPES=#& :are supported by this server";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.Bounce, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual("are supported by this server", msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":irc.example.com 005 meebey3 CHANLIMIT=#&:25 CHANNELLEN=50 CHANMODES=eIb,k,l,imnpstMRS KNOCK ELIST=CMNTU SAFELIST AWAYLEN=160 EXCEPTS=e INVEX=I :are supported by this server";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("irc.example.com", msg.From);
            Assert.AreEqual(null, msg.Nick);
            Assert.AreEqual(null, msg.Ident);
            Assert.AreEqual(null, msg.Host);
            Assert.AreEqual(ReplyCode.Bounce, msg.ReplyCode);
            Assert.AreEqual(ReceiveType.Login, msg.Type);
            Assert.AreEqual("are supported by this server", msg.Message);
            Assert.AreEqual(null, msg.Channel);
            Assert.IsNotNull(msg.Tags);
            Assert.AreEqual(0, msg.Tags.Count);

            rawline = ":[email protected] JOIN :#debian.de";
            msg = client.MessageParser(rawline);
            Assert.AreSame(client, msg.Irc);
            Assert.AreEqual(rawline, msg.RawMessage);
            Assert.AreEqual("[email protected]", msg.From);
            Assert.AreEqual("i_ron", msg.Nick);
//.........这里部分代码省略.........
开发者ID:gmt2001,项目名称:SmartIrc4net,代码行数:101,代码来源:IrcClientTests.cs


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