Пример #1
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            if (message == "LIST" && Bot.MySteamID.Contains(OtherSID.ToString()))
            {
                List <long> contextId = new List <long>();
                contextId.Add(2);
                Bot.mySteamInventory.load(Bot.BotGameUsage, contextId, Bot.SteamClient.SteamID);

                SendChatMessage("My inventory (" + Bot.BotGameUsage + ") contain " + Bot.mySteamInventory.items.Count + " item(s) !");
                foreach (KeyValuePair <ulong, GenericInventory.Item> item in Bot.mySteamInventory.items)
                {
                    SteamTrade.GenericInventory.ItemDescription description = Bot.mySteamInventory.getDescription(item.Key);
                    SendChatMessage(description.name + " in game " + Bot.mySteamInventory.items[item.Key].appid);
                }
            }
            else if (message == "TCP" && Bot.MySteamID.Contains(OtherSID.ToString()))
            {
                ThreadState state = Bot.StartListening.ThreadState;
                SendChatMessage(state.ToString());
            }
            else if (message.StartsWith("EXEC") && Bot.MySteamID.Contains(OtherSID.ToString()))
            {
                message = message.Replace("EXEC", "");
                string[] cmd = message.Split(' ');
                if (cmd.Length >= 2)
                {
                    string command = "";
                    for (int i = 2; i < cmd.Length; i++)
                    {
                        command += cmd[i] + " ";
                    }
                    command.Remove(command.Length - 1);

                    if (Bot.SendCommandToServer(Int32.Parse(cmd[1]), command))
                    {
                        SendChatMessage("Executed '" + command + "' on server id '" + cmd[1] + "' !");
                    }
                    else
                    {
                        SendChatMessage("Wrong server ID, use 'SERVERLIST' to get the server ID.");
                    }
                }
                else
                {
                    SendChatMessage("Usage : EXEC [serverid] [command]");
                    SendChatMessage("Exemple : EXEC 0 sm_test 1 2 3");
                }
            }
            else if (message == "SERVERLIST" && Bot.MySteamID.Contains(OtherSID.ToString()))
            {
                List <string> existingServer = new List <string>();
                SendChatMessage("Number of connection : " + Bot.socket.Clients.Count);
                SendChatMessage("Server ID   Server name");
                for (int i = 0; i < Bot.socket.Clients.Count; i++)
                {
                    if (!existingServer.Contains(Bot.socket.Clients[i].Name) && Bot.socket.Clients[i].clientSocket.Connected)
                    {
                        SendChatMessage(i + "             " + Bot.socket.Clients[i].Name);
                        existingServer.Add(Bot.socket.Clients[i].Name);
                    }
                }
                SendChatMessage("-----------------------");
            }
            else
            {
                SendChatMessage(Bot.chatbotSession.Think(message));
            }
        }