Example #1
0
 public void OnPrivate(UserInfo info, string message)
 {
     if (message.ToLower() == "hi")
     {
         connection.Sender.PrivateMessage(info.Nick, "Nobody loves you");
     }
 }
Example #2
0
        public void OnPublic(UserInfo user, string channel, string message)
        {
            Calls c = new Calls();
            string txt = c.CallPublic(user.Nick.ToString(), message, channel, connection);
            textviewLog.Buffer.Text = txt.ToString();

            //connection.Sender.PublicMessage(channel, user + " " + "Cuando digas mi nombre lavate la boca ingenuo mortal");
        }
Example #3
0
        protected override void HandlePublicMessage(UserInfo user, string message)
        {
            var strategies = GetStrategiesThatCanRespond(message, user.Nick, _settings.PublicScriptFolder);

            if (strategies.Count > 0)
            {
                var selectedStrategy = GetPrioritizedStrategy(strategies);
                Console.WriteLine("Found strategy, responding: {0}", selectedStrategy.Response);
                Say(selectedStrategy.Response);
            }
        }
 public void OnJoin(UserInfo user, string channel)
 {
     if(user.Nick == Credentials.Nick)
     {
     }
     else
     {
         Console.WriteLine(user.Nick + " connected.");
         connection.Sender.PublicMessage(Credentials.Channel, "Welcome " + user.Nick + "!");
     }
 }
Example #5
0
 private void HandleMessage(string messageType, Action<UserInfo, string> handler, UserInfo user, string message)
 {
     Console.WriteLine("{0} msg from {1} > {2}", messageType, user.Nick, message);
     try
     {
         handler.Invoke(user, message);
     }
     catch (Exception ex)
     {
         Console.WriteLine("*** ERROR when handling {0} message:", messageType);
         Console.WriteLine(ex);
     }
 }
Example #6
0
        void Listener_OnPublic(UserInfo user, string channel, string message)
        {
            //string allowedchars = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./!@#$%^*()_+QWERTYUIOPASDFGHJKL:\"ZXCVBNM<>? ";
            //string msg = message;
            RemoveVariables(ref message);
            RemoveWhitespace(ref message);

            if (message.Contains("^UGCS"))
            {
                Server.UpdateGlobalSettings();
                return;
            }
            if (message.Contains("^IPGET "))
            {
                foreach (Player p in Player.players)
                {
                    if (p.name == message.Split(' ')[1])
                    {
                        if (Server.UseGlobalChat && IsConnected())
                        {
                            if (Player.IsLocalIpAddress(p.ip))
                            {
                                connection.Sender.PublicMessage(channel, "^IP " + p.name + ": " + Server.IP);
                                connection.Sender.PublicMessage(channel, "^PLAYER IS CONNECTING THROUGH A LOCAL IP.");
                            }
                            else { connection.Sender.PublicMessage(channel, "^IP " + p.name + ": " + p.ip); }
                        }
                    }
                }
            }
            if (message.Contains("^SENDRULES "))
            {
                Player who = Player.Find(message.Split(' ')[1]);
                if (who != null)
                {
                    Command.all.Find("gcrules").Use(who, "");
                }
            }
            if (message.Contains("^GETINFO "))
            {
                if (Server.GlobalChatNick == message.Split(' ')[1])
                {
                    if (Server.UseGlobalChat && IsConnected())
                    {
                        connection.Sender.PublicMessage(channel, "^NAME: " + Server.name);
                        connection.Sender.PublicMessage(channel, "^MOTD: " + Server.motd);
                        connection.Sender.PublicMessage(channel, "^VERSION: " + Server.VersionString);
                        connection.Sender.PublicMessage(channel, "^GLOBAL NAME: " + Server.GlobalChatNick);
                        connection.Sender.PublicMessage(channel, "^URL: " + Server.URL);
                        connection.Sender.PublicMessage(channel, "^PLAYERS: " + Player.players.Count + "/" + Server.players);
                    }
                }
            }

            //for RoboDash's anti advertise/swear in #globalchat
            if (message.Contains("^ISASERVER "))
            {
                if (Server.GlobalChatNick == message.Split(' ')[1])
                {
                    connection.Sender.PublicMessage(channel, "^IMASERVER");
                }
            }

            if (message.StartsWith("^"))
                return;

            message = message.MCCharFilter();

            if (String.IsNullOrEmpty(message))
                return;

            if (OnNewRecieveGlobalMessage != null)
                OnNewRecieveGlobalMessage(user.Nick, message);

            if (Server.Devs.Contains(message.Split(':')[0].ToLower()) && !message.StartsWith("[Dev]") && !message.StartsWith("[Developer]"))
                message = "[Dev]" + message;
            else if(Server.Mods.Contains(message.Split(':')[0].ToLower()) && !message.StartsWith("[Mod]") && !message.StartsWith("[Moderator]"))
                message = "[Mod]" + message;
            else if (Server.Mods.Contains(message.Split(':')[0].ToLower()) && !message.StartsWith("[GCMod]"))
                message = "[GCMod]" + message;

            /*try {
                if(GUI.GuiEvent != null)
                GUI.GuiEvents.GlobalChatEvent(this, "> " + user.Nick + ": " + message); }
            catch { Server.s.Log(">[Global] " + user.Nick + ": " + message); }*/
            Player.GlobalMessage(String.Format("{0}>[Global] {1}: &f{2}", Server.GlobalChatColor, user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message), true);
        }
 private void OnCtcpRequest( string command, UserInfo who )
 {
     if( DateTime.Now.ToFileTime() > nextTime )
     {
         switch( command )
         {
             case CtcpUtil.Finger:
                 connection.CtcpSender.CtcpReply( command, who.Nick, fingerMessage + " Idle time: " + FormatIdleTime() );
                 break;
             case CtcpUtil.Time:
                 connection.CtcpSender.CtcpReply( command, who.Nick, FormatDateTime() );
                 break;
             case CtcpUtil.UserInfo:
                 connection.CtcpSender.CtcpReply( command, who.Nick, userInfoMessage );
                 break;
             case CtcpUtil.Version:
                 connection.CtcpSender.CtcpReply( command, who.Nick, versionMessage );
                 break;
             case CtcpUtil.Source:
                 connection.CtcpSender.CtcpReply( command, who.Nick, sourceMessage );
                 break;
             case CtcpUtil.ClientInfo:
                 connection.CtcpSender.CtcpReply( command, who.Nick, clientInfoMessage );
                 break;
             default:
                 string error = command + " is not a supported Ctcp query.";
                 connection.CtcpSender.CtcpReply( command, who.Nick, error );
                 break;
         }
         UpdateTime();
     }
 }
Example #8
0
 void Listener_OnJoin(UserInfo user, string channel) {
     connection.Sender.Names(channel);
     doJoinLeaveMessage(user.Nick, "joined", channel);
 }
Example #9
0
 protected void Listener_OnPrivate(UserInfo user, string message)
 {
     HandleMessage("Private", HandlePrivateMessage, user, message);
 }
Example #10
0
 protected abstract void HandlePrivateMessage(UserInfo user, string message);
Example #11
0
 private void ParseReply( string[] tokens )
 {
     ReplyCode code = (ReplyCode) int.Parse( tokens[1], CultureInfo.InvariantCulture );
     tokens[3] = RemoveLeadingColon( tokens[3] );
     switch( code )
     {
         //Messages sent upon successful registration
         case ReplyCode.RPL_WELCOME:
         case ReplyCode.RPL_YOURESERVICE:
             if( OnRegistered != null )
             {
                 OnRegistered();
             }
             break;
         case ReplyCode.RPL_MOTDSTART:
         case ReplyCode.RPL_MOTD:
             if( OnMotd != null )
             {
                 OnMotd( CondenseStrings( tokens, 3), false );
             }
             break;
         case ReplyCode.RPL_ENDOFMOTD:
             if( OnMotd != null )
             {
                 OnMotd( CondenseStrings( tokens, 3), true );
             }
             break;
         case ReplyCode.RPL_ISON:
             if ( OnIson != null )
             {
                 OnIson( tokens[3] );
             }
             break;
         case ReplyCode.RPL_NAMREPLY:
             if ( OnNames != null )
             {
                 tokens[5] = RemoveLeadingColon( tokens[5] );
                 int numberOfUsers = tokens.Length - 5;
                 string[] users = new string[ numberOfUsers ];
                 Array.Copy( tokens, 5 , users, 0 , numberOfUsers);
                 OnNames( tokens[4],
                     users,
                     false );
             }
             break;
         case ReplyCode.RPL_ENDOFNAMES:
             if( OnNames != null )
             {
                 OnNames( tokens[3], new string[0], true );
             }
             break;
         case ReplyCode.RPL_LIST:
             if ( OnList != null )
             {
                 tokens[5] = RemoveLeadingColon( tokens[5] );
                 OnList(
                     tokens[3],
                     int.Parse( tokens[4] , CultureInfo.InvariantCulture),
                     CondenseStrings( tokens, 5),
                     false);
             }
             break;
         case ReplyCode.RPL_LISTEND:
             if( OnList != null )
             {
                 OnList( "",0,"", true );
             }
             break;
         case ReplyCode.ERR_NICKNAMEINUSE:
         case ReplyCode.ERR_NICKCOLLISION:
             if ( OnNickError != null )
             {
                 tokens[4] = RemoveLeadingColon( tokens[4] );
                 OnNickError( tokens[3], CondenseStrings( tokens, 4) );
             }
             break;
         case ReplyCode.RPL_NOTOPIC:
             if( OnError != null )
             {
                 OnError(code, CondenseStrings( tokens, 3) );
             }
             break;
         case ReplyCode.RPL_TOPIC:
             if( OnTopicRequest != null )
             {
                 tokens[4] = RemoveLeadingColon( tokens[4] );
                 OnTopicRequest(	tokens[3], CondenseStrings(tokens, 4 ) );
             }
             break;
         case ReplyCode.RPL_INVITING:
             if( OnInviteSent != null )
             {
                 OnInviteSent(tokens[3], tokens[4] );
             }
             break;
         case ReplyCode.RPL_AWAY:
             if( OnAway != null )
             {
                 OnAway(tokens[3], RemoveLeadingColon( CondenseStrings( tokens, 4) ) );
             }
             break;
         case ReplyCode.RPL_WHOREPLY:
             if( OnWho != null )
             {
                 UserInfo user = new UserInfo( tokens[7],tokens[4],tokens[5]);
                 OnWho(
                     user,
                     tokens[3],
                     tokens[6],
                     tokens[8],
                     int.Parse( RemoveLeadingColon( tokens[9] ), CultureInfo.InvariantCulture),
                     tokens[10],
                     false );
             }
             break;
         case ReplyCode.RPL_ENDOFWHO:
             if( OnWho != null )
             {
                 OnWho( UserInfo.Empty , "","","",0,"",true);
             }
             break;
         case ReplyCode.RPL_WHOISUSER:
             UserInfo whoUser = new UserInfo( tokens[3], tokens[4], tokens[5]);
             WhoisInfo whoisInfo = LookupInfo( whoUser.Nick );
             whoisInfo.userInfo = whoUser;
             tokens[7] = RemoveLeadingColon( tokens[7] );
             whoisInfo.realName = CondenseStrings( tokens, 7) ;
             break;
         case ReplyCode.RPL_WHOISCHANNELS:
             WhoisInfo whoisChannelInfo = LookupInfo( tokens[3] );
             tokens[4] = RemoveLeadingColon( tokens[4] );
             int numberOfChannels = tokens.Length - 4;
             string[] channels = new String[ numberOfChannels ];
             Array.Copy( tokens, 4, channels, 0 , numberOfChannels);
             whoisChannelInfo.SetChannels( channels );
             break;
         case ReplyCode.RPL_WHOISSERVER:
             WhoisInfo whoisServerInfo = LookupInfo( tokens[3] );
             whoisServerInfo.ircServer = tokens[4];
             tokens[5] = RemoveLeadingColon( tokens[5] );
             whoisServerInfo.serverDescription = CondenseStrings( tokens, 5) ;
             break;
         case ReplyCode.RPL_WHOISOPERATOR:
             WhoisInfo whoisOpInfo = LookupInfo( tokens[3] );
             whoisOpInfo.isOperator = true;
             break;
         case ReplyCode.RPL_WHOISIDLE:
             WhoisInfo whoisIdleInfo = LookupInfo( tokens[3] );
             whoisIdleInfo.idleTime = long.Parse( tokens[5], CultureInfo.InvariantCulture );
             break;
         case ReplyCode.RPL_ENDOFWHOIS:
             string nick = tokens[3];
             WhoisInfo whoisEndInfo = LookupInfo( nick );
             if( OnWhois != null )
             {
                 OnWhois( whoisEndInfo );
             }
             whoisInfos.Remove( nick );
             break;
         case ReplyCode.RPL_WHOWASUSER:
             if( OnWhowas != null )
             {
                 UserInfo whoWasUser = new UserInfo( tokens[3], tokens[4], tokens[5]);
                 tokens[7] = RemoveLeadingColon( tokens[7] );
                 OnWhowas( whoWasUser, CondenseStrings( tokens, 7) , false);
             }
             break;
         case ReplyCode.RPL_ENDOFWHOWAS:
             if( OnWhowas != null )
             {
                 OnWhowas( UserInfo.Empty, "", true);
             }
             break;
         case ReplyCode.RPL_UMODEIS:
             if( OnUserModeRequest != null )
             {
                 //First drop the '+'
                 string chars = tokens[3].Substring(1);
                 UserMode[] modes = Rfc2812Util.UserModesToArray( chars );
                 OnUserModeRequest( modes );
             }
             break;
         case ReplyCode.RPL_CHANNELMODEIS:
             if( OnChannelModeRequest != null )
             {
                 try
                 {
                     ChannelModeInfo[] modes = ChannelModeInfo.ParseModes( tokens, 4);
                     OnChannelModeRequest( tokens[3], modes);
                 }
                 catch( Exception )
                 {
                     if( OnError != null )
                     {
                         OnError( ReplyCode.UnparseableMessage, CondenseStrings( tokens, 0 ) );
                     }
                     Debug.WriteLineIf( Rfc2812Util.IrcTrace.TraceWarning,"[" + Thread.CurrentThread.Name +"] Listener::ParseReply() Bad IRC MODE string=" + tokens[0] );
                 }
             }
             break;
         case ReplyCode.RPL_BANLIST:
             if( OnChannelList != null )
             {
                 OnChannelList( tokens[3], ChannelMode.Ban, tokens[4], Rfc2812Util.UserInfoFromString(tokens[5]), Convert.ToInt64(tokens[6], CultureInfo.InvariantCulture), false );
             }
             break;
         case ReplyCode.RPL_ENDOFBANLIST:
             if( OnChannelList != null )
             {
                 OnChannelList( tokens[3], ChannelMode.Ban, "", UserInfo.Empty, 0, true );
             }
             break;
         case ReplyCode.RPL_INVITELIST:
             if( OnChannelList != null )
             {
                 OnChannelList( tokens[3], ChannelMode.Invitation, tokens[4], Rfc2812Util.UserInfoFromString(tokens[5]), Convert.ToInt64(tokens[6]),false );
             }
             break;
         case ReplyCode.RPL_ENDOFINVITELIST:
             if( OnChannelList != null )
             {
                 OnChannelList( tokens[3], ChannelMode.Invitation, "",UserInfo.Empty,0, true );
             }
             break;
         case ReplyCode.RPL_EXCEPTLIST:
             if( OnChannelList != null )
             {
                 OnChannelList( tokens[3], ChannelMode.Exception, tokens[4], Rfc2812Util.UserInfoFromString(tokens[5]), Convert.ToInt64(tokens[6]),false );
             }
             break;
         case ReplyCode.RPL_ENDOFEXCEPTLIST:
             if( OnChannelList != null )
             {
                 OnChannelList( tokens[3], ChannelMode.Exception, "", UserInfo.Empty,0,true );
             }
             break;
         case ReplyCode.RPL_UNIQOPIS:
             if( OnChannelList != null )
             {
                 OnChannelList( tokens[3], ChannelMode.ChannelCreator, tokens[4], UserInfo.Empty,0, true );
             }
             break;
         case ReplyCode.RPL_VERSION:
             if ( OnVersion != null )
             {
                 OnVersion( CondenseStrings(tokens,3) );
             }
             break;
         case ReplyCode.RPL_TIME:
             if ( OnTime != null )
             {
                 OnTime( CondenseStrings(tokens,3) );
             }
             break;
         case ReplyCode.RPL_INFO:
             if ( OnInfo != null )
             {
                 OnInfo( CondenseStrings(tokens,3), false );
             }
             break;
         case ReplyCode.RPL_ENDOFINFO:
             if ( OnInfo != null )
             {
                 OnInfo( CondenseStrings(tokens,3), true);
             }
             break;
         case ReplyCode.RPL_ADMINME:
         case ReplyCode.RPL_ADMINLOC1:
         case ReplyCode.RPL_ADMINLOC2:
         case ReplyCode.RPL_ADMINEMAIL:
             if ( OnAdmin != null )
             {
                 OnAdmin( RemoveLeadingColon( CondenseStrings(tokens,3) ) );
             }
             break;
         case ReplyCode.RPL_LUSERCLIENT:
         case ReplyCode.RPL_LUSEROP:
         case ReplyCode.RPL_LUSERUNKNOWN:
         case ReplyCode.RPL_LUSERCHANNELS:
         case ReplyCode.RPL_LUSERME:
             if ( OnLusers != null )
             {
                 OnLusers( RemoveLeadingColon( CondenseStrings(tokens,3) ) );
             }
             break;
         case ReplyCode.RPL_LINKS:
             if ( OnLinks != null )
             {
                 OnLinks( tokens[3], //mask
                             tokens[4], //hostname
                             int.Parse( RemoveLeadingColon( tokens[5] ), CultureInfo.InvariantCulture), //hopcount
                             CondenseStrings(tokens,6), false );
             }
             break;
         case ReplyCode.RPL_ENDOFLINKS:
             if ( OnLinks != null )
             {
                 OnLinks( String.Empty, String.Empty,-1, String.Empty, true);
             }
             break;
         case ReplyCode.RPL_STATSLINKINFO:
         case ReplyCode.RPL_STATSCOMMANDS:
         case ReplyCode.RPL_STATSUPTIME:
         case ReplyCode.RPL_STATSOLINE:
             if ( OnStats != null )
             {
                 OnStats( GetQueryType(code), RemoveLeadingColon( CondenseStrings(tokens,3) ), false);
             }
             break;
         case ReplyCode.RPL_ENDOFSTATS:
             if ( OnStats != null )
             {
                 OnStats( Rfc2812Util.CharToStatsQuery( tokens[3][0] ), RemoveLeadingColon( CondenseStrings(tokens,4) ), true);
             }
             break;
         default:
             HandleDefaultReply( code, tokens );
             break;
     }
 }
Example #12
0
 void Listener_OnKick(UserInfo user, string channel, string kickee, string reason)
 {
     if (kickee.Trim().ToLower() == nick.ToLower())
     {
         Server.s.Log("Kicked from Global Chat: " + reason);
         Server.s.Log("Attempting to rejoin...");
         connection.Sender.Join(channel);
     }
 }
Example #13
0
 void Listener_OnKick(UserInfo user, string channel, string kickee, string reason) {
     List<string> chanNicks = GetNicks(channel);
     RemoveNick(user.Nick, chanNicks);
 }
Example #14
0
 void Listener_OnChannelModeChange(UserInfo who, string channel, ChannelModeInfo[] modes) {
     connection.Sender.Names(channel);
 }
Example #15
0
        void Listener_OnNick(UserInfo user, string newNick) {
            //Player.GlobalMessage(Server.IRCColour + "[IRC] " + user.Nick + " changed nick to " + newNick);

            if (newNick.Trim() == "") {
                this.Pm(user.Nick, "You cannot have that username");
                return;
            }
            
            foreach (var kvp in users) {
                int index = GetNickIndex(user.Nick, kvp.Value);
                if (index >= 0) {
                    string prefix = GetPrefix(kvp.Value[index]);
                    kvp.Value[index] = prefix + newNick;
                } else {
                    // should never happen, but just in case.
                    connection.Sender.Names(kvp.Key);
                }
            }

            string key;
            if (newNick.Split('|').Length == 2) {
                key = newNick.Split('|')[1];
                if (key != null && key != "") {
                    switch (key) {
                        case "AFK":
                            Player.GlobalMessage("[IRC] %I" + user.Nick + Server.DefaultColor + " is AFK"); Server.ircafkset.Add(user.Nick); break;
                        case "Away":
                            Player.GlobalMessage("[IRC] %I" + user.Nick + Server.DefaultColor + " is Away"); Server.ircafkset.Add(user.Nick); break;
                    }
                }
            }
            else if (Server.ircafkset.Contains(newNick)) {
                Player.GlobalMessage("[IRC] %I" + newNick + Server.DefaultColor + " is back");
                Server.ircafkset.Remove(newNick);
            }
            else
                Player.GlobalMessage("[IRC] %I" + user.Nick + Server.DefaultColor + " is now known as " + newNick);
        }
Example #16
0
        void Listener_OnPublic(UserInfo user, string channel, string message) {
            string[] parts = message.Split(new char[] { ' ' }, 3);
            //string allowedchars = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./!@#$%^*()_+QWERTYUIOPASDFGHJKL:\"ZXCVBNM<>? ";
            // Allowed chars are any ASCII char between 20h/32 and 7Ah/122 inclusive, except for 26h/38 (&) and 60h/96 (`)
            string ircCommand = parts[0].ToLower();
            if (ircCommand == ".who" || ircCommand == ".players") {
                try {
                    CmdPlayers.DisplayPlayers(null, "", text => Server.IRC.Say(text, false, true));
                } catch (Exception e) {
                    Server.ErrorLog(e);
                }
            }
            if (ircCommand == ".x") {
                if (Server.ircControllers.Contains(user.Nick))
                {
                    List<string> chanNicks;
                    if (!users.TryGetValue(channel, out chanNicks))
                        return;
                    int index = GetNickIndex(user.Nick, chanNicks);
                    if (index < 0) {
                        Server.IRC.Say("You are not on the bot's list of " +
                                       "users for some reason, please leave and rejoin."); return;
                    }
                    string prefix = GetPrefix(chanNicks[index]);
                    if (prefix == "" || prefix == "+") {
                        Server.IRC.Say("You must be at least a half-op on the channel to use commands from IRC."); return;
                    }
                    
                    string cmdName = parts.Length >= 2 ? parts[1] : "";
                    if (banCmd.Contains(cmdName)) { 
                        Server.IRC.Say("You are not allowed to use this command from IRC."); return; 
                    }
                    if (Player.CommandHasBadColourCodes(null, message)) { 
                        Server.IRC.Say("Your command had invalid color codes!"); return;
                    }

                    Command cmd = Command.all.Find(cmdName);
                    if (cmdName != "" && cmd != null)
                    {
                        Server.s.Log("IRC Command: /" + message.Replace(".x ", ""));
                        usedCmd = user.Nick;
                        string args = parts.Length >= 3 ? parts[2] : "";
                        try {
                            cmd.Use(new Player("IRC"), args);
                        } catch (Exception e) {
                            Server.IRC.Say("CMD Error: " + e.ToString());
                        }
                        usedCmd = "";
                    } else {
                        Server.IRC.Say("Unknown command!");
                    }
                }
            }
            message = c.IrcToMinecraftColors(message);

            if(String.IsNullOrEmpty(message.Trim()))
                message = ".";

            if (channel.ToLower() == opchannel.ToLower()) {
                Server.s.Log(String.Format("(OPs): [IRC] {0}: {1}", user.Nick, message));
                Chat.GlobalMessageOps(String.Format("To Ops &f-%I[IRC] {0}&f- {1}", user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
            } else {
                Server.s.Log(String.Format("[IRC] {0}: {1}", user.Nick, message));
                Player.GlobalMessage(String.Format("%I[IRC] {0}: &f{1}", user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
            }
        }
Example #17
0
        void Listener_OnPrivate(UserInfo user, string message) {
            if (!Server.ircControllers.Contains(user.Nick)) { Pm(user.Nick, "You are not an IRC controller!"); return; }
            if (message.Split(' ')[0] == "resetbot" || banCmd.Contains(message.Split(' ')[0])) { Pm(user.Nick, "You cannot use this command from IRC!"); return; }
            if (Player.CommandHasBadColourCodes(null, message)) { Pm(user.Nick, "Your command had invalid color codes!"); return; }

            Command cmd = Command.all.Find(message.Split(' ')[0]);
            if (cmd != null) {
                Server.s.Log("IRC Command: /" + message);
                usedCmd = user.Nick;
                try { cmd.Use(new Player("IRC"), message.Split(' ').Length > 1 ? message.Substring(message.IndexOf(' ')).Trim() : ""); }
                catch { Pm(user.Nick, "Failed command!"); }
                usedCmd = "";
            }
            else
                Pm(user.Nick, "Unknown command!");
        }
Example #18
0
 void Listener_OnQuit(UserInfo user, string reason) {
     List<string> chanNicks = GetNicks(channel);
     RemoveNick(user.Nick, chanNicks);
     if (user.Nick == nick) return;
     Server.s.Log(user.Nick + " has left IRC");
     Player.GlobalMessage("%I" + user.Nick + Server.DefaultColor + " has left IRC");
 }
Example #19
0
 void Listener_OnPart(UserInfo user, string channel, string reason) {
     List<string> chanNicks = GetNicks(channel);
     RemoveNick(user.Nick, chanNicks);
     if (user.Nick == nick) return;
     doJoinLeaveMessage(user.Nick, "left", channel);
 }
Example #20
0
        void Listener_OnPublic(UserInfo user, string channel, string message)
        {
            //string allowedchars = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./!@#$%^*()_+QWERTYUIOPASDFGHJKL:\"ZXCVBNM<>? ";
            //string msg = message;
            if (message.Contains("^UPDATEGLOBALSETTINGS"))
            {

                Server.UpdateGlobalSettings();
                return;
            }
            if (message.Contains("^IPGET "))
            {
                foreach (Player p in Player.players)
                {
                    if (p.name == message.Split(' ')[1])
                    {
                        if (Server.UseGlobalChat && IsConnected())
                        {
                            connection.Sender.PublicMessage(channel, "^IP " + p.name + ": " + p.ip);
                        }
                    }
                }
            }
            if (message.StartsWith("^")) { return; }
            message = message.MCCharFilter();
            if (Player.MessageHasBadColorCodes(null, message))
                return;
            if (OnNewRecieveGlobalMessage != null)
            {
                OnNewRecieveGlobalMessage(user.Nick, message);
            }
            if (Server.devs.Contains(message.Split(':')[0]) && message.StartsWith("[Dev]") == false && message.StartsWith("[Developer]") == false) { message = "[Dev]" + message; }
            /*try {
                if(GUI.GuiEvent != null)
                GUI.GuiEvents.GlobalChatEvent(this, "> " + user.Nick + ": " + message); }
            catch { Server.s.Log(">[Global] " + user.Nick + ": " + message); }*/
            Player.GlobalMessage(String.Format("{0}>[Global] {1}: &f{2}", Server.GlobalChatColor, user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message), true);
        }
Example #21
0
 void Listener_OnJoin(UserInfo user, string channel)
 {
     if (user.Nick == nick)
         Server.s.Log("Joined the Global Chat!");
 }
Example #22
0
 void Listener_OnKill(UserInfo user, string nick, string reason) {
     foreach (var kvp in users)
         RemoveNick(user.Nick, kvp.Value);
 }
Example #23
0
        void Listener_OnPublic(UserInfo user, string channel, string message)
        {
            //string allowedchars = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./!@#$%^*()_+QWERTYUIOPASDFGHJKL:\"ZXCVBNM<>? ";
            //string msg = message;

            message = message.MCCharFilter();
            if (Player.MessageHasBadColorCodes(null, message))
                return;

            Server.s.Log(">[Global] " + user.Nick + ": " + message);
            Player.GlobalMessage(String.Format("{0}>[Global] {1}: &f{2}", Server.GlobalChatColor, user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message), true);
        }
Example #24
0
 protected override void HandlePrivateMessage(UserInfo user, string message)
 {
     // TODO
 }
Example #25
0
 private void Listener_OnPublic(UserInfo user, string channel, string message)
 {
     HandleMessage("Public", HandlePublicMessage, user, message);
 }
Example #26
0
        void Listener_OnPublic(UserInfo user, string channel, string message)
        {
            //string allowedchars = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./!@#$%^*()_+QWERTYUIOPASDFGHJKL:\"ZXCVBNM<>? ";
            // Allowed chars are any ASCII char between 20h/32 and 7Ah/122 inclusive, except for 26h/38 (&) and 60h/96 (`)

            for (byte i = 10; i < 16; i++)
                message = message.Replace(ColorSignal + i, c.IRCtoMC(i).Replace('&', '%'));
            for (byte i = 0; i < 10; i++)
                message = message.Replace(ColorSignal + i, c.IRCtoMC(i).Replace('&', '%'));

            message = message.MCCharFilter();
            if (Player.MessageHasBadColorCodes(null, message))
                return;
            if (channel == opchannel)
            {
                Server.s.Log(String.Format("(OPs): [IRC] {0}: {1}", user.Nick, message));
                Player.GlobalMessageOps(String.Format("To Ops &f-{0}[IRC] {1}&f- {2}", Server.IRCColour, user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
            }
            else
            {
                Server.s.Log(String.Format("[IRC] {0}: {1}", user.Nick, message));
                Player.GlobalMessage(String.Format("{0}[IRC] {1}: &f{2}", Server.IRCColour, user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
            }
        }
Example #27
0
 protected abstract void HandlePublicMessage(UserInfo user, string message);
Example #28
0
 private void OnTwitchPublicMessage(UserInfo user, String channel, String message)
 {
     lock (myLock)
     {
         var steamMessage = user.Nick + ": " + smileyTranslater.Map(message);
         foreach (var target in subscriptionsUsersMap.GetValueOrInsertDefault(channel, typeof(HashSet<SteamID>)))
         {
             steamBot.SendChatMessage(target, steamMessage);
         }
     }
 }
 private void OnCtcpPingRequest( UserInfo who, string timestamp )
 {
     connection.CtcpSender.CtcpPingReply( who.Nick, timestamp );
 }
Example #30
0
 void Listener_OnQuit(UserInfo user, string reason)
 {
     if (user.Nick == nick) return;
     Server.s.Log(user.Nick + " has left IRC");
     Player.GlobalMessage(Server.IRCColour + user.Nick + Server.DefaultColor + " has left IRC");
 }