示例#1
0
        /// <summary>
        /// Constructor to initialize variables and the class
        /// </summary>
        /// <param name="_gamesLibraryHelper"></param>
        /// <param name="_steamWeb"></param>
        /// <param name="_logger"></param>
        public CardFarmHelperClass(GamesLibraryHelperClass _gamesLibraryHelper, SteamWeb _steamWeb, Logger.Logger _logger)
        {
            m_steamWeb        = _steamWeb;
            m_steamUserWebAPI = new SteamUserWebAPI(m_steamWeb);

            m_logger = _logger;

            m_gamesLibraryHelper = _gamesLibraryHelper;
        }
        /// <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
        /// <summary>
        /// initialize the Bot
        /// </summary>
        /// <param name="_botInfo"></param>
        public Bot(BotInfo _botInfo)
        {
            // The Steamclient we are going to log on to
            m_steamClient = new SteamClient();

            // CallbackManager, which handles all callbacks we are going to get from the client
            m_callbackManager = new CallbackManager(m_steamClient);

            #region Callbacks
            #region SteamClient Callbacks
            m_callbackManager.Subscribe <SteamClient.ConnectedCallback>(OnConnected);
            m_callbackManager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected);
            #endregion

            #region SteamUser Callbacks
            m_steamUser = m_steamClient.GetHandler <SteamUser>();
            m_callbackManager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn);
            m_callbackManager.Subscribe <SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
            m_callbackManager.Subscribe <SteamUser.LoggedOffCallback>(OnLoggedOff);
            #endregion

            #region SteamFriends Callbacks
            m_steamFriends = m_steamClient.GetHandler <SteamFriends>();
            m_callbackManager.Subscribe <SteamFriends.FriendsListCallback>(OnLoadedFriendsList);
            m_callbackManager.Subscribe <SteamFriends.FriendMsgCallback>(OnMessageReceive);
            #endregion

            #region Custom Callbacks
            // Initialize the gamesLibraryHelper object here, because it inherits from "ClientMsgHandler"
            // We need the ClientMsgHandler to allow the callbackmanager to listen to our custom callbacks from steam
            // Because we are handling the received answer from steam inside the gamesLibraryHelpers method "HandleMsg" add it as handler to the steamclient
            // This sets internal the SteamClient so we do not have to pass the SteamClient to the methods we are using inside the Handler
            // Internally we are posting the response as Callback, so the callbackmanager passes the callback to our function so we can handle it if we want to
            m_gamesLibraryHelper = new GamesLibraryHelperClass();
            m_steamClient.AddHandler(m_gamesLibraryHelper);
            m_callbackManager.Subscribe <PurchaseResponseCallback>(OnPurchaseResponse);

            CustomHandler customHandler = new CustomHandler();
            m_steamClient.AddHandler(customHandler);
            m_callbackManager.Subscribe <NotificationCallback>(OnNotifications);
            #endregion
            #endregion

            // Check if all needed informations are given
            m_neededInfosAreGiven = CheckForNeededBotInfo(_botInfo);

            m_botName = _botInfo.BotName;
            m_admins  = _botInfo.Admins;
            m_acceptFriendRequests = _botInfo.AcceptFriendRequests;
            m_adminGroupToInviteTo = _botInfo.GroupToInviteTo;

            m_steamUserLogonDetails = new SteamUser.LogOnDetails
            {
                Username = _botInfo.Username,
                Password = _botInfo.Password,
                LoginID  = 20,
                ShouldRememberPassword = true
            };

            m_logger             = new Logger.Logger(_botInfo.Username);
            m_steamWeb           = new SteamWeb(m_steamUser, m_logger);
            m_chatHandler        = new ChatHandler(_botInfo);
            m_mobileHelper       = new MobileHelper(m_logger);
            m_tradeOfferHelper   = new TradeOfferHelperClass(m_mobileHelper, _botInfo, m_steamWeb, m_logger);
            m_steamUserWebAPI    = new SteamUserWebAPI(m_steamWeb);
            m_cardFarmHelper     = new CardFarmHelperClass(m_gamesLibraryHelper, m_steamWeb, m_logger);
            m_steamFriendsHelper = new SteamFriendsHelper();
            m_steamStoreWebAPI   = new SteamStoreWebAPI(m_steamWeb);
        }