Ejemplo n.º 1
0
 internal void ActionNotify(IrcUser user, StringStream text)
 {
     if (ActionReceived != null)
     {
         ActionReceived(user, text);
     }
 }
Ejemplo n.º 2
0
 internal void TextNotify(IrcUser user, StringStream text)
 {
     if (TextReceived != null)
     {
         TextReceived(user, text);
     }
 }
Ejemplo n.º 3
0
 internal void NoticeReceivedNotify(IrcUser user, StringStream text)
 {
     if (NoticeReceived != null)
     {
         NoticeReceived(user, text);
     }
 }
Ejemplo n.º 4
0
 internal void MsgReceivedNotify(IrcUser user, StringStream text)
 {
     if (MsgReceived != null)
     {
         MsgReceived(user, text);
     }
 }
Ejemplo n.º 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());
        }
Ejemplo n.º 6
0
 internal void ActionNotify(IrcUser user, IrcChannel channel, StringStream text)
 {
     if (channel != null)
     {
         channel.ActionNotify(user, text);
     }
     OnAction(user, channel, text);
 }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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;
     }));
 }
Ejemplo n.º 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)));
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 11
0
 public NoticeCmdTrigger(StringStream args, IrcUser user, IrcChannel chan = null)
     : base(args, user, chan)
 {
 }
Ejemplo n.º 12
0
 public ExecuteCmdTrigger(StringStream args, IrcUser user, IrcChannel chan)
     : base(args, user, chan)
 {
 }
Ejemplo n.º 13
0
 internal void ChannelMsgNotify(IrcUser user, IrcChannel chan, StringStream text)
 {
     chan.MsgReceivedNotify(user, text);
     OnChannelMsg(user, chan, text);
 }
Ejemplo n.º 14
0
 internal void ChannelMsgNotify(IrcUser user, IrcChannel chan, StringStream text)
 {
     chan.MsgReceivedNotify(user, text);
     OnChannelMsg(user, chan, text);
 }
Ejemplo n.º 15
0
 internal void QueryMsgNotify(IrcUser user, StringStream text)
 {
     OnQueryMsg(user, text);
 }
Ejemplo n.º 16
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();
        }
Ejemplo n.º 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)
        {
        }
Ejemplo n.º 18
0
 internal void ActionNotify(IrcUser user, StringStream text)
 {
     if (ActionReceived != null)
         ActionReceived(user, text);
 }
Ejemplo n.º 19
0
 internal void MsgReceivedNotify(IrcUser user, StringStream text)
 {
     if (MsgReceived != null)
         MsgReceived(user, text);
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 21
0
 public ExecuteCmdTrigger(StringStream args, IrcUser user, IrcChannel chan)
     : base(args, user, chan)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)));
            }
        }
Ejemplo n.º 24
0
 internal void QueryMsgNotify(IrcUser user, StringStream text)
 {
     OnQueryMsg(user, text);
 }
Ejemplo n.º 25
0
 public DccChatCmdTrigger(StringStream args, IrcUser user)
     : base(args, user, null)
 {
 }
Ejemplo n.º 26
0
 public NoticeCmdTrigger(StringStream args, IrcUser user, IrcChannel chan = null)
     : base(args, user, chan)
 {
 }
Ejemplo n.º 27
0
 internal void NoticeNotify(IrcUser user, IrcChannel channel, StringStream text)
 {
     OnNotice(user, channel, text);
 }
Ejemplo n.º 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;
                                                             });
 }
Ejemplo n.º 29
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;
        }
Ejemplo n.º 30
0
 internal void TextNotify(IrcUser user, StringStream text)
 {
     if (TextReceived != null)
         TextReceived(user, text);
 }
Ejemplo n.º 31
0
 public WCellCmdTrigger(WCellUser user, IrcChannel channel, WCellStr text, RealmServerCmdArgs args)
     : base(text, args)
 {
     Channel = channel;
     User    = user.IrcUser;
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Fires when the Client receives a PRIVMSG, directed to this Client itself.
 /// </summary>
 protected virtual void OnQueryMsg(IrcUser user, StringStream text)
 {
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Fires when the Client receives a PRIVMSG, directed to this Client itself.
 /// </summary>
 protected virtual void OnQueryMsg(IrcUser user, StringStream text)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 36
0
 public DccChatCmdTrigger(StringStream args, IrcUser user)
     : base(args, user, null)
 {
 }
Ejemplo n.º 37
0
 internal void NoticeNotify(IrcUser user, IrcChannel channel, StringStream text)
 {
     OnNotice(user, channel, text);
 }
Ejemplo n.º 38
0
 internal void ActionNotify(IrcUser user, IrcChannel channel, StringStream text)
 {
     if (channel != null)
         channel.ActionNotify(user, text);
     OnAction(user, channel, text);
 }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 40
0
 internal void NoticeReceivedNotify(IrcUser user, StringStream text)
 {
     if (NoticeReceived != null)
         NoticeReceived(user, text);
 }