Exemple #1
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#canceltrade")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#canceltrade", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("canceltrade", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                TheTCPWrapper.Send(CommandCreator.EXIT_TRADE());
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "The trade was cancelled!"));
                return;
            }
        }
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#isonline")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#isonline", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#isonline", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (CommandArray.Length < 2)
                {
                    goto WrongArguments;
                }
                string playerName     = CommandArray[1];
                bool   playerIsOnline = false;
                string serverName     = "live";
                if (CommandArray.Length == 3)
                {
                    serverName = CommandArray[2];
                }
                if ((playerIsOnline = TheMySqlManager.isPlayerOnline(e.username, playerName, serverName)))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, playerName + " is online on the " + serverName + " server."));
                }
                else
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, playerName + " is not online on the " + serverName + " server."));
                }
                return;

WrongArguments:
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-------------------------------------------"));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #isonline command:"));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#isonline <playername> <server>            "));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-------------------------------------------"));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #isonline DogBreath test          "));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-------------------------------------------"));
                return;
            }
        }
Exemple #3
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#sit")
            {
//                if (CommandArray.Length < 3)
//                    goto WrongArguments;
//
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#sit", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#move", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                TheTCPWrapper.Send(CommandCreator.SIT_DOWN(true));
            }
            if (CommandArray[0] == "#stand")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#stand", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#tl", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                TheTCPWrapper.Send(CommandCreator.SIT_DOWN(false));
            }
            return;
            //WrongArguments:
            //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #move command:   "));
            //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#move x y                                 "));
            //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #move 192 168                    "));
            //    return;
        }
Exemple #4
0
 private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
 {
     if (TheMySqlManager.loggotpms(Settings.botid) == true)
     {
         if (e.username.ToLower() == "gossip" && LogGossipFeed == false)
         {
             return;
         }
         TheLogger.PMLog("Got PM from " + e.username + ": " + e.Message);
     }
 }
Exemple #5
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#pm")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#pm", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#pm", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                int i;
                Message = "";

                if (CommandArray.Length < 3)
                {
                    goto WrongArguments;
                }

                for (i = 2; i < CommandArray.Length; i++)
                {
                    Message += CommandArray[i] + " ";
                }
                Message = Message.Trim();
                TheTCPWrapper.Send(CommandCreator.SEND_PM(CommandArray[1], Message));
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "-------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Here is the usage of the #pm command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#pm <username> <message>             "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "-------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Example: #pm artem Hi, how are You?  "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "-------------------------------------"));
            return;
        }
Exemple #6
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#retrade" || CommandArray[0] == "#r")
            {
                /*
                 * bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#pm", Settings.botid);
                 *
                 * if (disabled == true)
                 * {
                 *  TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                 *  return;
                 * }
                 */

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#inv", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                //TheMessageParser.FakeMessage(e.username + " her in order to accept the trade.");
                if (!TheTradeHandler.AmITrading())
                {
                    TheMessageParser.FakeTrade(e.username);
                    //TheTCPWrapper.Send(CommandCreator.TRADE_WITH(TheActorHandler.GetUserIDFromname(e.username)));
                }
                else if (TradeHandler.username == e.username && TheTradeHandler.AmITrading())
                {
                    TheTCPWrapper.Send(CommandCreator.EXIT_TRADE());
                    TheMessageParser.FakeTrade(e.username);
                    //TheTCPWrapper.Send(CommandCreator.TRADE_WITH(TheActorHandler.GetUserIDFromname(e.username)));
                }
                else
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#Retrade will only work when I am not trading with someone else."));
                    //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#Retrade will only work when I am trading with you."));
                    return;
                }
            }
            return;
        }
Exemple #7
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#useobject")
            {
                if (CommandArray.Length < 2)
                {
                    goto WrongArguments;
                }

                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#useobject", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#useobject", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (CommandArray[1].Contains(","))
                {
                    goto WrongArguments;
                }
                int objectid = int.Parse(CommandArray[1]);
                TheTCPWrapper.Send(CommandCreator.USE_MAP_OBJECT((uint)objectid, -1));
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #useobject command:   "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#useobject x                                   "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-----------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #useobject 520                        "));
            return;
        }
Exemple #8
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#automessage" || CommandArray[0] == "#automessage:" || CommandArray[0] == "#afk")
            {
                return;
            }

            return;
        }
Exemple #9
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#ty" || CommandArray[0] == "#tyvm" || CommandArray[0] == "#thx" || CommandArray[0] == "#thank" || CommandArray[0] == "#thanks" || CommandArray[0] == "#thy" || CommandArray[0] == "#thanx")
            {
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are very welcome, and thank you :)"));
                return;
            }

            return;
        }
Exemple #10
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int    lineSize = 56;
            string Message  = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#adminhelp")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#adminhelp", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#adminhelp", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '-')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[List of admin commands:".PadRight(lineSize, ' ')));

                // display the admin help commands
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '=')));
                foreach (string MyCommand in CommandArrayList)
                {
                    if (!MyCommand.ToLower().Contains("null"))
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[" + MyCommand.PadRight(lineSize - 1, ' ')));
                    }
                }
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '=')));
            }
        }
Exemple #11
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#quit" || CommandArray[0] == "#exit" || CommandArray[0] == "#shutdown")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#quit", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#quit", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                //if (TheTradeHandler.AmITrading())
                //{
                //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly."));
                //    return;
                //}

                //shut the bot down here
                //TheMessageParser.FakePM("Console:\\>", "#say  Returning to my slumber...  Wake me at your own risk!");
                //                TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#gm ### SHUTTING DOWN UNTIL NEEDED AGAIN ###"));
                TheMessageParser.FakePM("Console:\\>", "#say #gm ### SHUTTING DOWN UNTIL NEEDED AGAIN ###");
                TheMySqlManager.ImLoggedOut(Settings.botid);
                return;
            }
        }
Exemple #12
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#online")
            {
                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#online", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (CommandArray.Length < 1)
                {
                    goto WrongArguments;
                }

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Name".PadRight(20, ' ') + "|Lastlogin          |Lastlogout   |LoggdIn"));
                TheMySqlManager.listBuddies(e.username);
            }


            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Here is the usage of the #online command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#online"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#online all"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Example: #online"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Example: #online all"));
            return;
        }
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#kickme")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#kickme", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#kickme", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheMySqlManager.CheckIfGuildMember(e.username, Settings.botid) == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, but you are not a guild member."));
                    return;
                }

                Message = "#remove " + e.username;

                TheTCPWrapper.Send(CommandCreator.RAW_TEXT(Message));
            }

            return;
        }
Exemple #14
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#gt")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#gt", Settings.botid);

                if (disabled == true)
                {
                    //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (e.username.ToLower() != "gossip")
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                string name = "", temp = "", guild = "";
                temp = CommandArray[1].Trim();
                if (guild == "")
                {
                    guild = "";
                }
                if (guild.ToLower() == "noexist")
                {
                    return;
                }
                TheMySqlManager.UpdatePlayer(name, guild);
            }
            return;
        }
Exemple #15
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');
            int      linsize      = 55;

            if (CommandArray[0] == "#about" || CommandArray[0] == "#a" || CommandArray[0] == "#hi" || CommandArray[0] == "#gday" || CommandArray[0] == "#hello")
            {
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(linsize, '-')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Hello, I am a C# bot by DogBreath.".PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[PM me in game if you need me... or on the test server.".PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, ("[Version: " + Settings.Version.ToString()).PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(linsize, '-')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[This code relies heavily on code written by:".PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Artem Makhutov (Artem) and Gregory Fenton (LabRat)".PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Artem's homepage: http://www.makhutov.org/el".PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[labRat's homepage: http://www.labby.co.uk".PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[DogBreath's homepage: http://forum.el-services.net".PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(linsize, '-')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Special thanks to draavell my faithful assistant :)".PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Special thanks to VinoVeritas for the web hosting.".PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(linsize, '-')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, ("[My bot owner(s) is(are) " + TheMySqlManager.botowner(Settings.botid).ToString()).PadRight(linsize, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[" + Settings.URL.PadRight(linsize - 1, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(linsize, '-')));
            }

            if (CommandArray[0] == "#version" || CommandArray[0] == "#v" || CommandArray[0] == "#ver")
            {
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Version: " + Settings.Version));
            }
            return;
        }
Exemple #16
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }
            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#acceptme")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#acceptme", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#acceptme", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheMySqlManager.CheckIfGuildMember(e.username, Settings.botid) == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, but you are not a guild member."));
                    return;
                }

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "If you don't get accepted check if you have typed in #join_guild " + TheMySqlManager.guildlongname(Settings.botid) + " before using this command."));

                TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#accept " + e.username));
            }

            return;
        }
Exemple #17
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#whoistrading")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#whoistrading", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#quit", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (TradeHandler.username == "")
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "No one is trading with me."));
                }
                else
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, TradeHandler.username + " is trading with me."));
                }
//                TheMessageParser.FakePM("Console:\\>", "#say #gm ### SHUTTING DOWN UNTIL NEEDED AGAIN ###");
//                TheMySqlManager.ImLoggedOut(Settings.botid);
                return;
            }
        }
Exemple #18
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#loc" || CommandArray[0].ToLower() == "#l" || CommandArray[0].ToLower() == "#location" || CommandArray[0].ToLower() == "#lo" || CommandArray[0].ToLower() == "#where")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#loc", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#loc", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                string locString = "I am in " + Settings.LocationInfo;
                if (Settings.ServerPort == 2001)
                {
                    locString += "(" + MainClass.mapName + ")";
                }
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, locString));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, TheMySqlManager.locationdescription(Settings.botid).Trim()));
            }

            return;
        }
Exemple #19
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int    lineSize = 55;
            string Message  = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#help" || CommandArray[0] == "#h")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#help", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#help", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '-')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[List of available basic commands:".PadRight(lineSize, ' ')));

                // display a list of commands/text
                // for now, gonna cluge in some important ones being listed first
                // later I'll either add an element to the array or use the database to build the list

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '-')));
                foreach (string MyCommand in CommandArrayList)
                {
                    if (!MyCommand.ToLower().Contains("null"))
                    {
                        if (MyCommand.ToLower().Contains("#inv") || MyCommand.ToLower().Contains("#buy") || MyCommand.ToLower().Contains("#wanted") ||
                            MyCommand.ToLower().Contains("#loc"))
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[" + MyCommand.PadRight(lineSize - 1, ' ')));
                        }
                    }
                }
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '-')));

                foreach (string MyCommand in CommandArrayList)
                {
                    if (!MyCommand.ToLower().Contains("null") && !MyCommand.ToLower().Contains("#buy") && !MyCommand.ToLower().Contains("#wanted") &&
                        !MyCommand.ToLower().Contains("#loc"))
                    {
                        if (!MyCommand.ToLower().Contains("#inv"))
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[" + MyCommand.PadRight(lineSize - 1, ' ')));
                        }
                    }
                }

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '=')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[" + Settings.URL.PadRight(lineSize - 1, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '=')));
                //				TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username,"To see the usage of the commands write help after the command. Example: #buy help"));
            }
        }
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');


            //if (CommandArray[0] == "#donate" || (CommandArray[0] == "#d" && CommandArray.Length == 1))
            {
                if (TheMySqlManager.CheckIfTextCommandIsDisabled(CommandArray[0], Settings.botid))
                {
                    //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetTextCommandRank(CommandArray[0], Settings.botid))
                {
                    //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
            }
            if (TheMySqlManager.sendtextcommandtogm(CommandArray[0], Settings.botid))
            {
                TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#gm " + System.Convert.ToChar(TheMySqlManager.playerloggedoncolor(Settings.botid)) + "### " + e.username.ToUpper() + " JUST SENT " + CommandArray[0] + " ###"));
            }
            string text     = TheMySqlManager.TextCommandText(CommandArray[0], Settings.botid);
            int    maxwidth = 60;

            if (text.Length < maxwidth)
            {
                maxwidth = text.Length;
            }
            //text = text.Replace(System.Convert.ToString(13) + System.Convert.ToString(10), System.Convert.ToString(13)).Replace(System.Convert.ToString(10), System.Convert.ToString(13)).Replace(System.Convert.ToString(13)+System.Convert.ToString(13),System.Convert.ToString(13));
            if (text.Length < maxwidth)
            {
                maxwidth = text.Length;
            }

            string[] lines = text.Split(' ');
            if (lines.Length == 0)
            {
                return;
            }

            string separator = "[", spaces = "";

            for (int i = 0; i <= maxwidth; i++)
            {
                separator += "=";
                spaces    += " ";
            }
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, separator));
            string str = "";

            foreach (string tl in lines)
            {
                if (tl.Contains("\n"))
                {
                    if (str.Length > 0)
                    {
                        str += " ";
                    }
                    //str += tl.Substring(0, tl.IndexOf("\n"));
                    if (str.Length + tl.Substring(0, tl.IndexOf("\n")).Length > maxwidth)
                    {
                        str += spaces;
                        str  = "[" + str.Substring(0, maxwidth + 1);
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                        str = tl.Substring(0, tl.IndexOf("\n"));
                    }
                    else
                    {
                        str += tl.Substring(0, tl.IndexOf("\n"));
                        str += spaces;
                        str  = "[" + str.Substring(0, maxwidth + 1);
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                        //str = tl.Substring(0, tl.IndexOf("\n"));
                        str = "";
                    }
                    if (str.Length > 0)
                    {
                        str += spaces;
                        str  = "[" + str.Substring(0, maxwidth + 1);
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                        str = "";
                    }
                    if (str.Length > 0)
                    {
                        str += " ";
                    }
                    if (tl.Length > tl.IndexOf("\n"))
                    {
                        str = tl.Substring(tl.IndexOf("\n") + 1);
                    }
                }
                else
                {
                    if (str.Length + tl.Length > maxwidth && str.Length > 0 && !tl.Contains("\n"))
                    {
                        str += spaces;
                        str  = "[" + str.Substring(0, maxwidth + 1);
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                        str = "";
                    }
                    if (str.Length > 0)
                    {
                        str += " ";
                    }
                    str += tl;
                }
            }
            str += spaces;
            str  = "[" + str.Substring(0, maxwidth + 1);
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));

            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, separator));
            return;
        }
Exemple #21
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            uint quantity = 0;
            int  SQLID    = 0;
            //int nameToID = -1;
            //bool fromInventory = true;
            bool   fromInventory = false;
            string itemName      = "";

            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#give" || CommandArray[0] == "#g")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#give", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#give", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheTradeHandler.Trading == false || TradeHandler.username.ToLower() != e.username.ToLower())
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please trade with me first!"));
                    return;
                }
                if (TradeHandler.openingStorage)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please wait a moment for storage to finish opening!"));
                    return;
                }

                if (CommandArray.Length < 2)
                {
                    goto WrongArguments;
                }

                int i = 0;
                try
                {
                    //there is a quantity given
                    quantity = uint.Parse(CommandArray[1]);
                    i        = 2;
                }
                catch
                {
                    //no quantity given
                    quantity = 1;
                    i        = 1;
                }
                if (!TradeHandler.storageOpen)
                {
                    fromInventory = true;
                }
                for (; i < CommandArray.Length; i++)
                {
                    if (CommandArray[i] == "inv" || CommandArray[i] == "inventory")
                    {
                        fromInventory = true;
                        break;
                    }
                    itemName += CommandArray[i] + " ";
                }
                try
                {
                    SQLID = int.Parse(itemName);
                }
                catch
                {
                    SQLID = TheMySqlManager.GetItemID(itemName, Settings.botid, !fromInventory);
                }
                uint ItemsPlacedOnTrade = TheTradeHandler.PutItemsOnTrade(SQLID, quantity, fromInventory);
                if (ItemsPlacedOnTrade > 0)
                {
                    TheTradeHandler.Donating   = true;
                    TheTradeHandler.itemTraded = true;
                    if (fromInventory == true)
                    {
                        TheTradeHandler.AddTrade(SQLID, 0, ItemsPlacedOnTrade, "gave from inv");
                    }
                    else
                    {
                        TheTradeHandler.AddTrade(SQLID, 0, ItemsPlacedOnTrade, "gave from sto");
                    }
                }

                if (ItemsPlacedOnTrade < quantity)
                {
                    if (ItemsPlacedOnTrade == 0 && !fromInventory)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I don't have this item in storage!"));
                    }
                    else if (ItemsPlacedOnTrade == 0)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I don't have this item in inventory!"));
                    }
                    else
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I only have " + ItemsPlacedOnTrade.ToString() + " of this item!"));
                    }
                }
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Here is the usage of the #give command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|#give <quantity> <name or itemid>      "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #give 100 2                   "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #give 1 Pickaxe               "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #give 1 Pickaxe inv           "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            return;
        }
Exemple #22
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            string[] Inv           = new string[64];
            string   searchName    = "";
            string   inputCategory = "";

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');
            bool     issto        = false;

            if (CommandArray[0] == "#sto")
            {
                issto = true;
            }
            if (issto)
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#sto", Settings.botid);


                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid);
                if (rank < TheMySqlManager.GetCommandRank("#sto", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

//                if (TheTradeHandler.Trading == false || TheTradeHandler.username.ToLower() == "")
////                if (TheTradeHandler.Trading == false || TheTradeHandler.username.ToLower() != e.username.ToLower())
//                {
//                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Someone must be trading with me first!"));
//                    return;
//                }
                if (!TradeHandler.storageOpen)
                {
                    if (TradeHandler.openingStorage)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please wait a moment for storage to finish opening."));
                    }
                    else
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You must open storage first!"));
                    }
                    return;
                }

                if (CommandArray.Length < 1)
                {
                    goto WrongArguments;
                }
                else if (CommandArray.Length > 1)
                //inputCategory = (string)CommandArray.GetValue(1);
                {
                    for (int i = 1; i < CommandArray.Length; i++)
                    {
                        if (inputCategory.Length > 0)
                        {
                            inputCategory += (" " + (string)CommandArray[i]);
                        }
                        else
                        {
                            inputCategory += (string)CommandArray[i];
                        }
                    }
                    //Console.WriteLine("inputCategory:{0}", inputCategory);
                }
                else
                {
                    if (TheStorage.TheStorageCategories.Count > 0 && TradeHandler.storageOpen)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please enter one of the following categories (or an item name)!"));

                        foreach (Storage.StorageCategory MyStorageCategory in TheStorage.TheStorageCategories)
                        {
                            if (MyStorageCategory.num != -1)
                            {
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, MyStorageCategory.name));
                            }
                        }
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "All"));
                    }
                    return;
                }

                string searchcategory = "";
                bool   categoryFound  = false;

                searchName = inputCategory;
                foreach (Storage.StorageCategory MyStorageCategory in TheStorage.TheStorageCategories)
                {
                    searchcategory = MyStorageCategory.name.ToLower();
                    if (searchcategory.Contains(inputCategory) || (inputCategory.Contains("all")))
                    {
                        searchName    = "";
                        categoryFound = true;
                    }
                }

                if (categoryFound == false)
                {
                    inputCategory = "all";
                }
                //pm the boarder
                string str        = "";
                string str2       = "";
                int    lineLength = 55;
                str  = "[";
                str  = str.PadRight(lineLength, '-');
                str2 = "[";
                str2 = str2.PadRight(lineLength, '=');
                //string header = "[ItemID:    Qty:  Name:";
                //header = header.PadRight(lineLength, ' ');
                string catname    = "";
                bool   itemsFound = false;
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str2));
                bool Member = (TheMySqlManager.CheckIfTradeMember(e.username, Settings.botid) == true);

                //loop through the storage sending pms
                foreach (Storage.StorageCategory MyStorageCategory in TheStorage.TheStorageCategories)
                {
                    catname        = "[Item ID:  Count: Category: " + MyStorageCategory.name.Substring(0, MyStorageCategory.name.Length);
                    catname        = catname.PadRight(lineLength, ' ');
                    searchcategory = MyStorageCategory.name.ToLower();
                    if (searchcategory.Contains(inputCategory) || (inputCategory.Contains("all")))
                    {
                        if (searchName == "")
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, catname));
                            // send header
                            //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, header));
                        }
                        bool categoryPrinted = false;
                        foreach (Storage.StorageItem MyStorageItem in TheStorage.GetStorageList())
                        {
                            string outputLine = "";
                            Int32  tempAmount = 0;
                            string temp;
                            string spaces = "   ";
                            temp       = MyStorageItem.knownItemsID.ToString();
                            temp       = temp.PadLeft(6, ' ');
                            outputLine = "[" + temp + spaces;
                            tempAmount = (Int32)(MyStorageItem.quantity - MyStorageItem.reservedQuantity);
                            if (tempAmount < 0)
                            {
                                tempAmount = 0;
                            }
//                            temp = (MyStorageItem.quantity - MyStorageItem.reservedQuantity).ToString();
                            temp        = tempAmount.ToString();
                            temp        = temp.PadLeft(5, ' ');
                            outputLine += temp + spaces + MyStorageItem.name.Substring(0, MyStorageItem.name.Length);
                            outputLine  = outputLine.PadRight(lineLength, ' ');
                            if (searchName != "")
                            {
                                if (MyStorageItem.name.ToLower().Contains(searchName) && MyStorageItem.category_num == MyStorageCategory.num)
                                {
                                    if (categoryPrinted == false)
                                    {
                                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, catname));
                                    }
                                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outputLine));
                                    itemsFound      = true;
                                    categoryPrinted = true;
                                }
                            }
                            else if (MyStorageItem.category_num == MyStorageCategory.num)
                            {
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outputLine));
                                itemsFound = true;
                            }
                        }
                        if (itemsFound == false && searchName == "")
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[None found"));
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                        }
                        else if (itemsFound == true)
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                        }
                        itemsFound = false;
                    }
                }

                return;
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #sto command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#sto <item>                           "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #sto                         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #sto silver                  "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            return;
        }
Exemple #23
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int    UsedSlots = 0;
            string Message   = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            string[] Inv    = new string[64];
            int      maxlen = 4;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');
            bool     isinv = false, isinvmembers = false;

            if (CommandArray[0] == "#inv" || CommandArray[0] == "#i" || CommandArray[0] == "#inb" || CommandArray[0] == "#sell" || CommandArray[0] == "#selling" || CommandArray[0] == "#inventory")
            {
                isinv = true;
            }
            if (CommandArray[0] == "#invmembers" || CommandArray[0] == "#im" || CommandArray[0] == "#invmemvers" || CommandArray[0] == "#invmember" || CommandArray[0] == "#invmemver")
            {
                isinvmembers = true;
            }
            if (isinv || isinvmembers)
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#inv", Settings.botid);

                string str1 = "", str2 = "";

                if (TheInventory.GettingInventoryItems == true)
                {
                    str2 = "I am building my inventory list, please try again in a few seconds";
                    str1 = str1.PadRight(str2.Length, '=');
                    str1 = "[" + str1;
                    str2 = "[" + str2;
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str2));
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));

                    return;
                }

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (Settings.IsTradeBot == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I am not a trade bot!"));
                    return;
                }
                int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid);
                if (rank < TheMySqlManager.GetCommandRank("#inv", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if ((CommandArray[0] == "#im" || CommandArray[0] == "#invmembers" || CommandArray[0] == "#invmemvers" || CommandArray[0] == "#invmember" || CommandArray[0] == "#invmemver") && ((rank < TheMySqlManager.GetCommandRank("#invmembers", Settings.botid)) && TheMySqlManager.CheckIfBannedGuild(e.username, Settings.botid) < 1))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (this.TheTradeHandler.AmITrading() && e.username != TradeHandler.username)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly."));
                    return;
                }

                if (CommandArray.Length < 1)
                {
                    goto WrongArguments;
                }

                char invFiller = TheMySqlManager.getInvFiller();

                System.Collections.ArrayList MyInventoryList    = TheInventory.GetInventoryList();
                System.Collections.Hashtable MySellingItemsList = TheMySqlManager.GetSellingItemList(0);

                // sum up all inventory items if the items are on sale
                System.Collections.SortedList TheInventoryList = new System.Collections.SortedList();

                foreach (Inventory.inventory_item MyInventoryItem in MyInventoryList)
                {
                    //adjust the number of slots used...
                    if (MyInventoryItem.pos < 36)
                    {
                        if (MyInventoryItem.is_stackable)
                        {
                            UsedSlots++;
                        }
                        else
                        {
                            UsedSlots = UsedSlots + (int)(MyInventoryItem.quantity);
                        }
                    }
                    //adjust the amount

                    //only display if in selling list
                    if (MySellingItemsList.Contains(MyInventoryItem.SqlID))
                    {
                        //if already in inventory output (eg.., two slots) just sum the quantity
                        //otherwise add to inventory output
                        if (TheInventoryList.Contains(MyInventoryItem.SqlID) && MyInventoryItem.pos < 36)
                        {
                            Inventory.inventory_item TempInventoryItem = (Inventory.inventory_item)TheInventoryList[MyInventoryItem.SqlID];
                            TempInventoryItem.quantity += MyInventoryItem.quantity;
                            TheInventoryList[MyInventoryItem.SqlID] = TempInventoryItem;
                        }
                        else
                        {
                            if (MyInventoryItem.pos < 36)
                            {
                                TheInventoryList.Add(MyInventoryItem.SqlID, MyInventoryItem);
                            }
                        }
                    }
                }

                //foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values)
                //{
                //    if(maxlen<MyInventoryItem.name.Length && (MyInventoryItem.pos < 36))
                //        maxlen = MyInventoryItem.name.Length;
                //}
                //maxlen++;
                maxlen = 20 + 25 - Settings.Loginname.Length;
                // pm all summed up inventory items on sale
                int i = 0;
                for (i = 0; i < 64; i++)
                {
                    Inv[i] = "ZZZZZZZZZZZZZZZZ";
                }
                int    c   = 0;
                string str = "";
                str2 = "";
                str  = "[";
                str  = str.PadRight(maxlen + 27, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                bool Member = (TheMySqlManager.CheckIfTradeMember(e.username, Settings.botid) == true);

                str = "[name".PadRight(maxlen, ' ');
                str = str + "|qty".PadRight(7, ' ');
                str = str + "|price".PadRight(14, ' ');
                str = str + "|id".PadRight(6, ' ');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));

                str = "[";
                str = str.PadRight(maxlen + 27, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));

                string msg, msg2;

                foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values)
                {
                    if (MyInventoryItem.pos < 36)
                    {
                        msg = ("[" + MyInventoryItem.name).PadRight(maxlen, i == 0 ? ' ' : invFiller);
                        {
                            uint tempAmount = 0;
                            if ((TheMySqlManager.ReservedAmount(MyInventoryItem.SqlID)) < MyInventoryItem.quantity)
                            {
                                tempAmount = MyInventoryItem.quantity;
                                tempAmount = tempAmount - (TheMySqlManager.ReservedAmount(MyInventoryItem.SqlID));
                            }
                            else
                            {
                                continue;
                            }

                            msg2 = tempAmount.ToString();
                        }
                        msg2 = msg2.PadLeft(6, i == 0 ? ' ' : invFiller);
                        msg  = msg + "|" + msg2;
                        TradeHandler.SellingItem MySellingItem = (TradeHandler.SellingItem)(MySellingItemsList[MyInventoryItem.SqlID]);
                        if (isinv)
                        {
                            msg2 = MySellingItem.pricesale.ToString();
                        }
                        else
                        {
                            msg2 = MySellingItem.pricesalemembers.ToString();
                        }
                        if (!msg2.Contains("."))
                        {
                            msg2 += ".00gc";
                        }
                        else if (msg2[msg2.Length - 2] == '.')
                        {
                            msg2 += "0gc";
                        }
                        else
                        {
                            msg2 += "gc";
                        }
                        msg2   = msg2.PadLeft(13, i == 0 ? ' ' : invFiller);
                        msg    = msg + "|" + msg2;
                        msg2   = MyInventoryItem.SqlID.ToString().PadLeft(5, i == 0 ? ' ' : invFiller);
                        msg    = msg + "|" + msg2;
                        Inv[c] = msg;
                        c++;
                        i = 1 - i;
                    }
                }
                int d;
//                for (d = 0; d < c; d++)
//                {
//                    str = Inv[d].Substring(16) + Inv[d].Substring(0, 16);
//                    Inv[d] = str;
//                }
                Array.Sort(Inv);
                i = maxlen + 13;

                string filter = "";
                if (CommandArray.Length > 1)
                {
                    bool firstTime = true;
                    foreach (string filterPart in CommandArray)
                    {
                        if (firstTime)
                        {
                            firstTime = false;
                            continue;
                        }
                        filter += (" " + filterPart);
                    }
                    //filter = Message.Substring(CommandArray[0].Length);
                }
                else
                {
                    filter = "";
                }

                for (d = 0; d < c; d++)
                {
                    str = Inv[d];
                    //27 chars after the name....
                    if (filter == "" || Inv[d].ToLower().Contains(filter.ToLower().Trim()))
                    {
                        string[] outFields = Inv[d].Split('|');
                        string   outString = Inv[d];
                        if (outFields[0].Length > maxlen)
                        {
                            outString = outFields[0].Substring(0, maxlen - 3) + "...";
                            outString = outString.PadRight(maxlen, ' ') + "|".PadRight(7, ' ') + "|".PadRight(14, ' ') + "|".PadRight(6, ' ');
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                            outString = ("[..." + outFields[0].Substring(maxlen - 3).Trim()).PadRight(maxlen, ' ');
                            int count = 0;
                            foreach (string tempString in outFields)
                            {
                                if (count == 0)
                                {
                                    count++;
                                    continue;
                                }
                                outString += "|" + tempString;
                            }
                        }
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                    }
                    else
                    {
                        //for (i = 1; i < CommandArray.Length; i++)
                        {
                            //if (Inv[d].ToLower().Contains(CommandArray[i].ToLower().Trim()))
                            Console.WriteLine("inv(d): " + Inv[d] + " filter: " + filter);
                            if (Inv[d].ToLower().Contains(filter.ToLower().Trim()))
                            {
                                string[] outFields = Inv[d].Split('|');
                                string   outString = Inv[d];
                                if (outFields[0].Length > maxlen)
                                {
                                    outString = outFields[0].Substring(0, maxlen - 3) + "...";
                                    outString = outString.PadRight(maxlen, ' ') + "|".PadRight(14, ' ') + "|".PadRight(9, ' ');
                                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                                    outString = ("[..." + outFields[0].Substring(maxlen - 3).Trim()).PadRight(maxlen, ' ');
                                    foreach (string tempString in outFields)
                                    {
                                        outString += "|" + tempString;
                                    }
                                }
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                                i = CommandArray.Length;
                            }
                        }
                    }
                }

                int Phys  = TheMySqlManager.GetBotPhysqiue(Settings.botid);
                int Coord = TheMySqlManager.GetBotCoordination(Settings.botid);
                int carry = (Phys + Coord) * 10;
                //int UsedSpace = TheMySqlManager.GetBotUsedSpace(Settings.botid);
                //int UsedSlots = TheMySqlManager.GetBotUsedSlots(Settings.botid);
                int UsedSpace = TheStats.MyCurrentCarryingAmt;
                int FreeSpace = carry - UsedSpace;
                str = "[";
                str = str.PadRight(maxlen + 27, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                str  = "[";
                str += FreeSpace.ToString() + " EMU Avail|";
                str += (36 - UsedSlots).ToString() + " Open slot(s)";
                if (rank > 89)
                {
                    //str += TheMySqlManager.moneylevel(Settings.botid).ToString() + " gc";
                    str += "|" + TheInventory.GetMoneyAmount().ToString() + " gc";
                }

                str = str.PadRight(maxlen + 27, ' ');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                str = "[";
                if (Member)
                {
                    if ((CommandArray[0] != "#im" && CommandArray[0] != "#invmembers" && CommandArray[0] != "#invmemvers" && CommandArray[0] != "#invmember" && CommandArray[0] != "#invmemver"))
                    {
                        str = str.PadRight(maxlen + 27, '-');
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                        str = "[Use invmembers (im) to see member prices";
                        str = str.PadRight(maxlen + 27, ' ');
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                    }
                    //if (isinv)
                    //{
                    //    str = "[to see member prices use invmembers or im";
                    //    str = str.PadRight(maxlen + 28, ' ');
                    //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                    //}
                }
                str = "[";
                str = str.PadRight(maxlen + 27, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));

                return;
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #inv command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#inv                                  "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #inv                         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #inv silver ore              "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            return;
        }
Exemple #24
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#ban" ||
                CommandArray[0].ToLower() == "#unban" ||
                CommandArray[0].ToLower() == "#banguild" ||
                CommandArray[0].ToLower() == "#bg" ||
                CommandArray[0].ToLower() == "#unbanguild" ||
                CommandArray[0].ToLower() == "#ug" ||
                CommandArray[0].ToLower() == "#prefer" ||
                CommandArray[0].ToLower() == "#preferguild" ||
                CommandArray[0].ToLower() == "#pg" ||
                CommandArray[0].ToLower() == "#rank"
                )
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#ban", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank(CommandArray[0], Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (CommandArray[0].ToLower() == "#rank")
                {
                    if (CommandArray.Length != 3)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "The " + CommandArray[0].ToLower() + " command requires two parameters, the name and the rank."));
                        return;
                    }
                    TheMySqlManager.UpdatePlayer(CommandArray[1].ToLower(), int.Parse(CommandArray[2]), e.username);
                    return;
                }
                else if (CommandArray.Length != 2)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "The " + CommandArray[0].ToLower() + " command requires one parameter, the name."));
                    return;
                }
                string name = CommandArray[1];
                if (CommandArray[0] == "#ban")
                {
                    TheMySqlManager.UpdatePlayer(name.ToLower(), -1, e.username);
                }
                else if (CommandArray[0] == "#unban")
                {
                    TheMySqlManager.UpdatePlayer(name.ToLower(), 0, e.username);
                }
                else if (CommandArray[0] == "#prefer")
                {
                    TheMySqlManager.UpdatePlayer(name.ToLower(), 1, e.username);
                }
                else if (CommandArray[0] == "#banguild" || CommandArray[0] == "#bg")
                {
                    TheMySqlManager.BanGuild(CommandArray[1], -1, e.username);
                }
                else if (CommandArray[0] == "#unbanguild" || CommandArray[0] == "#ug")
                {
                    TheMySqlManager.BanGuild(CommandArray[1], 0, e.username);
                }
                else if (CommandArray[0] == "#preferguild" || CommandArray[0] == "#pg")
                {
                    TheMySqlManager.BanGuild(CommandArray[1], 1, e.username);
                }
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Command executed."));
            }

            return;
        }
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int nameToID = -1;

            username = e.username;

            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#useitem")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled(CommandArray[0], Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (CommandArray[0] == "#useitem")
                {
                    if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#useitem", Settings.botid))
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                        return;
                    }
                }

                if (TheTradeHandler.AmITrading())
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly."));
                    return;
                }

                if (TheInventory.GettingInventoryItems == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please wait a moment for me to finish getting my inventory..."));
                    return;
                }


                try
                {
                    if (CommandArray.Length < 2)
                    {
                        goto WrongArguments;
                    }
                    string str = "";
                    int    i;
                    for (i = 1; i < CommandArray.Length; i++)
                    {
                        str += CommandArray[i] + " ";
                    }
                    str = str.Trim();
                    if (str == "")
                    {
                        goto WrongArguments;
                    }
                    nameToID = TheMySqlManager.GetItemID(str, Settings.botid, false);
                    if (nameToID == -1)
                    {
                        SQLID = int.Parse(CommandArray[1]);
                    }
                    if (nameToID != -1)
                    {
                        SQLID = nameToID;
                    }
                }
                catch
                {
                    goto WrongArguments;
                }
                username = e.username;
                UseItem(SQLID);
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Usage of the #useitem command:         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|#useitem <item>                        "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #useitem ring of portland     "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            return;
        }
Exemple #26
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#say" || CommandArray[0].ToLower() == "#s")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#say", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#say", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                int i;
                Message = "";

                if (CommandArray.Length < 2)
                {
                    goto WrongArguments;
                }

                for (i = 1; i < CommandArray.Length; i++)
                {
                    Message += CommandArray[i];
                    if (i < CommandArray.Length - 1)
                    {
                        Message += " ";
                    }
                }
                if (Message.ToLower().Contains("#killme") ||
                    Message.ToLower().Contains("#reset") ||
                    Message.ToLower().Contains("#abuse") ||
                    Message.ToLower().Contains("#help_me") ||
                    Message.ToLower().Contains("#suicide") ||
                    Message.ToLower().Contains("#destroy_guild") ||
                    (Message.ToLower().Contains("#beam") && TheMySqlManager.GetUserRank(e.username, Settings.botid) < 100) ||
                    (Message.ToLower().Contains("#change_owner") && TheMySqlManager.GetUserRank(e.username, Settings.botid) < 100))
                {
                    TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#GM " + System.Convert.ToChar(141) + "ALERT " + e.username + " tried to get me to send a prohibited command"));
                    TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#GM " + System.Convert.ToChar(136) + Message));
                }
                else
                {
                    TheTCPWrapper.Send(CommandCreator.RAW_TEXT(Message));
                }
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Here is the usage of the #say command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#say <message>"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "--------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Example: #say Hi, how are You?"));
            return;
        }
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int SQLID    = 0;
            int nameToID = -1;

            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#describe" || (CommandArray[0] == "#d" && CommandArray.Length > 1))
            {
                if (Settings.IsTradeBot == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I am not a trade bot!"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#d", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                try
                {
                    if (CommandArray.Length < 1)
                    {
                        goto WrongArguments;
                    }
                    string str = "", str2 = "";
                    int    i;
                    for (i = 1; i < CommandArray.Length; i++)
                    {
                        str += CommandArray[i] + " ";
                    }
                    str      = str.Trim();
                    nameToID = TheMySqlManager.GetItemID(str, false);
                    if (nameToID == -1)
                    {
                        if (str[0] < '0' || str[0] > '9')
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "description of " + str + " not found"));
                            return;
                        }
                        SQLID = int.Parse(CommandArray[1]);
                    }
                    if (nameToID != -1)
                    {
                        SQLID = nameToID;
                    }

                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Description of " + TheMySqlManager.GetKnownItemsname(SQLID) + " (ID " + SQLID.ToString() + ")"));
                    str = TheMySqlManager.GetDescription(SQLID);
                    i   = str.Length;
                    int v = 158 - e.username.Length;
                    if (e.username.Length + i > v)
                    {
                        while (v > 0 && str[v] != ' ')
                        {
                            v--;
                        }

                        str2 = str.Substring(0, v);
                        v++;
                        if (str2.Length > 0)
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str2.Trim()));
                        }
                        str = str.Substring(v);
                    }
                    str = str.Trim();
                    if (str.Length > 0)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                    }
                    str = TheMySqlManager.GetDescriptionExtra(SQLID).Trim();
                    if (str.Length > 0)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                    }
                }
                catch
                {
                    goto WrongArguments;
                }
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|-------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Here is the usage of the #describe command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|#describe <name or itemid>                 "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|-------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #describe 2                       "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #describe Pickaxe                 "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|-------------------------------------------"));
            return;
        }
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int    UsedSlots = 0;
            string Message   = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            string[] Inv = new string[512];

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#invlist" || CommandArray[0] == "#il")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#invlist", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid);
                if (rank < TheMySqlManager.GetCommandRank("#invlist", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (this.TheTradeHandler.AmITrading() && e.username != TradeHandler.username)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly."));
                    return;
                }

                char invFiller = TheMySqlManager.getInvFiller();

                string str1 = "", str2 = "";
                if (TheInventory.GettingInventoryItems == true)
                {
                    str2 = "I am building my inventory list, please try again in a few seconds";
                    str1 = str1.PadRight(str2.Length, '=');
                    str1 = "[" + str1;
                    str2 = "[" + str2;
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str2));
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));

                    return;
                }
                if (CommandArray.Length < 1)
                {
                    goto WrongArguments;
                }

                System.Collections.ArrayList MyInventoryList    = TheInventory.GetInventoryList();
                System.Collections.Hashtable MySellingItemsList = TheMySqlManager.GetSellingItemList(0);

                // sum up all inventory items if the items are on sale
                int i = 0;
                for (i = 0; i < 512; i++)
                {
                    Inv[i] = "ZZZZZZZZZZZZZZZZ";
                }
                int c = 0;

                System.Collections.SortedList TheInventoryList = new System.Collections.SortedList();
                System.Collections.SortedList TheWornList      = new System.Collections.SortedList();
                int ii = 0;
                foreach (Inventory.inventory_item MyInventoryItem in MyInventoryList)
                {
                    ii++;
                    if (TheInventoryList.Contains(MyInventoryItem.SqlID) && MyInventoryItem.pos < 36)
                    {
//                        if (MyInventoryItem.pos < 36)
                        {
                            Inventory.inventory_item TempInventoryItem = (Inventory.inventory_item)TheInventoryList[MyInventoryItem.SqlID];
                            TempInventoryItem.quantity += MyInventoryItem.quantity;
                            TheInventoryList[MyInventoryItem.SqlID] = TempInventoryItem;
                        }
                    }
                    else
                    {
                        if (MyInventoryItem.pos < 36)
                        {
                            TheInventoryList.Add(MyInventoryItem.SqlID, MyInventoryItem);
                        }
                    }
                    if (MyInventoryItem.pos > 35 && MyInventoryItem.pos < 44)
                    {
                        TheWornList.Add(MyInventoryItem.SqlID, MyInventoryItem);
                    }
                }
                int maxlen = 4;
                foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values)
                {
//                    if (maxlen < MyInventoryItem.name.Length && MyInventoryItem.pos < 44)
                    if (maxlen < MyInventoryItem.name.Length && MyInventoryItem.pos < 36)
                    {
                        maxlen = MyInventoryItem.name.Length;
                    }
                }
                foreach (Inventory.inventory_item MyInventoryItem in TheWornList.Values)
                {
                    if (maxlen <= MyInventoryItem.name.Length + 3)
                    {
                        maxlen = MyInventoryItem.name.Length + 3;
                    }
                }
                str2 = "";
                str1 = "[";
                str1 = str1.PadRight(maxlen + 16, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                str1  = "[ id |";
                str2  = "quantity";
                str2  = str2.PadRight(9, ' ') + "|";
                str1 += str2;
                str2  = "name";
                str2  = str2.PadRight(maxlen, ' ');
                str1  = str1 + str2;
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                str1 = "[";
                str1 = str1.PadRight(maxlen + 16, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                // pm all summed up inventory items on sale
                c = 0;
                i = 1;
                foreach (Inventory.inventory_item MyInventoryItem in TheWornList.Values)
                {
                    if (MyInventoryItem.pos < 44)
                    {
                        if (MyInventoryItem.pos < 36)
                        {
                            if (MyInventoryItem.is_stackable)
                            {
                                UsedSlots++;
                            }
                            else
                            {
                                UsedSlots = UsedSlots + (int)(MyInventoryItem.quantity);
                            }
                        }
                        str1  = "";
                        str2  = "";
                        str2 += MyInventoryItem.SqlID.ToString();
                        str2  = str2.PadLeft(4, i == 0 ? ' ' : invFiller);
                        str2  = "[" + str2 + "|";
                        str1  = MyInventoryItem.quantity.ToString();
                        str1  = str1.PadLeft(9, i == 0 ? ' ' : invFiller);
                        str2 += str1 + "|";
                        if (MyInventoryItem.pos > 35)
                        {
                            str1 = "{E}" + MyInventoryItem.name;
                        }
                        else
                        {
                            str1 = MyInventoryItem.name;
                        }
                        str1 = str1.PadRight(maxlen, i == 0 ? ' ' : invFiller);
                        str1 = str2 + str1;
                        //TradeHandler.SellingItem MySellingItem = (TradeHandler.SellingItem)(MySellingItemsList[MyInventoryItem.SqlID]);
                        //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                        Inv[c++] = str1;
                        //i = 1 - i;
                    }
                }
                foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values)
                {
                    if (MyInventoryItem.pos < 44)
                    {
                        if (MyInventoryItem.pos < 36)
                        {
                            if (MyInventoryItem.is_stackable)
                            {
                                UsedSlots++;
                            }
                            else
                            {
                                UsedSlots = UsedSlots + (int)(MyInventoryItem.quantity);
                            }
                        }
                        str1  = "";
                        str2  = "";
                        str2 += MyInventoryItem.SqlID.ToString();
                        str2  = str2.PadLeft(4, i == 0 ? ' ' : invFiller);
                        str2  = "[" + str2 + "|";
                        str1  = MyInventoryItem.quantity.ToString();
                        str1  = str1.PadLeft(9, i == 0 ? ' ' : invFiller);
                        str2 += str1 + "|";
                        if (MyInventoryItem.pos > 35)
                        {
                            str1 = "{E}" + MyInventoryItem.name;
                        }
                        else
                        {
                            str1 = MyInventoryItem.name;
                        }
                        str1 = str1.PadRight(maxlen, i == 0 ? ' ' : invFiller);
                        str1 = str2 + str1;
                        //TradeHandler.SellingItem MySellingItem = (TradeHandler.SellingItem)(MySellingItemsList[MyInventoryItem.SqlID]);
                        //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                        Inv[c++] = str1;
                        //i = 1 - i;
                    }
                }
                int    d;
                string str;
                for (d = 0; d < c; d++)
                {
                    str    = Inv[d].Substring(16) + Inv[d].Substring(0, 16);
                    Inv[d] = str;
                }
                Array.Sort(Inv);
                i = maxlen + 13;

                string filter = "";
                if (CommandArray.Length > 1)
                {
                    bool firstTime = true;
                    foreach (string filterPart in CommandArray)
                    {
                        if (firstTime)
                        {
                            firstTime = false;
                            continue;
                        }
                        filter += (" " + filterPart);
                    }
                    //filter = Message.Substring(CommandArray[0].Length);
                }
                else
                {
                    filter = "";
                }

                //for (d = c - 1; d >= 0; d--)
                for (d = 0; d < c; d++)
                {
                    i      = Inv[d].Length - 16;
                    str    = Inv[d].Substring(i);
                    str   += Inv[d].Substring(0, i);
                    Inv[d] = str.Substring(str.Length - 16);
                    if (filter == "" || str.ToLower().Contains(filter.ToLower().Trim()))
                    {
                        //string[] outFields = Inv[d].Split('|');
                        //string outString = Inv[d];
                        //if (outFields[0].Length > maxlen)
                        //{
                        //    outString = outFields[0].Substring(0, maxlen - 3) + "...";
                        //    outString = outString.PadRight(maxlen, ' ') + "|".PadRight(14, ' ') + "|".PadRight(9, ' ');
                        //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                        //    outString = "[...".PadRight(maxlen, ' ');
                        //    foreach (string tempString in outFields)
                        //    {
                        //        outString += "|" + tempString;
                        //    }
                        //}
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                    }
                    else
                    {
                        //for (i = 1; i < CommandArray.Length; i++)
                        {
                            if (str.ToLower().Contains(filter.ToLower().Trim()))
                            {
                                //string[] outFields = Inv[d].Split('|');
                                //string outString = Inv[d];
                                //if (outFields[0].Length > maxlen)
                                //{
                                //    outString = outFields[0].Substring(0, maxlen - 3) + "...";
                                //    outString = outString.PadRight(maxlen, ' ') + "|".PadRight(14, ' ') + "|".PadRight(9, ' ');
                                //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                                //    outString = "[...".PadRight(maxlen, ' ');
                                //    foreach (string tempString in outFields)
                                //    {
                                //        outString += "|" + tempString;
                                //    }
                                //}
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                                i = CommandArray.Length;
                            }
                        }
                    }
                }

                int Phys      = TheMySqlManager.GetBotPhysqiue(Settings.botid);
                int Coord     = TheMySqlManager.GetBotCoordination(Settings.botid);
                int carry     = (Phys + Coord) * 10;
                int UsedSpace = TheStats.MyCurrentCarryingAmt;
                int FreeSpace = carry - UsedSpace;
                str1 = "[";
                str1 = str1.PadRight(maxlen + 16, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                str1  = "[";
                str1 += FreeSpace.ToString() + " EMU Avail|";
                str1 += (36 - UsedSlots).ToString() + " Open slot(s)";
                if (rank > 89)
                {
                    str1 += "|" + TheInventory.GetMoneyAmount().ToString() + " gc";
                }

                str1 = str1.PadRight(maxlen + 16, ' ');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));

                str1 = "[";
                str1 = str1.PadRight(maxlen + 16, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));

                return;
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #invlist command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#invlist                                  "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #invlist                         "));
            return;
        }
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            string[] Inv = new string[64];

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');
            if (CommandArray[0] == "#deposit")
            {
                username = e.username;
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#deposit", Settings.botid);


                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid);

                if (rank < TheMySqlManager.GetCommandRank("#deposit", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (CommandArray.Length < 1)
                {
                    goto WrongArguments;
                }

                if (!TradeHandler.storageOpen)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You must open storage first!"));
                    return;
                }

                if (TheInventory.GettingInventoryItems == true || TheInventory.inventoryRequested)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please wait a moment for me to finish getting my inventory..."));
                    return;
                }

                TheTradeHandler.makingDeposit = true;
                //ok, let's do a deposit
                uint   quantity = 0;
                string itemName = "";
                int    SQLID    = -1;

                int    nameToID = -1;
                string str      = "";
                try
                {
                    if (CommandArray.Length < 2)
                    {
                        goto WrongArguments;
                    }
                    if (CommandArray.Length < 3)
                    {
                        quantity = 1;
                        try
                        {
                            SQLID    = int.Parse(CommandArray[1]);
                            nameToID = SQLID;
                        }
                        catch
                        {
                            itemName = CommandArray[1] + " ";
                            nameToID = TheMySqlManager.GetItemID(CommandArray[1], Settings.botid, true);
                        }
                    }
                    if (CommandArray.Length > 2)
                    {
                        int i;
                        try
                        {
                            quantity = uint.Parse(CommandArray[1]);
                            for (i = 2; i < CommandArray.Length; i++)
                            {
                                str += CommandArray[i] + " ";
                            }
                        }
                        catch
                        {
                            quantity = 1;
                            for (i = 1; i < CommandArray.Length; i++)
                            {
                                str += CommandArray[i] + " ";
                            }
                        }
                        finally
                        {
                            str      = str.Trim();
                            nameToID = TheMySqlManager.GetItemID(str, Settings.botid, true);
                            itemName = str + " ";
                        }
                    }
                }
                catch
                {
                    goto WrongArguments;
                }
                finally
                {
                    try
                    {
                        SQLID = int.Parse(str);
                    }
                    catch
                    {
                        SQLID = nameToID;
                    }
                }

                int invCount = 0;
                MyStorageItem = new Storage.StorageItem();
                foreach (Inventory.inventory_item myInventoryItem in TheInventory.GetInventoryList())
                {
                    if (myInventoryItem.SqlID == SQLID)
                    {
                        TheTCPWrapper.Send(CommandCreator.DEPOSIT_ITEM(myInventoryItem.pos, (UInt16)quantity));
                        TheInventory.requestInventory();
                        TheTradeHandler.makingDeposit  = false;
                        TheTradeHandler.depositMade    = true;
                        MyStorageItem.knownItemsID     = myInventoryItem.SqlID;
                        MyStorageItem.imageid          = myInventoryItem.imageid;
                        MyStorageItem.category_num     = -1;
                        MyStorageItem.name             = myInventoryItem.name;
                        MyStorageItem.reservedQuantity = 0;
                        MyStorageItem.name             = myInventoryItem.name;
                        break;
                    }
                    invCount++;
                }
                if (!TheTradeHandler.depositMade)
                {
                    TheTradeHandler.makingDeposit = false;
                    string outputString = "I don't seem to have any " + itemName + " in inventory!";
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outputString));
                }
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #deposit command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#deposit amt item                         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #deposit 1 silver ore            "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            return;
        }
Exemple #30
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#donate" || CommandArray[0] == "#donation" || (CommandArray[0] == "#d" && CommandArray.Length == 1))
            {
                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#donate", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#donate", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (Settings.IsTradeBot == false && TheTradeHandler.storageAvailable == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I am not a trade bot!"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#donate", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheTradeHandler.Trading == false || TradeHandler.username.ToLower() != e.username.ToLower())
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please trade with me first!"));
                    return;
                }

                if (TheTradeHandler.storageAvailable == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Items will be put in my inventory."));
                    TheTradeHandler.storageAvailable = false;
                }

                try
                {
                    if (CommandArray.Length != 1 && CommandArray[1] != "")
                    {
                        goto WrongArguments;
                    }

                    if (TheTradeHandler.PutOnSale == false && TheTradeHandler.Billance == 0 && TheTradeHandler.PartnerTradeItemsList.Count == 0 && TheTradeHandler.MyItemList.Count == 0)
                    {
                        TheTradeHandler.Donating = true;
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You can donate to me now."));
//                        if (Settings.IsTradeBot == false)
//                        {
//                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Move me away from storage if you want to donate into my inventory..."));
//                        }
                    }
                    else
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Plese restart the trade. And put no items on the trade before sending #donate."));
                    }
                }
                catch
                {
                    goto WrongArguments;
                }
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Here is the usage of the #donate command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#donate"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Example: #donate"));
            return;
        }