Exemple #1
0
 internal void ActionNotify(IrcUser user, StringStream text)
 {
     if (ActionReceived != null)
     {
         ActionReceived(user, text);
     }
 }
Exemple #2
0
 internal void TextNotify(IrcUser user, StringStream text)
 {
     if (TextReceived != null)
     {
         TextReceived(user, text);
     }
 }
Exemple #3
0
 internal void NoticeReceivedNotify(IrcUser user, StringStream text)
 {
     if (NoticeReceived != null)
     {
         NoticeReceived(user, text);
     }
 }
Exemple #4
0
 internal void MsgReceivedNotify(IrcUser user, StringStream text)
 {
     if (MsgReceived != null)
     {
         MsgReceived(user, text);
     }
 }
Exemple #5
0
        /// <summary>
        /// Convert bytes into IrcPackets
        /// </summary>
        public IrcPacket[] ExtractPackets(ByteBuffer partialResponse)
        {
            var str      = partialResponse.GetString(encoding);
            var response = lastResponsePart + str;
            var ss       = new StringStream(response);
            var packets  = new List <IrcPacket>(3);

            while (ss.HasNext)
            {
                var content = ss.NextWord(PacketTerminator);
                if (!ss.HasNext && !response.EndsWith(PacketTerminator))
                {
                    lastResponsePart = content;
                }
                else
                {
                    try
                    {
                        var packet = CreatePacket(content);
                        packets.Add(packet);
                        if (!ss.HasNext)
                        {
                            lastResponsePart = "";
                        }
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Unable to parse packet: " + content, e);
                    }
                }
            }
            return(packets.ToArray());
        }
Exemple #6
0
 internal void ActionNotify(IrcUser user, IrcChannel channel, StringStream text)
 {
     if (channel != null)
     {
         channel.ActionNotify(user, text);
     }
     OnAction(user, channel, text);
 }
Exemple #7
0
        internal void ChatMessageReceivedNotify(DccChatClient client, StringStream text)
        {
            if (ChatMessageReceived != null)
            {
                ChatMessageReceived(client, text);
            }

            if (m_irc.TriggersCommand(client.User, null, text))
            {
                m_irc.CommandHandler.Execute(new DccChatCmdTrigger(text, client.User));
            }
        }
Exemple #8
0
 public virtual bool TriggersCommand(IrcUser user, IrcChannel chan, StringStream input)
 {
     return(CommandHandler.RemoteCommandPrefixes.Iterate(prefix =>
     {
         if (input.String.StartsWith(prefix, StringComparison.CurrentCultureIgnoreCase))
         {
             input.Skip(prefix.Length);
             return false;
         }
         return true;
     }));
 }
Exemple #9
0
 internal void NoticeNotify(IrcUser user, IrcChannel chan, StringStream text)
 {
     if (chan != null)
     {
         chan.NoticeReceivedNotify(user, text);
     }
     OnNotice(user, chan, text);
     if (TriggersCommand(user, chan, text))
     {
         Task.Factory.StartNew(() => m_CommandHandler.Execute(new NoticeCmdTrigger(text, user, chan)));
     }
 }
Exemple #10
0
        /// <summary>
        /// Build a packet from a new line of content from the server.
        /// Do as much parsing as possible here before the packet-handler
        /// will then work with the gathered information.
        /// </summary>
        public IrcPacket CreatePacket(string content)
        {
            var line = new StringStream(content.Trim());

            string prefix;

            if (content[0] == ':')
            {
                prefix = line.NextWord().Substring(1);
            }
            else
            {
                prefix = line.NextWord();
            }

            var action = line.NextWord();
            var packet = new IrcPacket(irc, prefix, action, new StringStream(line.Remainder.Trim()), line.String)
            {
                protHandler = this
            };

            return(packet);
        }
 public NoticeCmdTrigger(StringStream args, IrcUser user, IrcChannel chan = null)
     : base(args, user, chan)
 {
 }
Exemple #12
0
 public ExecuteCmdTrigger(StringStream args, IrcUser user, IrcChannel chan)
     : base(args, user, chan)
 {
 }
Exemple #13
0
 internal void ChannelMsgNotify(IrcUser user, IrcChannel chan, StringStream text)
 {
     chan.MsgReceivedNotify(user, text);
     OnChannelMsg(user, chan, text);
 }
Exemple #14
0
 internal void ChannelMsgNotify(IrcUser user, IrcChannel chan, StringStream text)
 {
     chan.MsgReceivedNotify(user, text);
     OnChannelMsg(user, chan, text);
 }
Exemple #15
0
 internal void QueryMsgNotify(IrcUser user, StringStream text)
 {
     OnQueryMsg(user, text);
 }
        /// <summary>
        /// Convert bytes into IrcPackets
        /// </summary>
        public IrcPacket[] ExtractPackets(ByteBuffer partialResponse)
        {
            var str = partialResponse.GetString(encoding);
            var response = lastResponsePart + str;
            var ss = new StringStream(response);
            var packets = new List<IrcPacket>(3);

            while (ss.HasNext)
            {
                var content = ss.NextWord(PacketTerminator);
                if (!ss.HasNext && !response.EndsWith(PacketTerminator))
                {
                    lastResponsePart = content;
                }
                else
                {
                    try
                    {
                        var packet = CreatePacket(content);
                        packets.Add(packet);
                        if (!ss.HasNext)
                        {
                            lastResponsePart = "";
                        }
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Unable to parse packet: " + content, e);
                    }
                }
            }
            return packets.ToArray();
        }
Exemple #17
0
        /// <summary>
        /// Fires when the Client recieves any CTCP ACTION aka /me.
        /// </summary>
        /// <param name="user">The User who sent the text</param>
        /// <param name="channel">The Channel where it was sent (can be null if sent to a User)</param>
        /// <param name="text">The text which was sent</param>

        protected virtual void OnAction(IrcUser user, IrcChannel channel, StringStream text)
        {
        }
Exemple #18
0
 internal void ActionNotify(IrcUser user, StringStream text)
 {
     if (ActionReceived != null)
         ActionReceived(user, text);
 }
Exemple #19
0
 internal void MsgReceivedNotify(IrcUser user, StringStream text)
 {
     if (MsgReceived != null)
         MsgReceived(user, text);
 }
Exemple #20
0
 /// <summary>
 /// Fires when the Client receives a PRIVMSG which was directed to a Channel.
 /// </summary>
 protected virtual void OnChannelMsg(IrcUser user, IrcChannel chan, StringStream text)
 {
 }
 public ExecuteCmdTrigger(StringStream args, IrcUser user, IrcChannel chan)
     : base(args, user, chan)
 {
 }
Exemple #22
0
 /// <summary>
 /// Fires when the Client recieves any CTCP ACTION aka /me.
 /// </summary>
 /// <param name="user">The User who sent the text</param>
 /// <param name="channel">The Channel where it was sent (can be null if sent to a User)</param>
 /// <param name="text">The text which was sent</param>
 protected virtual void OnAction(IrcUser user, IrcChannel channel, StringStream text)
 {
 }
Exemple #23
0
        internal void TextNotify(IrcUser user, IrcChannel chan, StringStream text)
        {
            if (chan != null)
                chan.TextNotify(user, text);
            OnText(user, chan, text);

            if (TriggersCommand(user, chan, text))
            {
                Task.Factory.StartNew(()=>m_CommandHandler.Execute(new MsgCmdTrigger(text, user, chan)));
            }
        }
Exemple #24
0
 internal void QueryMsgNotify(IrcUser user, StringStream text)
 {
     OnQueryMsg(user, text);
 }
 public DccChatCmdTrigger(StringStream args, IrcUser user)
     : base(args, user, null)
 {
 }
 public NoticeCmdTrigger(StringStream args, IrcUser user, IrcChannel chan = null)
     : base(args, user, chan)
 {
 }
Exemple #27
0
 internal void NoticeNotify(IrcUser user, IrcChannel channel, StringStream text)
 {
     OnNotice(user, channel, text);
 }
Exemple #28
0
 public virtual bool TriggersCommand(IrcUser user, IrcChannel chan, StringStream input)
 {
     return CommandHandler.RemoteCommandPrefixes.Iterate(prefix =>
                                                             {
                                                                 if (input.String.StartsWith(prefix, StringComparison.CurrentCultureIgnoreCase))
                                                                 {
                                                                     input.Skip(prefix.Length);
                                                                     return false;
                                                                 } return true;
                                                             });
 }
        /// <summary>
        /// Build a packet from a new line of content from the server.
        /// Do as much parsing as possible here before the packet-handler
        /// will then work with the gathered information.
        /// </summary>
        public IrcPacket CreatePacket(string content)
        {
            var line = new StringStream(content.Trim());

            string prefix;
            if (content[0] == ':')
            {
                prefix = line.NextWord().Substring(1);
            }
            else
            {
                prefix = line.NextWord();
            }

            var action = line.NextWord();
            var packet = new IrcPacket(irc, prefix, action, new StringStream(line.Remainder.Trim()), line.String)
            {
                protHandler = this
            };

            return packet;
        }
Exemple #30
0
 internal void TextNotify(IrcUser user, StringStream text)
 {
     if (TextReceived != null)
         TextReceived(user, text);
 }
 public WCellCmdTrigger(WCellUser user, IrcChannel channel, WCellStr text, RealmServerCmdArgs args)
     : base(text, args)
 {
     Channel = channel;
     User    = user.IrcUser;
 }
Exemple #32
0
 /// <summary>
 /// Fires when the Client receives any kind of NOTICE.
 /// </summary>
 /// <param name="user">The User who sent the text</param>
 /// <param name="channel">The Channel where it was sent (can be null)</param>
 /// <param name="text">The text which was sent</param>
 protected virtual void OnNotice(IrcUser user, IrcChannel channel, StringStream text)
 {
 }
Exemple #33
0
 /// <summary>
 /// Fires when the Client receives a PRIVMSG, directed to this Client itself.
 /// </summary>
 protected virtual void OnQueryMsg(IrcUser user, StringStream text)
 {
 }
Exemple #34
0
 /// <summary>
 /// Fires when the Client receives a PRIVMSG, directed to this Client itself.
 /// </summary>
 protected virtual void OnQueryMsg(IrcUser user, StringStream text)
 {
 }
Exemple #35
0
 /// <summary>
 /// Fires when the Client receives any kind of NOTICE.
 /// </summary>
 /// <param name="user">The User who sent the text</param>
 /// <param name="chan">The Channel where it was sent (is null if its a private notice)</param>
 /// <param name="text">The text which was sent</param>
 protected virtual void OnNotice(IrcUser user, IrcChannel chan, StringStream text)
 {
 }
 public DccChatCmdTrigger(StringStream args, IrcUser user)
     : base(args, user, null)
 {
 }
Exemple #37
0
 internal void NoticeNotify(IrcUser user, IrcChannel channel, StringStream text)
 {
     OnNotice(user, channel, text);
 }
Exemple #38
0
 internal void ActionNotify(IrcUser user, IrcChannel channel, StringStream text)
 {
     if (channel != null)
         channel.ActionNotify(user, text);
     OnAction(user, channel, text);
 }
Exemple #39
0
        internal void ChatMessageReceivedNotify(DccChatClient client, StringStream text)
        {
            if (ChatMessageReceived != null)
                ChatMessageReceived(client, text);

            if (m_irc.TriggersCommand(client.User, null, text))
            {
                m_irc.CommandHandler.Execute(new DccChatCmdTrigger(text, client.User));
            }
        }
Exemple #40
0
 internal void NoticeReceivedNotify(IrcUser user, StringStream text)
 {
     if (NoticeReceived != null)
         NoticeReceived(user, text);
 }