Beispiel #1
0
 /// <summary>
 /// Invokes the Parsers.
 /// </summary>
 /// <param name="s">The server object.</param>
 /// <param name="c">The channel triggered on.</param>
 /// <param name="u">The user triggered from.</param>
 /// <param name="cu">The channeluser triggered from.</param>
 /// <param name="text">The offending text.</param>
 /// <param name="pt">The Parse Types to invoke on.</param>
 private static void InvokeParsers(Server s, Channel c, User u, ChannelUser cu, string text, IRCEvents.ParseTypes pt)
 {
     bool pcount = s.EventObject.Parses.Count > 0;
     bool wcount = s.EventObject.WildcardParses.Count > 0;
     if ( pcount || wcount ) {
         IRCEvents.ParseReturns pr = CreateParseReturns( s.ServerID, c, u, cu, text );
         if ( pcount )
             s.QueueData( ParseInvocation( pr.Text, s.EventObject, pr, pt, false ) );
         if ( wcount )
             s.QueueData( ParseInvocation( pr.Text, s.EventObject, pr, pt, true ) );
     }
 }
Beispiel #2
0
        /// <summary>
        /// Retrieves a ChannelUser from the database.
        /// </summary>
        /// <param name="s">The server to check for the ChannelUser.</param>
        /// <param name="channelname">The channel to check.</param>
        /// <param name="usernick">The nick of a definetely existing user.</param>
        /// <param name="uflag">If the channel user does not exist he must be created with a userflag. This is that flag.</param>
        /// <returns>The new or old ChannelUser.</returns>
        private static ChannelUser UpdateBothDB(Server s, string channelname, string usernick, Nullable<char> uflag)
        {
            ChannelUser cu;
            try {
                cu = s.ChannelDatabase[channelname][usernick]; //Check if ChannelUser exists.
            }
            catch ( KeyNotFoundException ) {
                //ChannelUser does not exist.
                cu = new ChannelUser();

                User internalu;
                try {
                    internalu = s.UserDatabase[usernick];
                }
                catch ( KeyNotFoundException ) {
                    cu.UserFlag = uflag;
                    s.ChannelDatabase[channelname].AddUser( usernick, cu );
                    return cu;
                }

                cu.InternalUser = internalu;
                cu.UserFlag = uflag;
                s.ChannelDatabase[channelname].AddUser( cu );
                return cu;
            }

            //Make certain that if the usernick exists in the database that we attach it to it's user counterpart.
            if ( cu.InternalUser == null ) {
                User internalu;
                try {
                    internalu = s.UserDatabase[usernick];
                    cu.InternalUser = internalu;
                }
                catch ( KeyNotFoundException ) {
                    //throw new ExecutionEngineException( "PLACEHOLDER FOR DESTRUCTION THIS SHOULD NEVER HAPPEN" );
                }
            }

            return cu;
        }
Beispiel #3
0
 /// <summary>
 /// Fires the OnPart event.
 /// </summary>
 /// <param name="sid">The server id.</param>
 /// <param name="cu">The channel user that parted.</param>
 /// <param name="c">The channel parted.</param>
 /// <param name="message">The message sent to the server.</param>
 /// <returns>The raw data to be sent to the server.</returns>
 public string[] OnPart(int sid, ChannelUser cu, Channel c, string message)
 {
     if ( Part == null )
         return null;
     JoinPartEvent je = new JoinPartEvent();
     je.sid = sid;
     je.channel = c;
     je.user = cu;
     je.message = message;
     return InvocationTunnel( Part.GetInvocationList(), je, "onPartData",
         ( cu.InternalUser.UserAttributes == null ) ? null : cu.InternalUser.UserAttributes.Privegeles );
 }
Beispiel #4
0
 /// <summary>
 /// Creates a parse returns struct.
 /// </summary>
 /// <param name="serverId">The server id.</param>
 /// <param name="c">The channel triggered on.</param>
 /// <param name="u">The user triggered from.</param>
 /// <param name="cu">The channeluser triggered from.</param>
 /// <param name="text">The offending text.</param>
 /// <returns>A new parse returns struct.</returns>
 private static IRCEvents.ParseReturns CreateParseReturns(int serverId, Channel c, User u, ChannelUser cu, string text)
 {
     IRCEvents.ParseReturns pr = new IRCEvents.ParseReturns();
     pr.Channel = c;
     pr.User = u;
     pr.ChannelUser = cu;
     pr.ServerID = serverId;
     pr.Text = text;
     return pr;
 }
Beispiel #5
0
 /// <summary>
 /// Fires the OnJoin event.
 /// </summary>
 /// <param name="sid">The server on which the user has joined a channel.</param>
 /// <param name="channel">The channel which the user has joined.</param>
 /// <param name="cu">The user which joined the channel.</param>
 /// <returns>The raw data to be sent to the server.</returns>
 public string[] OnJoin(int sid, Channel c, ChannelUser cu)
 {
     if ( Join == null )
         return null;
     JoinPartEvent je = new JoinPartEvent();
     je.sid = sid;
     je.channel = c;
     je.user = cu;
     return InvocationTunnel( Join.GetInvocationList(), je, "onJoinData",
         ( cu.InternalUser.UserAttributes == null ) ? null : cu.InternalUser.UserAttributes.Privegeles );
 }
Beispiel #6
0
 /// <summary>
 /// Fires the ChannelMessage event.
 /// </summary>
 /// <param name="sid">Server id.</param>
 /// <param name="channel">The channel the message was sent to.</param>
 /// <param name="channeluser">The userhost of the user who sent it.</param>
 /// <param name="text">The text contained in the message.</param>
 /// <returns>Raw data.</returns>
 public string[] OnChannelMessage(int sid, Channel channel, ChannelUser userhost, string text)
 {
     if (ChannelMessage == null)
         return null;
     ChannelMessageEvent me = new ChannelMessageEvent();
     me.sid = sid;
     me.channelUser = userhost;
     me.channel = channel;
     me.text = text;
     return InvocationTunnel(ChannelMessage.GetInvocationList(), me, "channelMessageData",
         ( userhost.InternalUser.UserAttributes == null ) ? null : userhost.InternalUser.UserAttributes.Privegeles );
 }
Beispiel #7
0
 /// <summary>
 /// Fires the Part event.
 /// </summary>
 /// <param name="sid">The server on which the part happened.</param>
 /// <param name="cu">The ChannelUser that parted.</param>
 /// <param name="message">The quit message.</param>
 /// <returns>The raw data to be sent to the server.</returns>
 public string[][] OnPart(int sid, ChannelUser u, Channel c, string message)
 {
     if ( Part != null )
         return InvocationTunnel( this.Part.GetInvocationList(),
             u.InternalUser.UserAttributes == null ?
             null : u.InternalUser.UserAttributes.Privegeles, sid, u, c, message );
     return null;
 }
Beispiel #8
0
 /// <summary>
 /// Fires the OnJoin event.
 /// </summary>
 /// <param name="sid">The server on which the user has joined a channel.</param>
 /// <param name="channel">The channel which the user has joined.</param>
 /// <param name="cu">The user which joined the channel.</param>
 /// <returns>The raw data to be sent to the server.</returns>
 public string[][] OnJoin(int sid, Channel channel, ChannelUser cu)
 {
     if ( Join != null )
         return InvocationTunnel( this.Join.GetInvocationList(),
             cu.InternalUser.UserAttributes == null ?
             null : cu.InternalUser.UserAttributes.Privegeles, sid, channel, cu );
     return null;
 }
Beispiel #9
0
 /// <summary>
 /// Fire the ChannelMessage event.
 /// </summary>
 /// <param name="sid">Server ID</param>
 /// <param name="channel">The channel which the message was destined for.</param>
 /// <param name="userhost">The userhost of the sender.</param>
 /// <param name="text">The contents of the message.</param>
 /// <returns>The raw data to be sent to the server.</returns>
 public string[][] OnChannelMessage(int sid, Channel channel, ChannelUser user, string text)
 {
     if ( ChannelMessage != null )
         return InvocationTunnel(this.ChannelMessage.GetInvocationList(),
             user.InternalUser.UserAttributes == null ?
             null : user.InternalUser.UserAttributes.Privegeles, sid, channel, user, text );
     return null;
 }