示例#1
0
        public override bool replyReceived(ExpectedReply e, message m, bool messageFailed = false)
        {
            bool processed = false;
            chat c         = Roboto.Settings.getChat(e.chatID);
            mod_steam_chat_data chatData = c.getPluginData <mod_steam_chat_data>();

            //Adding a player to the chat. We should have a player ID in our message.
            if (e.messageData == "ADDPLAYER")
            {
                long playerID = -1;
                if (long.TryParse(m.text_msg, out playerID) && playerID >= -1)
                {
                    //get the steam profile
                    mod_steam_player player = mod_steam_steamapi.getPlayerInfo(playerID, c.chatID);

                    if (player.isPrivate)
                    {
                        TelegramAPI.SendMessage(c.chatID, "Couldn't add " + player.playerName + " as their profile is set to private", m.userFullName, false, m.message_id);
                    }
                    else
                    {
                        chatData.addPlayer(player);
                        TelegramAPI.SendMessage(c.chatID, "Added " + player.playerName + ". Any steam achievements will be announced.", m.userFullName, false, m.message_id);
                    }
                }
                else if (m.text_msg.ToUpper() != "CANCEL")
                {
                    TelegramAPI.GetExpectedReply(m.chatID, m.userID, m.text_msg + " is not a valid playerID. Enter a valid playerID or 'Cancel'", false, typeof(mod_steam), "ADDPLAYER", m.userFullName, m.message_id, true);
                }
                processed = true;
            }
            else if (e.messageData == "REMOVEPLAYER")
            {
                bool success = chatData.removePlayer(m.text_msg);

                if (success)
                {
                    TelegramAPI.SendMessage(c.chatID, "Player " + m.text_msg + " removed.", m.userFullName, false, m.message_id, true);
                }
                else
                {
                    TelegramAPI.SendMessage(c.chatID, "Sorry, something went wrong removing " + m.text_msg, m.userFullName, false, m.message_id, true);
                }
                processed = true;
            }
            return(processed);
        }
示例#2
0
        public static mod_steam_player getPlayerInfo(long playerID, long chatID)
        {
            NameValueCollection pairs = new NameValueCollection();

            pairs["steamids"] = playerID.ToString();
            JObject response = sendPOST(@"/ISteamUser/GetPlayerSummaries/v0002/", pairs);


            if (response != null)
            {
                //mangle this into a player object
                string playerName = "";
                bool   isPrivate  = false;
                try
                {
                    //get the message details
                    playerName = response.SelectToken("response.players[0].personaname").Value <string>();
                    int communityvisibilitystate = response.SelectToken("response.players[0].communityvisibilitystate").Value <int>();
                    if (communityvisibilitystate == 1)
                    {
                        Console.WriteLine(playerName + " is set to private");
                        isPrivate = true;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error parsing message " + e.ToString());
                }

                mod_steam_player player = new mod_steam_player(chatID, playerID.ToString(), playerName, isPrivate);
                return(player);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
 public void addPlayer(mod_steam_player player)
 {
     players.Add(player);
 }
示例#4
0
        public static mod_steam_player getPlayerInfo(long playerID, long chatID)
        {
            NameValueCollection pairs = new NameValueCollection();
            pairs["steamids"] = playerID.ToString();
            JObject response = sendPOST(@"/ISteamUser/GetPlayerSummaries/v0002/", pairs);

            if (response != null)
            {
                //mangle this into a player object
                string playerName = "";
                bool isPrivate = false;
                try
                {
                    //get the message details
                    playerName = response.SelectToken("response.players[0].personaname").Value<string>();
                    int communityvisibilitystate = response.SelectToken("response.players[0].communityvisibilitystate").Value<int>();
                    if (communityvisibilitystate == 1)
                    {
                        Console.WriteLine(playerName + " is set to private");
                        isPrivate = true;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error parsing message " + e.ToString());

                }

                mod_steam_player player = new mod_steam_player(chatID, playerID.ToString(), playerName, isPrivate);
                return player;

            }
            else return null;
        }
示例#5
0
 public void addPlayer(mod_steam_player player)
 {
     players.Add(player);
 }