예제 #1
0
        public override string getStats()
        {
            int playersTracked = 0;
            int achieves       = 0;
            int playerAchieves = 0;

            foreach (chat c in Roboto.Settings.chatData)
            {
                mod_steam_chat_data cd = c.getPluginData <mod_steam_chat_data>();
                if (cd != null)
                {
                    playersTracked += cd.players.Count;
                    foreach (mod_steam_player p in cd.players)
                    {
                        playerAchieves += p.chievs.Count;
                    }
                }
            }


            foreach (mod_steam_game g in localData.games)
            {
                achieves += g.chievs.Count;
            }

            string result = "Tracking " + playersTracked.ToString() + " players" + "\n\r" +
                            playerAchieves.ToString() + " player achievements known" + "\n\r" +
                            localData.games.Count.ToString() + " games and " + achieves.ToString() + " achievements cached";

            return(result);
        }
예제 #2
0
        public override void initChatData(chat c)
        {
            mod_steam_chat_data chatData = c.getPluginData <mod_steam_chat_data>();

            if (chatData == null)
            {
                //Data doesnt exist, create, populate with sample data and register for saving
                chatData = new mod_steam_chat_data();
                c.addChatData(chatData);
            }
        }
예제 #3
0
        /// <summary>
        /// checks the players in the chat, if neccessary, for new achievs.
        /// </summary>
        /// <param name="c"></param>
        private void checkChat(chat c)
        {
            mod_steam_chat_data localData = c.getPluginData <mod_steam_chat_data>();

            if (localData != null)
            {
                foreach (mod_steam_player player in localData.players)
                {
                    player.checkAchievements();
                }
            }
        }
예제 #4
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);
        }
예제 #5
0
        public override bool chatEvent(message m, chat c = null)
        {
            bool processed = false;

            if (c != null)
            {
                mod_steam_chat_data chatData = (mod_steam_chat_data)c.getPluginData(typeof(mod_steam_chat_data));


                if (m.text_msg.StartsWith("/steam_addplayer"))
                {
                    TelegramAPI.GetExpectedReply(c.chatID, m.userID
                                                 , "Enter the steamID of the player you want to add. /steam_help to find out how to get this."
                                                 , false
                                                 , typeof(mod_steam)
                                                 , "ADDPLAYER", m.userFullName, m.message_id, true);
                    processed = true;
                }
                else if (m.text_msg.StartsWith("/steam_help"))
                {
                    TelegramAPI.SendMessage(m.chatID, "You are looking for an ID from the Steam Community site, try http://steamcommunity.com/ and find your profile. You should have something like http://steamcommunity.com/profiles/01234567890132456 . Take this number on the end of the URL."
                                            , m.userFullName, false, m.message_id);
                    processed = true;
                }
                else if (m.text_msg.StartsWith("/steam_check"))
                {
                    checkChat(c);

                    processed = true;
                }
                else if (m.text_msg.StartsWith("/steam_stats"))
                {
                    string announce = "Currently watching achievements from the following players: " + "\n\r";
                    foreach (mod_steam_player p in chatData.players)
                    {
                        announce += "*" + p.playerName + "* - " + p.chievs.Count().ToString() + " known achievements" + "\n\r";
                    }
                    int achievements = 0;
                    foreach (mod_steam_game g in localData.games)
                    {
                        achievements += g.chievs.Count();
                    }
                    announce += "Tracking " + achievements.ToString() + " achievements across " + localData.games.Count().ToString() + " games";

                    TelegramAPI.SendMessage(m.chatID, announce, m.userFullName, true, m.message_id);
                }


                else if (m.text_msg.StartsWith("/steam_remove"))
                {
                    List <string> playerKeyboard = new List <string>();
                    foreach (mod_steam_player p in chatData.players)
                    {
                        playerKeyboard.Add(p.playerName);
                    }
                    playerKeyboard.Add("Cancel");
                    string playerKeyboardText = TelegramAPI.createKeyboard(playerKeyboard, 2);
                    TelegramAPI.GetExpectedReply(c.chatID, m.userID, "Which player do you want to stop tracking?", false, typeof(mod_steam), "REMOVEPLAYER", m.userFullName, m.message_id, true, playerKeyboardText);
                }
            }
            return(processed);
        }
예제 #6
0
        public override void initChatData(chat c)
        {
            mod_steam_chat_data chatData = c.getPluginData<mod_steam_chat_data>();

            if (chatData == null)
            {
                //Data doesnt exist, create, populate with sample data and register for saving
                chatData = new mod_steam_chat_data();
                c.addChatData(chatData);
            }
        }