Пример #1
0
        static void OnFriendsList(SteamFriends.FriendsListCallback callback)
        {
            // at this point, the client has received it's friends list

            int friendCount = steamFriends.GetFriendCount();

            Console.WriteLine("We have {0} friends", friendCount);

            for (int x = 0; x < friendCount; x++)
            {
                // steamids identify objects that exist on the steam network, such as friends, as an example
                SteamID steamIdFriend = steamFriends.GetFriendByIndex(x);

                // we'll just display the STEAM_ rendered version
                Console.WriteLine("Friend: {0}", steamIdFriend.Render());
            }

            // we can also iterate over our friendslist to accept or decline any pending invites

            foreach (var friend in callback.FriendList)
            {
                if (friend.Relationship == EFriendRelationship.RequestRecipient)
                {
                    // this user has added us, let's add him back
                    steamFriends.AddFriend(friend.SteamID);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Add the user to the friendslist
        /// Invite the user to our group and the group passed by the admin
        /// Allowed string passed by admin: group url, groupID32 and groupID64, groupID64 is prefered because of error measures
        /// If a url is passed, so get the groupID64 from the grouppage
        /// groupID32 will be converted into a groupID64
        /// Welcome the user to the service and tell him we invited him to our Group
        /// </summary>
        /// <param name="_steamFriends"></param>
        /// <param name="_friendSteamID"></param>
        /// <param name="_groupID"></param>
        /// <param name="_steamUserWebAPI"></param>
        public async Task AcceptFriendRequestAndInviteToGroup(SteamFriends _steamFriends, SteamID _friendSteamID, SteamUserWebAPI _steamUserWebAPI, string _groupID = "")
        {
            _steamFriends.AddFriend(_friendSteamID);

            for (int i = 0; i < _steamFriends.GetClanCount(); i++)
            {
                SteamID groupID = _steamFriends.GetClanByIndex(i);
                if (groupID.ConvertToUInt64().Equals(103582791458407475) && _steamFriends.GetClanName(groupID).ToUpper().Contains("XETAS"))
                {
                    await _steamUserWebAPI.InviteToGroup(groupID.ToString(), _friendSteamID.ConvertToUInt64().ToString()).ConfigureAwait(false);
                }

                if (!string.IsNullOrEmpty(_groupID))
                {
                    string groupID64;
                    if (_groupID.Contains("steamcommunity") && _groupID.Contains("groups"))
                    {
                        groupID64 = await _steamUserWebAPI.GetGroupIDFromGroupAdress(_groupID).ConfigureAwait(false);
                    }
                    else
                    {
                        groupID64 = GetGroupID64String(_groupID);
                    }

                    await _steamUserWebAPI.InviteToGroup(groupID64, _friendSteamID.ConvertToUInt64().ToString()).ConfigureAwait(false);
                }
            }

            _steamFriends.SendChatMessage(_friendSteamID, EChatEntryType.ChatMsg, "Hello and welcome to my Service!" +
                                          "\nI've invited you to my group, where you can check the other bots or get to learn and trade with other steamusers." +
                                          "\nYou can type !c or !commands to see all available commands.");
        }
Пример #3
0
        private void OnFriendsList(SteamFriends.FriendsListCallback callback)
        {
            if (callback == null)
            {
                return;
            }

            foreach (var friend in callback.FriendList)
            {
                if (friend.Relationship != EFriendRelationship.RequestRecipient)
                {
                    continue;
                }

                SteamID steamID = friend.SteamID;
                switch (steamID.AccountType)
                {
                case EAccountType.Clan:
                    //ArchiHandler.AcceptClanInvite(steamID);
                    break;

                default:
                    if (steamID == SteamMasterID)
                    {
                        SteamFriends.AddFriend(steamID);
                    }
                    else
                    {
                        SteamFriends.RemoveFriend(steamID);
                    }
                    break;
                }
            }
        }
Пример #4
0
 static void OnFriendList(SteamFriends.FriendsListCallback callback)
 {
     foreach (var friend in callback.FriendList)
     {
         if (friend.Relationship == EFriendRelationship.RequestRecipient)
         {
             steamFriends.AddFriend(friend.SteamID);
         }
     }
 }
Пример #5
0
 private void OnSteamFriendsList(SteamFriends.FriendsListCallback callback)
 {
     //List of friends received, accept all friend requests
     foreach (var friend in callback.FriendList)
     {
         if (friend.Relationship == EFriendRelationship.RequestRecipient)
         {
             m_steamFriends.AddFriend(friend.SteamID);
         }
     }
 }
Пример #6
0
        void OnFriendsList(SteamFriends.FriendsListCallback callback)         // Получаем список друзей в аккаунте бота
        {
            foreach (var friend in callback.FriendList)
            {
                Console.WriteLine($"Друзья: {friend.SteamID}");

                if (friend.Relationship == EFriendRelationship.RequestRecipient)
                {
                    steamFriends.AddFriend(friend.SteamID);
                }
            }
        }
Пример #7
0
        private void OnFriendsList(SteamFriends.FriendsListCallback callback)
        {
            Console.WriteLine("Getting Friends List...");

            foreach (var friend in callback.FriendList)
            {
                if (friend.Relationship == EFriendRelationship.RequestRecipient)
                {
                    Console.WriteLine("Adding Friend {0}.", friend.SteamID);
                    SteamFriends.AddFriend(friend.SteamID);
                }
            }
        }
Пример #8
0
        static void onFriendList(SteamFriends.FriendsListCallback callback)
        {
            int friendCount = steamFriends.GetFriendCount();

            Console.WriteLine("You have {0} friends", friendCount);

            foreach (var friend in callback.FriendList)
            {
                if (friend.Relationship == EFriendRelationship.RequestRecipient)
                {
                    steamFriends.AddFriend(friend.SteamID);
                }
            }
        }
Пример #9
0
 static void OnFriendList(SteamFriends.FriendsListCallback callback)
 {
     Thread.Sleep(3000);
     foreach (var friend in callback.FriendList)
     {
         if (friend.Relationship == EFriendRelationship.RequestRecipient)
         {
             steamFriends.AddFriend(friend.SteamID);
             Console.WriteLine("Accepted friend request of " + steamFriends.GetFriendPersonaName(friend.SteamID));
             Thread.Sleep(500);
             steamFriends.SendChatMessage(friend.SteamID, EChatEntryType.ChatMsg, "Nice to meet you! I am a steam bot");
         }
     }
 }
Пример #10
0
        private void OnFriendsList(SteamFriends.FriendsListCallback callback)
        {
            Console.WriteLine($"We have {SteamFriends.GetFriendCount()} friends");

            foreach (var friend in callback.FriendList)
            {
                SteamID steamIdFriend = friend.SteamID;
                if (friend.Relationship == EFriendRelationship.RequestRecipient)
                {
                    SteamFriends.AddFriend(steamIdFriend);
                }
                Console.WriteLine($"Friend: {steamIdFriend.Render()}");
            }
        }
Пример #11
0
 static void OnFriendsList(SteamFriends.FriendsListCallback callback)
 {
     //We need to make the program sleep for a little bit so it has time to cache all the names, if you don't add this part strange things will happen.
     Thread.Sleep(2500);
     Random timing      = new Random();
     int    nexttime    = timing.Next(30, 60);
     Random rnd         = new Random();
     Random who         = new Random();
     var    friendtimer = new System.Threading.Timer((e) => {
         List <SteamID> ids = new List <SteamID> ();
         int count          = 0;
         nexttime           = timing.Next(45, 75);
         //here we will create a foreach loop that will go through our callback.FriendsList and check to see if one of the friends is really someone who wants to be our friend
         //and if so, to add them
         //var is basically a variable declaration for something you don't know will be.
         foreach (var friend in callback.FriendList)
         {
             //checks our friend relationship to check if they sent a friend request and aren't just a friend already on the list.
             if (friend.Relationship == EFriendRelationship.RequestRecipient)
             {
                 //Adds a friend based on their SteamID, because that is how steam friending works
                 steamFriends.AddFriend(friend.SteamID);
                 //Sleep half a second, not necessary but is nice.
                 Thread.Sleep(500);
                 //Notify the user that you are now friends to a bot.
                 steamFriends.SendChatMessage(friend.SteamID, EChatEntryType.ChatMsg, "Ahoy friendo!");
             }
             if (friend.Relationship == EFriendRelationship.Friend)
             {
                 ids.Add(friend.SteamID);
                 ++count;
             }
         }
         string rand   = rLine [rnd.Next(rLine.Count)];
         SteamID newid = ids.ElementAt(who.Next(ids.Count));
         Console.WriteLine(steamFriends.GetFriendPersonaName(newid));
         Console.WriteLine(steamFriends.GetFriendPersonaState(newid));
         Console.WriteLine(DateTime.Now);
         if (steamFriends.GetFriendPersonaState(newid) == EPersonaState.Online || steamFriends.GetFriendPersonaState(newid) == EPersonaState.Away)
         {
             Console.WriteLine(rand);
             steamFriends.SendChatMessage(newid, EChatEntryType.ChatMsg, rand);                      //if so, respond with the response listed in chat.txt
         }
     }, null, 0, 1 * 60 * 1000);
 }
Пример #12
0
 private static void OnFriendsList(SteamFriends.FriendsListCallback obj)
 {
     foreach (var friend in obj.FriendList)
     {
         if (friend.Relationship == EFriendRelationship.Friend)
         {
             if (!listFriendsSteamID.Contains(friend.SteamID))
             {
                 listFriendsSteamID.Add(friend.SteamID);
             }
         }
         if (friend.Relationship == EFriendRelationship.RequestRecipient)
         {
             steamFriends.AddFriend(friend.SteamID);
             steamFriends.SendChatMessage(friend.SteamID, EChatEntryType.ChatMsg, "Olá você pode ver meus comandos digitando @help");
         }
     }
 }
Пример #13
0
 private static void OnFriendList(SteamFriends.FriendsListCallback obj)
 {
     Thread.Sleep(2500);
     foreach (var friend in obj.FriendList)
     {
         if (friend.Relationship == EFriendRelationship.RequestRecipient)
         {
             Console.Write("\t\tFriend added ");
             Console.ForegroundColor = ConsoleColor.Blue;
             Console.WriteLine(_steamFriends.GetFriendPersonaName(friend.SteamID));
             Console.ResetColor();
             _steamFriends.AddFriend(friend.SteamID);
             Thread.Sleep(1000);
             _steamFriends.SendChatMessage(friend.SteamID, EChatEntryType.ChatMsg,
                                           "Hi. I am a HourBoosting , Reporting and commending Bot. Please un-friend me when u are done. You can use !help for help.");
         }
     }
 }
Пример #14
0
        internal async void OnFriendList(SteamFriends.FriendsListCallback callback)
        {
            if (!callback.FriendList.Any())
            {
                return;
            }
            foreach (var friend in callback.FriendList)
            {
                if (friend.Relationship == EFriendRelationship.RequestRecipient)
                {
                    steamFriends.AddFriend(friend.SteamID);
                    Log(steamFriends.GetFriendPersonaName(friend.SteamID) + " was added to friends list", LogType.Info);
                }

                /*
                 * if (friend.SteamID.IsIndividualAccount) // Friend list
                 *  FriendList.Add(friend.SteamID);
                 */
            }
        }
Пример #15
0
        static void OnFriendsList(SteamFriends.FriendsListCallback callback)
        {
            int friendCount = steamFriends.GetFriendCount();

            Console.WriteLine($"[SteamBot] Bot has {0} friends", friendCount);

            for (int x = 0; x < friendCount; x++)
            {
                SteamID steamIdFriend = steamFriends.GetFriendByIndex(x);

                Console.WriteLine($"[SteamBot] Friend: {0}", steamIdFriend.Render());
            }


            foreach (var friend in callback.FriendList)
            {
                if (friend.Relationship == EFriendRelationship.RequestRecipient)
                {
                    steamFriends.AddFriend(friend.SteamID);
                }
            }
        }
Пример #16
0
        static void OnFriendsList(SteamFriends.FriendsListCallback callback)
        {
            // at this point, the client has received it's friends list

            int friendCount = steamFriends.GetFriendCount();

            Console.WriteLine("We have {0} friends", friendCount);

            for (int x = 0; x < friendCount; x++)
            {
                // steamids identify objects that exist on the steam network, such as friends, as an example
                SteamID steamIdFriend = steamFriends.GetFriendByIndex(x);


                AccountController.getAccount(user).AddFriend(new Friend()
                {
                    steamFrindsID = "" + steamIdFriend.ConvertToUInt64().ToString(), chatLog = new ArrayList(), SteamIDObject = steamIdFriend
                });

                // we'll just display the STEAM_ rendered version
                Console.WriteLine("Friend: {0}", steamIdFriend.Render());
            }

            // we can also iterate over our friendslist to accept or decline any pending invites
            if (SteamTwoProperties.jsonSetting.autoAddFriendSetting)
            {
                foreach (var friend in callback.FriendList)
                {
                    if (friend.Relationship == EFriendRelationship.RequestRecipient)
                    {
                        // this user has added us, let's add him back
                        steamFriends.AddFriend(friend.SteamID);
                    }
                }
            }
        }
Пример #17
0
        static void OnChatMessage(SteamFriends.FriendMsgCallback callback)
        {
            string[] args;

            if (callback.EntryType == EChatEntryType.ChatMsg)
            {
                if (callback.Message.Length > 1)
                {
                    //"!"
                    if (callback.Message.Remove(1) == "!")
                    {
                        string command = callback.Message;
                        if (callback.Message.Contains(" ")) //!help
                        {
                            command = callback.Message.Remove(callback.Message.IndexOf(' '));
                        }

                        switch (command)
                        {
                            #region send
                        case "!send":     //!send friendname message
                            if (!isBotAdmin(callback.Sender))
                            {
                                break;
                            }
                            args = seperate(2, ' ', callback.Message);     //args[0] = !send, args[1] = friendname, args[2] = message, args[3-4] = null;
                            Console.WriteLine("!send " + args[1] + args[2] + " command recieved. User: "******"-1")
                            {
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Command syntax: !send [friend] [message]");
                                return;
                            }
                            for (int i = 0; i < steamFriends.GetFriendCount(); i++)
                            {
                                SteamID friend = steamFriends.GetFriendByIndex(i);
                                if (steamFriends.GetFriendPersonaName(friend).ToLower().Contains(args[1].ToLower()))     //bob dylan !send bob message or !send dylan message
                                {
                                    steamFriends.SendChatMessage(friend, EChatEntryType.ChatMsg, args[2]);
                                }
                            }
                            break;

                            #endregion
                            #region friends
                        case "!friends":
                            Console.WriteLine("!friends command recieved. User: "******"Friend: " + steamFriends.GetFriendPersonaName(friend) + "  State: " + steamFriends.GetFriendPersonaState(friend));
                            }
                            break;

                            #endregion
                            #region friend
                        case "!friend":
                            args = seperate(1, ' ', callback.Message);
                            Console.WriteLine("!friend " + args[1] + " | " + steamFriends.GetFriendPersonaName(Convert.ToUInt64(args[1])) + " command recieved. User: "******"-1")
                            {
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Command syntax: !friend [SteamID64]");
                                return;
                            }
                            try
                            {
                                SteamID validSID = Convert.ToUInt64(args[1]);
                                if (!validSID.IsValid)
                                {
                                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Invalid SteamID");     //no person exists with that SID
                                    break;
                                }
                                steamFriends.AddFriend(validSID.ConvertToUInt64());
                            }
                            catch (FormatException)
                            {
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Invalid SteamID64.");
                            }
                            break;

                            #endregion
                            #region changename
                        case "!changename":
                            #region theusualstuff
                            if (!isBotAdmin(callback.Sender))
                            {
                                return;
                            }
                            args = seperate(1, ' ', callback.Message);
                            Console.WriteLine("!changename " + args[1] + " command recieved. User: "******"-1")
                            {
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Syntax: !changename [name]");
                                return;
                            }
                            #endregion
                            steamFriends.SetPersonaName(args[1]);
                            break;

                            #endregion
                            #region reloadconfig
                        case "!reloadconfig":
                            if (isBotAdmin(callback.Sender))
                            {
                                return;
                            }
                            reloadConfig();
                            break;

                            #endregion
                        default:
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Unknown Comand!");
                            break;
                        }
                        return;
                    }
                }
                if (!config.Chatty)
                {
                    return;
                }
                string rLine;
                string trimmed = callback.Message;
                char[] trim    = { '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+', '[', ']', '{', '}', '\\', '|', ';', ':', '"', '\'', ',', '<', '.', '>', '/', '?' };

                for (int i = 0; i < 30; i++)
                {
                    trimmed = trimmed.Replace(trim[i].ToString(), "");
                }

                StreamReader sReader = new StreamReader("chat.txt");

                while ((rLine = sReader.ReadLine()) != null)
                {
                    string text     = rLine.Remove(rLine.IndexOf('|') - 1);
                    string response = rLine.Remove(0, rLine.IndexOf('|') + 2);

                    if (callback.Message.ToLower().Contains(text.ToLower()))
                    {
                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, response);
                        sReader.Close();
                        return;
                    }
                }
            }
        }
Пример #18
0
        void HandleSteamMessage(ICallbackMsg msg)
        {
            Log.Debug(msg.ToString());
            #region Login
            msg.Handle <SteamClient.ConnectedCallback> (callback =>
            {
                Log.Debug("Connection Callback: {0}", callback.Result);

                if (callback.Result == EResult.OK)
                {
                    UserLogOn();
                }
                else
                {
                    Log.Error("Failed to connect to Steam Community, trying again...");
                    SteamClient.Connect();
                }
            });

            msg.Handle <SteamUser.LoggedOnCallback> (callback =>
            {
                Log.Debug("Logged On Callback: {0}", callback.Result);

                if (callback.Result == EResult.OK)
                {
                    myUserNonce = callback.WebAPIUserNonce;
                }
                else
                {
                    Log.Error("Login Error: {0}", callback.Result);
                }

                if (callback.Result == EResult.AccountLogonDenied)
                {
                    Log.Interface("This account is SteamGuard enabled. Enter the code via the `auth' command.");

                    // try to get the steamguard auth code from the event callback
                    var eva = new SteamGuardRequiredEventArgs();
                    FireOnSteamGuardRequired(eva);
                    if (!String.IsNullOrEmpty(eva.SteamGuard))
                    {
                        logOnDetails.AuthCode = eva.SteamGuard;
                    }
                    else
                    {
                        logOnDetails.AuthCode = Console.ReadLine();
                    }
                }

                if (callback.Result == EResult.InvalidLoginAuthCode)
                {
                    Log.Interface("The given SteamGuard code was invalid. Try again using the `auth' command.");
                    logOnDetails.AuthCode = Console.ReadLine();
                }
            });

            msg.Handle <SteamUser.LoginKeyCallback> (callback =>
            {
                myUniqueId = callback.UniqueID.ToString();

                UserWebLogOn();

                if (Trade.CurrentSchema == null)
                {
                    Log.Info("Downloading Schema...");
                    Trade.CurrentSchema = Schema.FetchSchema(ApiKey, schemaLang);
                    Log.Success("Schema Downloaded!");
                }

                SteamFriends.SetPersonaName(DisplayNamePrefix + DisplayName);
                SteamFriends.SetPersonaState(EPersonaState.Online);

                Log.Success("Steam Bot Logged In Completely!");

                GetUserHandler(SteamClient.SteamID).OnLoginCompleted();
            });

            msg.Handle <SteamUser.WebAPIUserNonceCallback>(webCallback =>
            {
                Log.Debug("Received new WebAPIUserNonce.");

                if (webCallback.Result == EResult.OK)
                {
                    myUserNonce = webCallback.Nonce;
                    UserWebLogOn();
                }
                else
                {
                    Log.Error("WebAPIUserNonce Error: " + webCallback.Result);
                }
            });

            msg.Handle <SteamUser.UpdateMachineAuthCallback>(
                authCallback => OnUpdateMachineAuthCallback(authCallback)
                );
            #endregion

            #region Friends
            msg.Handle <SteamFriends.FriendsListCallback>(callback =>
            {
                foreach (SteamFriends.FriendsListCallback.Friend friend in callback.FriendList)
                {
                    switch (friend.SteamID.AccountType)
                    {
                    case EAccountType.Clan:
                        if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            if (GetUserHandler(friend.SteamID).OnGroupAdd())
                            {
                                AcceptGroupInvite(friend.SteamID);
                            }
                            else
                            {
                                DeclineGroupInvite(friend.SteamID);
                            }
                        }
                        break;

                    default:
                        CreateFriendsListIfNecessary();
                        if (friend.Relationship == EFriendRelationship.None)
                        {
                            friends.Remove(friend.SteamID);
                            GetUserHandler(friend.SteamID).OnFriendRemove();
                            RemoveUserHandler(friend.SteamID);
                        }
                        else if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            if (GetUserHandler(friend.SteamID).OnFriendAdd())
                            {
                                if (!friends.Contains(friend.SteamID))
                                {
                                    friends.Add(friend.SteamID);
                                }
                                else
                                {
                                    Log.Error("Friend was added who was already in friends list: " + friend.SteamID);
                                }
                                SteamFriends.AddFriend(friend.SteamID);
                            }
                            else
                            {
                                SteamFriends.RemoveFriend(friend.SteamID);
                                RemoveUserHandler(friend.SteamID);
                            }
                        }
                        break;
                    }
                }
            });


            msg.Handle <SteamFriends.FriendMsgCallback> (callback =>
            {
                EChatEntryType type = callback.EntryType;

                if (callback.EntryType == EChatEntryType.ChatMsg)
                {
                    Log.Info("Chat Message from {0}: {1}",
                             SteamFriends.GetFriendPersonaName(callback.Sender),
                             callback.Message
                             );
                    GetUserHandler(callback.Sender).OnMessageHandler(callback.Message, type);
                }
            });
            #endregion

            #region Group Chat
            msg.Handle <SteamFriends.ChatMsgCallback>(callback =>
            {
                GetUserHandler(callback.ChatterID).OnChatRoomMessage(callback.ChatRoomID, callback.ChatterID, callback.Message);
            });
            #endregion

            #region Trading
            msg.Handle <SteamTrading.SessionStartCallback> (callback =>
            {
                bool started = HandleTradeSessionStart(callback.OtherClient);

                if (!started)
                {
                    Log.Error("Could not start the trade session.");
                }
                else
                {
                    Log.Debug("SteamTrading.SessionStartCallback handled successfully. Trade Opened.");
                }
            });

            msg.Handle <SteamTrading.TradeProposedCallback> (callback =>
            {
                if (CheckCookies() == false)
                {
                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }

                try
                {
                    tradeManager.InitializeTrade(SteamUser.SteamID, callback.OtherClient);
                }
                catch (WebException we)
                {
                    SteamFriends.SendChatMessage(callback.OtherClient,
                                                 EChatEntryType.ChatMsg,
                                                 "Trade error: " + we.Message);

                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }
                catch (Exception)
                {
                    SteamFriends.SendChatMessage(callback.OtherClient,
                                                 EChatEntryType.ChatMsg,
                                                 "Trade declined. Could not correctly fetch your backpack.");

                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }

                //if (tradeManager.OtherInventory.IsPrivate)
                //{
                //    SteamFriends.SendChatMessage(callback.OtherClient,
                //                                 EChatEntryType.ChatMsg,
                //                                 "Trade declined. Your backpack cannot be private.");

                //    SteamTrade.RespondToTrade (callback.TradeID, false);
                //    return;
                //}

                if (CurrentTrade == null && GetUserHandler(callback.OtherClient).OnTradeRequest())
                {
                    SteamTrade.RespondToTrade(callback.TradeID, true);
                }
                else
                {
                    SteamTrade.RespondToTrade(callback.TradeID, false);
                }
            });

            msg.Handle <SteamTrading.TradeResultCallback> (callback =>
            {
                if (callback.Response == EEconTradeResponse.Accepted)
                {
                    Log.Debug("Trade Status: {0}", callback.Response);
                    Log.Info("Trade Accepted!");
                    GetUserHandler(callback.OtherClient).OnTradeRequestReply(true, callback.Response.ToString());
                }
                else
                {
                    Log.Warn("Trade failed: {0}", callback.Response);
                    CloseTrade();
                    GetUserHandler(callback.OtherClient).OnTradeRequestReply(false, callback.Response.ToString());
                }
            });
            #endregion

            #region Disconnect
            msg.Handle <SteamUser.LoggedOffCallback> (callback =>
            {
                IsLoggedIn = false;
                Log.Warn("Logged off Steam.  Reason: {0}", callback.Result);
            });

            msg.Handle <SteamClient.DisconnectedCallback> (callback =>
            {
                if (IsLoggedIn)
                {
                    IsLoggedIn = false;
                    CloseTrade();
                    Log.Warn("Disconnected from Steam Network!");
                }

                SteamClient.Connect();
            });
            #endregion

            #region Notifications
            msg.Handle <SteamBot.SteamNotifications.NotificationCallback>(callback =>
            {
                //currently only appears to be of trade offer
                if (callback.Notifications.Count != 0)
                {
                    foreach (var notification in callback.Notifications)
                    {
                        Log.Info(notification.UserNotificationType + " notification");
                    }
                }

                // Get offers only if cookies are valid
                if (CheckCookies())
                {
                    tradeOfferManager.GetOffers();
                }
            });

            msg.Handle <SteamBot.SteamNotifications.CommentNotificationCallback>(callback =>
            {
                //various types of comment notifications on profile/activity feed etc
                //Log.Info("received CommentNotificationCallback");
                //Log.Info("New Commments " + callback.CommentNotifications.CountNewComments);
                //Log.Info("New Commments Owners " + callback.CommentNotifications.CountNewCommentsOwner);
                //Log.Info("New Commments Subscriptions" + callback.CommentNotifications.CountNewCommentsSubscriptions);
            });
            #endregion
        }
Пример #19
0
 public void AddFriend(SteamID steamid)
 {
     SteamFriends.AddFriend(steamid);
 }
Пример #20
0
        void HandleSteamMessage(CallbackMsg msg)
        {
            log.Debug(msg.ToString());

            #region Login
            msg.Handle <SteamClient.ConnectedCallback>(callback =>
            {
                log.Debug("Connection Callback: " + callback.Result);

                if (callback.Result == EResult.OK)
                {
                    UserLogOn();
                }
                else
                {
                    log.Error("Failed to connect to Steam Community, trying again...");
                    SteamClient.Connect();
                }
            });

            msg.Handle <SteamUser.LoggedOnCallback>(callback =>
            {
                log.Debug("Logged On Callback: " + callback.Result);

                if (callback.Result == EResult.OK)
                {
                    MyUserNonce = callback.WebAPIUserNonce;
                }
                else
                {
                    log.Error("Login Error: " + callback.Result);
                }

                if (callback.Result == EResult.AccountLogonDenied)
                {
                    log.Interface("This account is SteamGuard enabled. Enter the code via the `auth' command.");

                    // try to get the steamguard auth code from the event callback
                    var eva = new SteamGuardRequiredEventArgs();
                    FireOnSteamGuardRequired(eva);
                    if (!String.IsNullOrEmpty(eva.SteamGuard))
                    {
                        logOnDetails.AuthCode = eva.SteamGuard;
                    }
                    else
                    {
                        logOnDetails.AuthCode = Console.ReadLine();
                    }
                }

                if (callback.Result == EResult.InvalidLoginAuthCode)
                {
                    log.Interface("The given SteamGuard code was invalid. Try again using the `auth' command.");
                    logOnDetails.AuthCode = Console.ReadLine();
                }
            });

            msg.Handle <SteamUser.LoginKeyCallback>(callback =>
            {
                MyUniqueId = callback.UniqueID.ToString();

                UserWebLogOn();

                if (Trade.CurrentSchema == null)
                {
                    log.Info("Downloading Schema...");
                    Trade.CurrentSchema = Schema.FetchSchema(apiKey);
                    log.Success("Schema Downloaded!");
                }

                SteamFriends.SetPersonaName(DisplayNamePrefix + DisplayName);
                SteamFriends.SetPersonaState(EPersonaState.Online);

                log.Success("Steam Bot Logged In Completely!");

                IsLoggedIn = true;

                GetUserHandler(SteamClient.SteamID).OnLoginCompleted();
            });

            msg.Handle <SteamClient.JobCallback <SteamUser.WebAPIUserNonceCallback> >(jobCallback =>
            {
                log.Debug("Received new WebAPIUserNonce.");

                if (jobCallback.Callback.Result == EResult.OK)
                {
                    MyUserNonce = jobCallback.Callback.Nonce;

                    UserWebLogOn();
                }
                else
                {
                    log.Error("WebAPIUserNonce Error: " + jobCallback.Callback.Result);
                }
            });

            // handle a special JobCallback differently than the others
            if (msg.IsType <SteamClient.JobCallback <SteamUser.UpdateMachineAuthCallback> >())
            {
                msg.Handle <SteamClient.JobCallback <SteamUser.UpdateMachineAuthCallback> >(
                    jobCallback => OnUpdateMachineAuthCallback(jobCallback.Callback, jobCallback.JobID)
                    );
            }
            #endregion

            #region Friends
            msg.Handle <SteamFriends.FriendsListCallback>(callback =>
            {
                foreach (SteamFriends.FriendsListCallback.Friend friend in callback.FriendList)
                {
                    switch (friend.SteamID.AccountType)
                    {
                    case EAccountType.Clan:
                        if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            if (GetUserHandler(friend.SteamID).OnGroupAdd())
                            {
                                AcceptGroupInvite(friend.SteamID);
                            }
                            else
                            {
                                DeclineGroupInvite(friend.SteamID);
                            }
                        }
                        break;

                    default:
                        CreateFriendsListIfNecessary();
                        if (friend.Relationship == EFriendRelationship.None)
                        {
                            friends.Remove(friend.SteamID);
                            GetUserHandler(friend.SteamID).OnFriendRemove();
                            RemoveUserHandler(friend.SteamID);
                        }
                        else if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            if (GetUserHandler(friend.SteamID).OnFriendAdd())
                            {
                                if (!friends.Contains(friend.SteamID))
                                {
                                    friends.Add(friend.SteamID);
                                }
                                else
                                {
                                    log.Error("Friend was added who was already in friends list: " + friend.SteamID);
                                }
                                SteamFriends.AddFriend(friend.SteamID);
                            }
                            else
                            {
                                SteamFriends.RemoveFriend(friend.SteamID);
                                RemoveUserHandler(friend.SteamID);
                            }
                        }
                        break;
                    }
                }
            });


            msg.Handle <SteamFriends.FriendMsgCallback>(callback =>
            {
                EChatEntryType type = callback.EntryType;

                if (callback.EntryType == EChatEntryType.ChatMsg)
                {
                    log.Info(String.Format("Chat Message from {0}: {1}",
                                           SteamFriends.GetFriendPersonaName(callback.Sender),
                                           callback.Message
                                           ));
                    GetUserHandler(callback.Sender).OnMessage(callback.Message, type);
                }
            });
            #endregion

            #region Group Chat
            //Begin KFBros stuff
            msg.Handle <SteamFriends.ChatMsgCallback>(callback =>
            {
                GetUserHandler(callback.ChatterID).OnChatRoomMessage(callback.ChatRoomID, callback.ChatterID, callback.Message);

                if (callback.Message == "hi")
                {
                    SteamFriends.SendChatRoomMessage(callback.ChatRoomID, EChatEntryType.ChatMsg, "hi");
                }

                if (callback.Message.Contains("v="))
                {
                    string coolresult;
                    string[] result = callback.Message.Split(' ');

                    for (int i = 0; i < result.Length; ++i)
                    {
                        if (result[i].Contains("v="))
                        {
                            coolresult = result[i];
                            log.Warn(coolresult.Substring(coolresult.IndexOf("v=") + 2));

                            string url = "https://www.googleapis.com/youtube/v3/videos?part=snippet&id=" + coolresult.Substring(coolresult.IndexOf("v=") + 2) + "&key=" + youtubeService.ApiKey;

                            WebRequest request   = HttpWebRequest.Create(url);
                            WebResponse response = request.GetResponse();
                            StreamReader reader  = new StreamReader(response.GetResponseStream());

                            string urlText = reader.ReadToEnd();

                            string final = "Youtube: " + urlText.Substring(urlText.IndexOf("\"title\": ") + 9, (urlText.IndexOf("\"description\":") - 6) - (urlText.IndexOf("\"title\": ") + 9));

                            log.Success(final);

                            if (final.Length > 9)
                            {
                                SteamFriends.SendChatRoomMessage(callback.ChatRoomID, EChatEntryType.ChatMsg, final);
                            }
                        }
                    }
                }
            });

            //handle bot being kicked and other type of chat member state messages
            msg.Handle <SteamFriends.ChatMemberInfoCallback>(callback =>
            {
                if (callback.StateChangeInfo.ChatterActedOn == 76561198119861272)
                {
                    if (callback.StateChangeInfo.StateChange == EChatMemberStateChange.Kicked)
                    {
                        SteamFriends.JoinChat(callback.ChatRoomID);
                    }
                }
            });



            #endregion

            #region Trading
            msg.Handle <SteamTrading.SessionStartCallback>(callback =>
            {
                bool started = HandleTradeSessionStart(callback.OtherClient);

                if (!started)
                {
                    log.Error("Could not start the trade session.");
                }
                else
                {
                    log.Debug("SteamTrading.SessionStartCallback handled successfully. Trade Opened.");
                }
            });

            msg.Handle <SteamTrading.TradeProposedCallback>(callback =>
            {
                if (CheckCookies() == false)
                {
                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }

                try
                {
                    tradeManager.InitializeTrade(SteamUser.SteamID, callback.OtherClient);
                }
                catch (WebException we)
                {
                    SteamFriends.SendChatMessage(callback.OtherClient,
                                                 EChatEntryType.ChatMsg,
                                                 "Trade error: " + we.Message);

                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }
                catch (Exception)
                {
                    SteamFriends.SendChatMessage(callback.OtherClient,
                                                 EChatEntryType.ChatMsg,
                                                 "Trade declined. Could not correctly fetch your backpack.");

                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }

                //if (tradeManager.OtherInventory.IsPrivate)
                //{
                //    SteamFriends.SendChatMessage(callback.OtherClient,
                //                                 EChatEntryType.ChatMsg,
                //                                 "Trade declined. Your backpack cannot be private.");

                //    SteamTrade.RespondToTrade (callback.TradeID, false);
                //    return;
                //}

                if (CurrentTrade == null && GetUserHandler(callback.OtherClient).OnTradeRequest())
                {
                    SteamTrade.RespondToTrade(callback.TradeID, true);
                }
                else
                {
                    SteamTrade.RespondToTrade(callback.TradeID, false);
                }
            });

            msg.Handle <SteamTrading.TradeResultCallback>(callback =>
            {
                if (callback.Response == EEconTradeResponse.Accepted)
                {
                    log.Debug("Trade Status: " + callback.Response);
                    log.Info("Trade Accepted!");
                    GetUserHandler(callback.OtherClient).OnTradeRequestReply(true, callback.Response.ToString());
                }
                else
                {
                    log.Warn("Trade failed: " + callback.Response);
                    CloseTrade();
                    GetUserHandler(callback.OtherClient).OnTradeRequestReply(false, callback.Response.ToString());
                }
            });
            #endregion

            #region Disconnect
            msg.Handle <SteamUser.LoggedOffCallback>(callback =>
            {
                IsLoggedIn = false;
                log.Warn("Logged Off: " + callback.Result);
            });

            msg.Handle <SteamClient.DisconnectedCallback>(callback =>
            {
                IsLoggedIn = false;
                CloseTrade();
                log.Warn("Disconnected from Steam Network!");
                SteamClient.Connect();
            });
            #endregion

            #region Notifications
            msg.Handle <SteamBot.SteamNotifications.NotificationCallback>(callback =>
            {
                //currently only appears to be of trade offer
                if (callback.Notifications.Count != 0)
                {
                    foreach (var notification in callback.Notifications)
                    {
                        log.Info(notification.UserNotificationType + " notification");
                    }
                }

                // Get offers only if cookies are valid
                if (CheckCookies())
                {
                    tradeOfferManager.GetOffers();
                }
            });

            msg.Handle <SteamBot.SteamNotifications.CommentNotificationCallback>(callback =>
            {
                //various types of comment notifications on profile/activity feed etc
                //log.Info("received CommentNotificationCallback");
                //log.Info("New Commments " + callback.CommentNotifications.CountNewComments);
                //log.Info("New Commments Owners " + callback.CommentNotifications.CountNewCommentsOwner);
                //log.Info("New Commments Subscriptions" + callback.CommentNotifications.CountNewCommentsSubscriptions);
            });
            #endregion
        }
Пример #21
0
        public static void Main(string[] args)
        {
            #region SteamRE Init
            AllArgs = args;

            //Hacking around https
            ServicePointManager.CertificatePolicy = new MainClass();

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("\n\tSteamBot Beta\n\tCreated by Jessecar96.\n\n");
            Console.ForegroundColor = ConsoleColor.White;


            steamClient = new SteamClient();
            steamTrade  = steamClient.GetHandler <SteamTrading>();
            SteamUser steamUser = steamClient.GetHandler <SteamUser> ();
            steamFriends = steamClient.GetHandler <SteamFriends>();

            steamClient.Connect();
            #endregion


            while (true)
            {
                CallbackMsg msg = steamClient.WaitForCallback(true);

                //Console Debug
                printConsole(msg.ToString(), ConsoleColor.Blue, true);


                #region Logged Off Handler
                msg.Handle <SteamUser.LoggedOffCallback> (callback =>
                {
                    printConsole("Logged Off: " + callback.Result, ConsoleColor.Red);
                });
                #endregion


                #region Steam Disconnect Handler
                msg.Handle <SteamClient.DisconnectedCallback> (callback =>
                {
                    printConsole("Disconnected.", ConsoleColor.Red);
                });
                #endregion


                #region Steam Connect Handler

                /**
                 * --Steam Connection Callback
                 *
                 * It's not needed to modify this section
                 */

                msg.Handle <SteamClient.ConnectedCallback> (callback =>
                {
                    //Print Callback
                    printConsole("Steam Connected Callback: " + callback.Result, ConsoleColor.Cyan);

                    //Validate Result
                    if (callback.Result == EResult.OK)
                    {
                        //Get Steam Login Details
                        printConsole("Username: "******"Password: "******"Getting Web Cookies...", ConsoleColor.Yellow);

                        //Get Web Cookies
                        SteamWeb web = new SteamWeb();
                        WebCookies   = web.DoLogin(user, pass);

                        if (WebCookies != null)
                        {
                            printConsole("SteamWeb Cookies retrived.", ConsoleColor.Green);
                            //Do Login
                            steamUser.LogOn(new SteamUser.LogOnDetails {
                                Username = user,
                                Password = pass
                            });
                        }
                        else
                        {
                            printConsole("Error while getting SteamWeb Cookies.", ConsoleColor.Red);
                        }
                    }
                    else
                    {
                        //Failure
                        printConsole("Failed to Connect to steam.", ConsoleColor.Red);
                    }
                });
                #endregion


                #region Steam Login Handler
                //Logged in (or not)
                msg.Handle <SteamUser.LoggedOnCallback>(callback =>
                {
                    printConsole("Logged on callback: " + callback.Result, ConsoleColor.Cyan);

                    if (callback.Result != EResult.OK)
                    {
                        printConsole("Login Failed!", ConsoleColor.Red);
                    }
                    else
                    {
                        printConsole("Successfulyl Logged In!\nWelcome " + steamUser.SteamID, ConsoleColor.Green);

                        //Set community status
                        steamFriends.SetPersonaName(BotPersonaName);
                        steamFriends.SetPersonaState(BotPersonaState);
                    }
                });
                #endregion


                #region Steam Trade Start

                /**
                 *
                 * Steam Trading Handler
                 *
                 */
                msg.Handle <SteamTrading.TradeStartSessionCallback>(call =>
                {
                    //Trading
                    trade = null;
                    trade = new TradeSystem();
                    trade.initTrade(steamUser.SteamID, call.Other, WebCookies);
                });
                #endregion

                #region Trade Requested Handler
                //Don't modify this
                msg.Handle <SteamTrading.TradeProposedCallback>(thing =>
                {
                    //Trade Callback
                    printConsole("Trade Proposed Callback. Other: " + thing.Other + "\n");

                    //Accept It
                    steamTrade.RequestTrade(thing.Other);
                });
                #endregion

                msg.Handle <SteamFriends.PersonaStateCallback>(callback =>
                {
                    if (callback.FriendID == steamUser.SteamID)
                    {
                        return;
                    }

                    EFriendRelationship relationship = steamFriends.GetFriendRelationship(callback.FriendID);
                    if (!(relationship == EFriendRelationship.RequestRecipient))
                    {
                        return;
                    }


                    if (steamFriends.GetFriendRelationship(callback.FriendID) == EFriendRelationship.PendingInvitee)
                    {
                        printConsole("[Friend] Friend Request Pending: " + callback.FriendID + "(" + steamFriends.GetFriendPersonaName(callback.FriendID) + ") - Accepted", ConsoleColor.Yellow);
                        steamFriends.AddFriend(callback.FriendID);
                    }
                });


                #region Steam Chat Handler

                /**
                 *
                 * Steam Chat Handler
                 *
                 */
                msg.Handle <SteamFriends.FriendMsgCallback>(callback =>
                {
                    //Type (emote or chat)
                    EChatEntryType type = callback.EntryType;

                    if (type == EChatEntryType.ChatMsg)
                    {
                        //Message is a chat message

                        //Reply with the same message
                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, callback.Message);

                        //Chat API coming soon
                    }
                    else if (type == EChatEntryType.Emote)
                    {
                        //Message is emote

                        //Do nothing yet
                    }
                });
                #endregion
            }     //end while loop
        }         //end Main method
Пример #22
0
 public void AddFriend(SteamID userID) => friends.AddFriend(userID);
Пример #23
0
 public void AddFriend(SteamID s) => steam_friends.AddFriend(s);
Пример #24
0
        public async Task <bool> processFriendRequest(SteamID SteamID, Bot bot)
        {
            SteamFriends steamFriends = Client.GetHandler <SteamFriends>();
            UserProfile  userProfile  = await UserProfile.BuildUserProfile(SteamID.ConvertToUInt64(), bot);

            Logger.LogDebug("[PROFILE DETAILS]: " + userProfile.ToString());

            await processCommentedOnProfile(userProfile, bot);

            List <Action> actions = new List <Action>();

            actions.Add(processPrivateProfile(userProfile, bot));
            Logger.LogDebug("[ACTION PRIVATE PROFILE]: " + processPrivateProfile(userProfile, bot).action);

            actions.Add(await processSteamRepScammerAsync(userProfile, bot));
            Logger.LogDebug("[ACTION STAEMREP SCAMMER]: " + (await processSteamRepScammerAsync(userProfile, bot)).action);

            actions.Add(processSteamLevel(userProfile, bot));
            Logger.LogDebug("[ACTION STEAM LEVEL]: " + processSteamLevel(userProfile, bot).action);

            actions.Add(processVACBanned(userProfile, bot));
            Logger.LogDebug("[ACTION VAC BANNED]: " + processVACBanned(userProfile, bot).action);

            actions.Add(processGameBanned(userProfile, bot));
            Logger.LogDebug("[ACTION GAME BANNED]: " + processGameBanned(userProfile, bot).action);

            actions.Add(processDaysSinceLastBan(userProfile, bot));
            Logger.LogDebug("[ACTION DAYS SINCE LAST BAN]: " + processDaysSinceLastBan(userProfile, bot).action);

            actions.Add(processCommunityBanned(userProfile, bot));
            Logger.LogDebug("[ACTION COMMUNITY BANNED]: " + processCommunityBanned(userProfile, bot).action);

            actions.Add(processEconomyBanned(userProfile, bot));
            Logger.LogDebug("[ACTION ECONOMY BANNED]: " + processEconomyBanned(userProfile, bot).action);

            actions.Add(processProfileName(userProfile, bot));
            Logger.LogDebug("[ACTION PROFILE NAME]: " + processProfileName(userProfile, bot).action);

            Config.FriendInviteConfigs.TryGetValue(bot, out Config config);
            List <string> actionpriority = config.ActionPriority;

            foreach (string action_string in actionpriority)
            {
                Action action = new Action(action_string);
                if (actions.Contains(action))
                {
                    action = actions[actions.IndexOf(action)];

                    switch (action.action)
                    {
                    case "block":
                        await steamFriends.IgnoreFriend(SteamID);

                        break;

                    case "ignore":
                        steamFriends.RemoveFriend(SteamID);
                        break;

                    case "add":
                        steamFriends.AddFriend(SteamID);
                        break;
                    }

                    Logger.LogInfo("New pending invite from {0}", userProfile.personaName);
                    Logger.LogInfo("  ├─ SteamID: {0}", Convert.ToString(SteamID.ConvertToUInt64()));
                    Logger.LogInfo("  ├─ Profile url: {0}", userProfile.profileUrl);
                    Logger.LogInfo("  └─ Action: {0} | Reason: {1}", action.action.ToUpper(), action.reason);
                }
            }
            return(true);
        }
Пример #25
0
        void HandleSteamMessage(CallbackMsg msg)
        {
            log.Debug(msg.ToString());

            #region Login
            msg.Handle <SteamClient.ConnectedCallback> (callback =>
            {
                log.Debug("Connection Callback: " + callback.Result);

                if (callback.Result == EResult.OK)
                {
                    UserLogOn();
                }
                else
                {
                    log.Error("Failed to connect to Steam Community, trying again...");
                    SteamClient.Connect();
                }
            });

            msg.Handle <SteamUser.LoggedOnCallback> (callback =>
            {
                log.Debug("Logged On Callback: " + callback.Result);

                if (callback.Result != EResult.OK)
                {
                    log.Error("Login Error: " + callback.Result);
                }

                if (callback.Result == EResult.AccountLogonDenied)
                {
                    log.Interface("This account is protected by Steam Guard.  Enter the authentication code sent to the proper email: ");
                    logOnDetails.AuthCode = Console.ReadLine();
                }

                if (callback.Result == EResult.InvalidLoginAuthCode)
                {
                    log.Interface("An Invalid Authorization Code was provided.  Enter the authentication code sent to the proper email: ");
                    logOnDetails.AuthCode = Console.ReadLine();
                }
            });

            msg.Handle <SteamUser.LoginKeyCallback> (callback =>
            {
                while (true)
                {
                    bool authd = SteamWeb.Authenticate(callback, SteamClient, out sessionId, out token);
                    if (authd)
                    {
                        log.Success("User Authenticated!");
                        break;
                    }
                    else
                    {
                        log.Warn("Authentication failed, retrying in 2s...");
                        Thread.Sleep(2000);
                    }
                }

                log.Info("Downloading Schema...");

                if (Trade.CurrentSchema == null)
                {
                    Trade.CurrentSchema = Schema.FetchSchema(apiKey);
                }

                log.Success("Schema Downloaded!");

                SteamFriends.SetPersonaName(DisplayNamePrefix + DisplayName);
                SteamFriends.SetPersonaState(EPersonaState.Online);

                log.Success("Steam Bot Logged In Completely!");

                IsLoggedIn = true;
            });

            // handle a special JobCallback differently than the others
            if (msg.IsType <SteamClient.JobCallback <SteamUser.UpdateMachineAuthCallback> >())
            {
                msg.Handle <SteamClient.JobCallback <SteamUser.UpdateMachineAuthCallback> >(
                    jobCallback => OnUpdateMachineAuthCallback(jobCallback.Callback, jobCallback.JobID)
                    );
            }
            #endregion

            #region Friends
            msg.Handle <SteamFriends.FriendsListCallback> (callback =>
            {
                foreach (SteamFriends.FriendsListCallback.Friend friend in callback.FriendList)
                {
                    if (!friends.Contains(friend.SteamID))
                    {
                        friends.Add(friend.SteamID);
                        if (friend.Relationship == EFriendRelationship.PendingInvitee &&
                            GetUserHandler(friend.SteamID).OnFriendAdd())
                        {
                            SteamFriends.AddFriend(friend.SteamID);
                        }
                    }
                }
            });

            msg.Handle <SteamFriends.FriendMsgCallback> (callback =>
            {
                EChatEntryType type = callback.EntryType;

                if (callback.EntryType == EChatEntryType.ChatMsg ||
                    callback.EntryType == EChatEntryType.Emote)
                {
                    log.Info(String.Format("Chat Message from {0}: {1}",
                                           SteamFriends.GetFriendPersonaName(callback.Sender),
                                           callback.Message
                                           ));
                    GetUserHandler(callback.Sender).OnMessage(callback.Message, type);
                }
            });
            #endregion

            #region Trading
            msg.Handle <SteamTrading.SessionStartCallback> (callback =>
            {
                OpenTrade(callback.OtherClient);
            });

            msg.Handle <SteamTrading.TradeProposedCallback> (callback =>
            {
                if (CurrentTrade == null && GetUserHandler(callback.OtherClient).OnTradeRequest())
                {
                    SteamTrade.RespondToTrade(callback.TradeID, true);
                }
                else
                {
                    SteamTrade.RespondToTrade(callback.TradeID, false);
                }
            });

            msg.Handle <SteamTrading.TradeResultCallback> (callback =>
            {
                log.Debug("Trade Status: " + callback.Response);

                if (callback.Response == EEconTradeResponse.Accepted)
                {
                    log.Info("Trade Accepted!");
                }
                if (callback.Response == EEconTradeResponse.Cancel ||
                    callback.Response == EEconTradeResponse.ConnectionFailed ||
                    callback.Response == EEconTradeResponse.Declined ||
                    callback.Response == EEconTradeResponse.Error ||
                    callback.Response == EEconTradeResponse.InitiatorAlreadyTrading ||
                    callback.Response == EEconTradeResponse.TargetAlreadyTrading ||
                    callback.Response == EEconTradeResponse.Timeout ||
                    callback.Response == EEconTradeResponse.TooSoon ||
                    callback.Response == EEconTradeResponse.VacBannedInitiator ||
                    callback.Response == EEconTradeResponse.VacBannedTarget ||
                    callback.Response == EEconTradeResponse.NotLoggedIn) // uh...
                {
                    CloseTrade();
                }
            });
            #endregion

            #region Disconnect
            msg.Handle <SteamUser.LoggedOffCallback> (callback =>
            {
                IsLoggedIn = false;
                log.Warn("Logged Off: " + callback.Result);
            });

            msg.Handle <SteamClient.DisconnectedCallback> (callback =>
            {
                IsLoggedIn = false;
                CloseTrade();
                log.Warn("Disconnected from Steam Network!");
                SteamClient.Connect();
            });
            #endregion
        }
Пример #26
0
        /// <summary>
        /// Add the user to the friendslist
        /// Welcome the user to the service
        /// </summary>
        /// <param name="_steamFriends"></param>
        /// <param name="_friendSteamID"></param>
        public void AcceptFriendRequest(SteamFriends _steamFriends, SteamID _friendSteamID)
        {
            _steamFriends.AddFriend(_friendSteamID);

            _steamFriends.SendChatMessage(_friendSteamID, EChatEntryType.ChatMsg, "Hello and welcome to my Service!");
        }
Пример #27
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.DarkCyan;

            System.Console.Title = "TradeBot";
            System.Console.WriteLine("Welcome to TradeBot!\nCreated by Jessecar.\nTurn of Steam Guard before loggin in!\n\n");

            Console.ForegroundColor = ConsoleColor.White;

            printConsole("Steam Username:"******"jessecar96"; //Console.ReadLine();

            System.Console.WriteLine("Steam Password: "******"Sorry, could not connect to Steam.");
                    }
                    steamUser.LogOn(new SteamUser.LogOnDetails
                    {
                        Username = username,
                        Password = password,
                    });
                });


                //Login Callback
                msg.Handle <SteamUser.LoggedOnCallback>(callback =>
                {
                    if (callback.Result != EResult.OK)
                    {
                        printConsole("Incorrect username or Password. Make sure you have disabled steam guard!");
                    }
                    else
                    {
                        printConsole("Connected to Steam!\nWelcome " + steamUser.SteamID);
                        steamFriends.SetPersonaName("ChatBot Beta (Say hi)");
                        steamFriends.SetPersonaState((EPersonaState)6);
                    }
                });

                //Chat Messages
                msg.Handle <SteamFriends.FriendMsgCallback>(callback =>
                {
                    EChatEntryType type = callback.EntryType;



                    if (type == EChatEntryType.ChatMsg)
                    {
                        SteamID sid = callback.Sender;

                        if (!clients.Contains(callback.Sender))
                        {
                            printConsole("[New Client]" + callback.Sender, ConsoleColor.Magenta);
                            clients.Add(callback.Sender);

                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Welcome to TradeBot created by Jessecar.  To see a list of commands type /help");
                        }

                        if (callback.Message.StartsWith("/"))
                        {
                            string message = callback.Message.Replace("/", "");

                            printConsole("[Command]" + callback.Sender + " (" + steamFriends.GetFriendPersonaName(callback.Sender) + "): " + message, ConsoleColor.Magenta);
                            //string[] args = .Split(" ");

                            string[] words = message.Split(new char[] { ' ' }, 2);

                            switch (words[0])
                            {
                            case "trade":
                                //Send a trade
                                trade.RequestTrade(callback.Sender);
                                printConsole("Trade requested by " + callback.Sender + " (" + steamFriends.GetFriendPersonaName(callback.Sender) + ")", ConsoleColor.Green);
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.Emote, "initiated a trade request.");
                                break;

                            case "remove":
                                //Remove Friend
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Thank you for using the Steam TradeBot BETA.");
                                steamFriends.RemoveFriend(callback.Sender);
                                printConsole("[Friend] Friend Removed: " + callback.Sender + " (" + steamFriends.GetFriendPersonaName(callback.Sender) + ")", ConsoleColor.Yellow);
                                break;

                            case "status":
                                //get status (nothing)
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.Emote, "is Online and working good.");
                                break;

                            case "hi":
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.Emote, "says hello.");
                                break;

                            case "help":
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "\nList Of Commands:\n/trade - Start a trade.\n/remove - Remove TradeBot from your friends.\n/hi - say hello");
                                break;

                            case "name":
                                if (checkAdmin(sid))
                                {
                                    steamFriends.SetPersonaName(words[1]);
                                }
                                break;

                            case "send":
                                string[] wrds = message.Split(new char[] { ' ' }, 3);

                                int index = int.Parse(wrds[1]);

                                if (index < clients.Count() && index >= 0)
                                {
                                    steamFriends.SendChatMessage(clients[index], EChatEntryType.ChatMsg, wrds[2]);
                                }
                                else
                                {
                                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.Emote, "Error: index out of bounds.");
                                }

                                break;

                            default:
                                printConsole("[Error]Unknown command from " + callback.Sender + ": " + callback.Message, ConsoleColor.Red);
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.Emote, "doesn't know that command.");
                                break;
                            }
                        }
                        else
                        {
                            printConsole("[Chat][" + getIndex(sid) + "]" + callback.Sender + ": " + " (" + steamFriends.GetFriendPersonaName(callback.Sender) + ")" + callback.Message, ConsoleColor.Magenta);
                            if ((callback.Message != "hi" || callback.Message != "hello") && clients.Contains(callback.Sender))
                            {
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You Said: " + callback.Message);
                            }
                        }
                    }
                    else if (type == EChatEntryType.Emote)
                    {
                        printConsole("[Emote]" + callback.Sender + ": " + callback.Message, ConsoleColor.DarkMagenta);
                    }
                });

                msg.Handle <SteamTrading.TradeProposedCallback>(callback =>
                {
                    SteamID sid = callback.Other;
                    //trade.RespondTradeRequest(callback.TradeRequestId, sid, true);
                    //trade.HandleMsg((IPacketMsg)EMsg.EconTrading_InitiateTradeProposed);
                });

                msg.Handle <SteamTrading.TradeRequestCallback>(callback =>
                {
                    printConsole("[Trade] Trade Status with " + callback.Other + " (" + steamFriends.GetFriendPersonaName(callback.Other) + "): " + callback.Status.ToString(), ConsoleColor.Green);
                    if (callback.Status == ETradeStatus.Rejected)
                    {
                        printConsole("[Trade] Trade rejected by " + callback.Other + " (" + steamFriends.GetFriendPersonaName(callback.Other) + ")", ConsoleColor.DarkRed);
                        steamFriends.SendChatMessage(callback.Other, EChatEntryType.Emote, "detected that you rejected that trade.");
                    }
                    //trade.RespondTradeRequest(callback.TradeRequestId, callback.Other, true);
                });

                msg.Handle <SteamTrading.TradeStartSessionCallback>(callback =>
                {
                    //callback.Other
                });

                msg.Handle <SteamFriends.PersonaStateCallback>(callback =>
                {
                    if (callback.FriendID == steamUser.SteamID)
                    {
                        return;
                    }

                    EFriendRelationship relationship = steamFriends.GetFriendRelationship(callback.FriendID);
                    if (!(relationship == EFriendRelationship.RequestRecipient))
                    {
                        return;
                    }

                    printConsole("[Friend] Added Friend: " + callback.FriendID + "(" + steamFriends.GetFriendPersonaName(callback.FriendID) + ")", ConsoleColor.Yellow);
                    steamFriends.AddFriend(callback.FriendID);
                });
            }
        }
        void OnFriendsList(SteamFriends.FriendsListCallback callback)
        {
            // at this point, the client has received it's friends list

            int friendCount = _steamFriends.GetFriendCount();

            Console.WriteLine("We have {0} friends", friendCount);

            for (int x = 0; x < friendCount; x++)
            {
                // steamids identify objects that exist on the steam network, such as friends, as an example
                SteamID steamIdFriend = _steamFriends.GetFriendByIndex(x);
                // we'll just display the STEAM_ rendered version
                Console.WriteLine("Friend: {0}", steamIdFriend.Render());

                if (_cmd == Command.SendAll)
                {
                    _steamFriends.SendChatMessage(steamIdFriend, EChatEntryType.ChatMsg, _messageText);
                    Thread.Sleep(500);
                }
                else if (_cmd == Command.SendSingle)
                {
                    if (_userId == steamIdFriend.ConvertToUInt64().ToString())
                    {
                        _steamFriends.SendChatMessage(steamIdFriend, EChatEntryType.ChatMsg, _messageText);
                        _isMessageSent = true;
                        break;
                    }
                }
                else if (_cmd == Command.AcceptFriends)
                {
                    foreach (var friend in callback.FriendList)
                    {
                        if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            // this _user has added us, let's add him back and send him a message
                            _steamFriends.AddFriend(friend.SteamID);
                            _steamFriends.SendChatMessage(friend.SteamID, EChatEntryType.ChatMsg, _messageText);
                            _isMessageSent = true;
                        }
                    }
                }
                else if (_cmd == Command.GetAllIds)
                {
                    foreach (var friend in callback.FriendList)
                    {
                        if (!_friendsIds.ContainsKey(friend.SteamID.ConvertToUInt64().ToString()))
                        {
                            var val = _steamFriends.RequestProfileInfo(friend.SteamID).ToTask().Result;
                            _friendsIds[friend.SteamID.ConvertToUInt64().ToString()] = val.RealName;
                        }
                    }
                    _isMessageSent = true;
                }
                else if (_cmd == Command.GetFriendInfo)
                {
                    if (_userId == steamIdFriend.ConvertToUInt64().ToString())
                    {
                        var val = _steamFriends.RequestProfileInfo(steamIdFriend).ToTask().Result;
                        _friendInfoVm.country    = val.CountryName;
                        _friendInfoVm.summary    = val.Summary;
                        _friendInfoVm.realName   = val.RealName;
                        _friendInfoVm.headline   = val.Headline;
                        _friendInfoVm.state      = val.StateName;
                        _friendInfoVm.steamId    = steamIdFriend.ToString();
                        _friendInfoVm.profileUrl = "https://steamcommunity.com/profiles/" + steamIdFriend.ConvertToUInt64().ToString();
                        string html;
                        using (WebClient client = new WebClient())
                        {
                            client.Headers[HttpRequestHeader.UserAgent] = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
                            html = client.DownloadString("https://steamid.xyz/" + val.SteamID.ConvertToUInt64().ToString());
                        }
                        _friendInfoVm.image_url = GetImagesInHTMLString(html);
                        _isMessageSent          = true;
                    }
                }
            }
            if (_cmd == Command.SendAll)
            {
                _isMessageSent = true;
            }
        }
Пример #29
0
        void HandleSteamMessage(CallbackMsg msg)
        {
            log.Debug(msg.ToString());

            #region Login
            msg.Handle <SteamClient.ConnectedCallback> (callback =>
            {
                log.Debug("Connection Callback: " + callback.Result);

                if (callback.Result == EResult.OK)
                {
                    UserLogOn();
                }
                else
                {
                    log.Error("Failed to connect to Steam Community, trying again...");
                    SteamClient.Connect();
                }
            });

            msg.Handle <SteamUser.LoggedOnCallback> (callback =>
            {
                log.Debug("Logged On Callback: " + callback.Result);

                if (callback.Result != EResult.OK)
                {
                    log.Error("Login Error: " + callback.Result);
                }

                if (callback.Result == EResult.AccountLogonDenied)
                {
                    log.Interface("This account is SteamGuard enabled. Enter the code via the `auth' command.");

                    // try to get the steamguard auth code from the event callback
                    var eva = new SteamGuardRequiredEventArgs();
                    FireOnSteamGuardRequired(eva);
                    if (!String.IsNullOrEmpty(eva.SteamGuard))
                    {
                        logOnDetails.AuthCode = eva.SteamGuard;
                    }
                    else
                    {
                        logOnDetails.AuthCode = Console.ReadLine();
                    }
                }

                if (callback.Result == EResult.InvalidLoginAuthCode)
                {
                    log.Interface("The given SteamGuard code was invalid. Try again using the `auth' command.");
                    logOnDetails.AuthCode = Console.ReadLine();
                }
            });

            msg.Handle <SteamUser.LoginKeyCallback> (callback =>
            {
                while (true)
                {
                    bool authd = SteamWeb.Authenticate(callback, SteamClient, out sessionId, out token);
                    if (authd)
                    {
                        log.Success("User Authenticated!");

                        tradeManager = new TradeManager(apiKey, sessionId, token);
                        tradeManager.SetTradeTimeLimits(MaximumTradeTime, MaximiumActionGap, TradePollingInterval);
                        tradeManager.OnTimeout    += OnTradeTimeout;
                        tradeManager.OnTradeEnded += OnTradeEnded;
                        break;
                    }
                    else
                    {
                        log.Warn("Authentication failed, retrying in 2s...");
                        Thread.Sleep(2000);
                    }
                }

                if (Trade.CurrentSchema == null)
                {
                    log.Info("Downloading Schema...");
                    Trade.CurrentSchema = Schema.FetchSchema(apiKey);
                    log.Success("Schema Downloaded!");
                }

                SteamFriends.SetPersonaName(DisplayNamePrefix + DisplayName);
                SteamFriends.SetPersonaState(EPersonaState.Online);

                log.Success("Steam Bot Logged In Completely!");

                IsLoggedIn = true;

                GetUserHandler(SteamClient.SteamID).OnLoginCompleted();
            });

            // handle a special JobCallback differently than the others
            if (msg.IsType <SteamClient.JobCallback <SteamUser.UpdateMachineAuthCallback> >())
            {
                msg.Handle <SteamClient.JobCallback <SteamUser.UpdateMachineAuthCallback> >(
                    jobCallback => OnUpdateMachineAuthCallback(jobCallback.Callback, jobCallback.JobID)
                    );
            }
            #endregion

            #region Friends
            msg.Handle <SteamFriends.FriendsListCallback> (callback =>
            {
                foreach (SteamFriends.FriendsListCallback.Friend friend in callback.FriendList)
                {
                    if (!friends.Contains(friend.SteamID))
                    {
                        friends.Add(friend.SteamID);
                        if (friend.Relationship == EFriendRelationship.PendingInvitee &&
                            GetUserHandler(friend.SteamID).OnFriendAdd())
                        {
                            SteamFriends.AddFriend(friend.SteamID);
                        }
                    }
                    else
                    {
                        if (friend.Relationship == EFriendRelationship.None)
                        {
                            friends.Remove(friend.SteamID);
                            GetUserHandler(friend.SteamID).OnFriendRemove();
                        }
                    }
                }
            });

            msg.Handle <SteamFriends.FriendMsgCallback> (callback =>
            {
                EChatEntryType type = callback.EntryType;

                if (callback.EntryType == EChatEntryType.ChatMsg ||
                    callback.EntryType == EChatEntryType.Emote)
                {
                    log.Info(String.Format("Chat Message from {0}: {1}",
                                           SteamFriends.GetFriendPersonaName(callback.Sender),
                                           callback.Message
                                           ));
                    GetUserHandler(callback.Sender).OnMessage(callback.Message, type);
                }
            });
            #endregion

            #region Group Chat
            msg.Handle <SteamFriends.ChatMsgCallback>(callback =>
            {
                GetUserHandler(callback.ChatterID).OnChatRoomMessage(callback.ChatRoomID, callback.ChatterID, callback.Message);
            });
            #endregion

            #region Trading
            msg.Handle <SteamTrading.SessionStartCallback> (callback =>
            {
                bool started = HandleTradeSessionStart(callback.OtherClient);

                if (!started)
                {
                    log.Error("Could not start the trade session.");
                }
                else
                {
                    log.Debug("SteamTrading.SessionStartCallback handled successfully. Trade Opened.");
                }
            });

            msg.Handle <SteamTrading.TradeProposedCallback> (callback =>
            {
                try
                {
                    tradeManager.InitializeTrade(SteamUser.SteamID, callback.OtherClient);
                }
                catch
                {
                    SteamFriends.SendChatMessage(callback.OtherClient,
                                                 EChatEntryType.ChatMsg,
                                                 "Trade declined. Could not correctly fetch your backpack.");

                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }

                if (tradeManager.OtherInventory.IsPrivate)
                {
                    SteamFriends.SendChatMessage(callback.OtherClient,
                                                 EChatEntryType.ChatMsg,
                                                 "Trade declined. Your backpack cannot be private.");

                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }

                if (CurrentTrade == null && GetUserHandler(callback.OtherClient).OnTradeRequest())
                {
                    SteamTrade.RespondToTrade(callback.TradeID, true);
                }
                else
                {
                    SteamTrade.RespondToTrade(callback.TradeID, false);
                }
            });

            msg.Handle <SteamTrading.TradeResultCallback> (callback =>
            {
                if (callback.Response == EEconTradeResponse.Accepted)
                {
                    log.Debug("Trade Status: " + callback.Response);
                    log.Info("Trade Accepted!");
                }
                else
                {
                    log.Warn("Trade failed: " + callback.Response);
                    CloseTrade();
                }
            });
            #endregion

            #region Disconnect
            msg.Handle <SteamUser.LoggedOffCallback> (callback =>
            {
                IsLoggedIn = false;
                log.Warn("Logged Off: " + callback.Result);
            });

            msg.Handle <SteamClient.DisconnectedCallback> (callback =>
            {
                IsLoggedIn = false;
                CloseTrade();
                log.Warn("Disconnected from Steam Network!");
                SteamClient.Connect();
            });
            #endregion
        }
Пример #30
0
        void HandleSteamMessage(ICallbackMsg msg)
        {
            Log.Debug(msg.ToString());
            #region Login
            msg.Handle <SteamClient.ConnectedCallback> (callback =>
            {
                Log.Debug("Connection Callback: {0}", callback.Result);

                if (callback.Result == EResult.OK)
                {
                    UserLogOn();
                }
                else
                {
                    Log.Error("Failed to connect to Steam Community, trying again...");
                    SteamClient.Connect();
                }
            });

            msg.Handle <SteamUser.LoggedOnCallback> (callback =>
            {
                Log.Debug("Logged On Callback: {0}", callback.Result);

                if (callback.Result == EResult.OK)
                {
                    myUserNonce = callback.WebAPIUserNonce;
                }
                else
                {
                    Log.Error("Login Error: {0}", callback.Result);
                }

                if (callback.Result == EResult.AccountLogonDenied)
                {
                    Log.Interface("This account is SteamGuard enabled. Enter the code via the `auth' command.");

                    // try to get the steamguard auth code from the event callback
                    var eva = new SteamGuardRequiredEventArgs();
                    FireOnSteamGuardRequired(eva);
                    if (!String.IsNullOrEmpty(eva.SteamGuard))
                    {
                        logOnDetails.AuthCode = eva.SteamGuard;
                    }
                    else
                    {
                        logOnDetails.AuthCode = Console.ReadLine();
                    }
                }

                if (callback.Result == EResult.InvalidLoginAuthCode)
                {
                    Log.Interface("The given SteamGuard code was invalid. Try again using the `auth' command.");
                    logOnDetails.AuthCode = Console.ReadLine();
                }
            });

            msg.Handle <SteamUser.LoginKeyCallback> (callback =>
            {
                myUniqueId = callback.UniqueID.ToString();

                UserWebLogOn();

                SteamFriends.SetPersonaName(DisplayNamePrefix + DisplayName);
                SteamFriends.SetPersonaState(EPersonaState.Online);

                Log.Success("Steam Bot Logged In Completely!");

                GetUserHandler(SteamClient.SteamID).OnLoginCompleted();
            });

            msg.Handle <SteamUser.WebAPIUserNonceCallback>(webCallback =>
            {
                Log.Debug("Received new WebAPIUserNonce.");

                if (webCallback.Result == EResult.OK)
                {
                    myUserNonce = webCallback.Nonce;
                    UserWebLogOn();
                }
                else
                {
                    Log.Error("WebAPIUserNonce Error: " + webCallback.Result);
                }
            });

            msg.Handle <SteamUser.UpdateMachineAuthCallback>(
                authCallback => OnUpdateMachineAuthCallback(authCallback)
                );
            #endregion

            #region Friends
            msg.Handle <SteamFriends.FriendsListCallback>(callback =>
            {
                foreach (SteamFriends.FriendsListCallback.Friend friend in callback.FriendList)
                {
                    switch (friend.SteamID.AccountType)
                    {
                    case EAccountType.Clan:
                        if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            if (GetUserHandler(friend.SteamID).OnGroupAdd())
                            {
                                AcceptGroupInvite(friend.SteamID);
                            }
                            else
                            {
                                DeclineGroupInvite(friend.SteamID);
                            }
                        }
                        break;

                    default:
                        CreateFriendsListIfNecessary();
                        if (friend.Relationship == EFriendRelationship.None)
                        {
                            friends.Remove(friend.SteamID);
                            GetUserHandler(friend.SteamID).OnFriendRemove();
                            RemoveUserHandler(friend.SteamID);
                        }
                        else if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            if (GetUserHandler(friend.SteamID).OnFriendAdd())
                            {
                                if (!friends.Contains(friend.SteamID))
                                {
                                    friends.Add(friend.SteamID);
                                }
                                else
                                {
                                    Log.Error("Friend was added who was already in friends list: " + friend.SteamID);
                                }
                                SteamFriends.AddFriend(friend.SteamID);
                            }
                            else
                            {
                                SteamFriends.RemoveFriend(friend.SteamID);
                                RemoveUserHandler(friend.SteamID);
                            }
                        }
                        break;
                    }
                }
            });


            msg.Handle <SteamFriends.FriendMsgCallback> (callback =>
            {
                EChatEntryType type = callback.EntryType;

                if (callback.EntryType == EChatEntryType.ChatMsg)
                {
                    Log.Info("Chat Message from {0}: {1}",
                             SteamFriends.GetFriendPersonaName(callback.Sender),
                             callback.Message
                             );
                    GetUserHandler(callback.Sender).OnMessageHandler(callback.Message, type);
                }
            });
            #endregion

            #region Group Chat
            msg.Handle <SteamFriends.ChatMsgCallback>(callback =>
            {
                GetUserHandler(callback.ChatterID).OnChatRoomMessage(callback.ChatRoomID, callback.ChatterID, callback.Message);
            });
            #endregion

            #region Disconnect
            msg.Handle <SteamUser.LoggedOffCallback> (callback =>
            {
                IsLoggedIn = false;
                Log.Warn("Logged off Steam.  Reason: {0}", callback.Result);
            });

            msg.Handle <SteamClient.DisconnectedCallback> (callback =>
            {
                if (IsLoggedIn)
                {
                    IsLoggedIn = false;
                    Log.Warn("Disconnected from Steam Network!");
                }

                SteamClient.Connect();
            });
            #endregion
        }