예제 #1
0
파일: Ctcp.cs 프로젝트: Rafa652/IRCQueueBot
 internal CtcpEvent(User sender, Entity target, CtcpType type, string message)
 {
     _sender = sender;
     _target = target;
     _ctype = type;
     _message = message;
 }
예제 #2
0
파일: Ctcp.cs 프로젝트: Rafa652/GameChannel
 internal CtcpEvent(bool outgoing, User sender, Entity target, CtcpType type, string message)
     : base(outgoing)
 {
     _sender = sender;
     _target = target;
     _ctype = type;
     _message = message;
 }
예제 #3
0
파일: Ctcp.cs 프로젝트: Rafa652/GameChannel
 internal ChannelCtcpEvent(bool outgoing, User sender, Channel target, CtcpType type, string message)
     : base(outgoing, sender, target, type, message)
 {
 }
예제 #4
0
파일: Ctcp.cs 프로젝트: Rafa652/IRCQueueBot
 internal ChannelCtcpEvent(User sender, Channel target, CtcpType type, string message)
     : base(sender, target, type, message)
 {
 }
예제 #5
0
        /// <summary>
        /// Sends a CTCP message of any type to the given target.
        /// </summary>
        /// <param name="target">Who/where to send the CTCP message.</param>
        /// <param name="message">The message to send.</param>
        /// <param name="type">The type of CTCP message.</param>
        /// <exception cref="ArgumentException">Thrown if attempting to send a response to a channel.</exception>
        /// <remarks>Most clients will expect the first word in the message to be in all caps.</remarks>
        public void SendCtcp(string target, string message, CtcpType type)
        {
            Entity etarget;
            if (Channel.IsValidChannelName(target)) etarget = GetChannel(target);
            else etarget = GetUser(target);

            if (etarget is Channel) {
                if (type == CtcpType.Response) throw new ArgumentException("Cannot send CTCP response to channel.");
                Enqueue(new ChannelCtcpEvent(true, GetClient(), (Channel)etarget, type, message));
            } else {
                Enqueue(new CtcpEvent(true, GetClient(), etarget, type, message));
            }
        }
예제 #6
0
        /// <summary>
        /// Sends a CTCP message of any type to the given target.
        /// </summary>
        /// <param name="target">Who/where to send the CTCP message.</param>
        /// <param name="message">The message to send.</param>
        /// <param name="type">The type of CTCP message.</param>
        /// <exception cref="ArgumentException">Thrown if attempting to send a response to a channel.</exception>
        /// <remarks>Most clients will expect the first word in the message to be in all caps.</remarks>
        public void SendCtcp(string target, string message, CtcpType type) {
            bool isChannel = Channel.IsValidChannelName(target);
            IrcEvent oev;
            lock (Cs.Irc.Entities) {
                var self = (User)Cs.Irc.Entities.Self;
                if (isChannel) {
                    oev = new ChannelCtcpEvent(self, (Channel)Cs.Irc.Entities.GetChannel(target), type, message);
                } else {
                    oev = new CtcpEvent(self, (User)Cs.Irc.Entities.GetUser(target), type, message);
                }
            }

            Q.Enqueue(
                new OutputEvent(
                    String.Format("{0} {1} :\u0001{2}\u0001",
                    type == CtcpType.Request ? "PRIVMSG" : "NOTICE", target, message), true));
            Q.Enqueue(oev);
        }