SetFromUInt64() public method

Sets the various components of this SteamID from a 64bit integer form.
public SetFromUInt64 ( System.UInt64 ulSteamID ) : void
ulSteamID System.UInt64 The 64bit integer to assign this SteamID from.
return void
        public void checkPeriodically(object sender, DoWorkEventArgs e)
        {
            Thread.Sleep(1000);//Wait 10s for Steambot to fully initialize
            while (true)
            {
                double newConversionRate = getConversionRate();
                if (newConversionRate != -1)
                    conversionRate = newConversionRate;

                DataSet verified_adds = returnQuery("SELECT * FROM add_verification a,users u WHERE verified=1 AND a.userID=u.userID");
                if (verified_adds != null)
                {
                    for (int r = 0; r < verified_adds.Tables[0].Rows.Count; r++)
                    {
                        BotManager.mainLog.Success("Add verified: " + verified_adds.Tables[0].Rows[r][2].ToString() + " DOGE to user " + verified_adds.Tables[0].Rows[r][1].ToString());
                        returnQuery("UPDATE users SET balance = balance + " + verified_adds.Tables[0].Rows[r][2].ToString() + " WHERE userID = " + verified_adds.Tables[0].Rows[r][1].ToString());
                        returnQuery("DELETE FROM add_verification WHERE addID = " + verified_adds.Tables[0].Rows[r][0].ToString());

                        SteamID userID = new SteamID();
                        userID.SetFromUInt64(ulong.Parse(verified_adds.Tables[0].Rows[r][6].ToString()));
                        Bot.SteamFriends.SendChatMessage(userID, EChatEntryType.ChatMsg, verified_adds.Tables[0].Rows[r][2].ToString() + " DOGE was successfully added to your tipping balance.");
                        BotManager.mainLog.Success("Registered user successfully added " + verified_adds.Tables[0].Rows[r][2].ToString() + " DOGE to their balance.");
                    }
                }
                Thread.Sleep(30000);
            }
        }
Example #2
0
        public void LongConstructorAndSetterGetterValid()
        {
            SteamID sid = new SteamID( 103582791432294076 );

            Assert.Equal( 2772668u, sid.AccountID );
            Assert.Equal( SteamID.AllInstances, sid.AccountInstance );
            Assert.Equal( EUniverse.Public, sid.AccountUniverse );
            Assert.Equal( EAccountType.Clan, sid.AccountType );

            sid.SetFromUInt64( 157626004137848889 );

            Assert.Equal( 12345u, sid.AccountID );
            Assert.Equal( SteamID.WebInstance, sid.AccountInstance );
            Assert.Equal( EUniverse.Beta, sid.AccountUniverse );
            Assert.Equal( EAccountType.GameServer, sid.AccountType );

            Assert.Equal( 157626004137848889ul, sid.ConvertToUInt64() );
        }
        private static EResult ResolveVanityURL(string input, EVanityURLType urlType, out SteamID steamID)
        {
            steamID = new SteamID();

            using (dynamic steamUser = WebAPI.GetInterface("ISteamUser", Settings.Current.Steam.WebAPIKey))
            {
                steamUser.Timeout = (int)TimeSpan.FromSeconds(5).TotalMilliseconds;

                KeyValue response;

                try
                {
                    response = steamUser.ResolveVanityURL( vanityurl: input, url_type: (int)urlType );
                }
                catch (WebException)
                {
                    return EResult.Timeout;
                }

                var eResult = (EResult)response["success"].AsInteger();

                if (eResult == EResult.OK)
                {
                    steamID.SetFromUInt64((ulong)response["steamid"].AsLong());
                }

                return eResult;
            }
        }
        private static bool TrySetSteamID(string input, out SteamID steamID)
        {
            steamID = new SteamID();

            if (steamID.SetFromString(input, EUniverse.Public)
            ||  steamID.SetFromSteam3String(input))
            {
                return true;
            }

            ulong numericInput;

            if (ulong.TryParse(input, out numericInput))
            {
                steamID.SetFromUInt64(numericInput);

                return true;
            }

            return false;
        }
        public void OnBefriend(SteamID id)
        {
            string msg = "Hey " + getSteamName(id) + "!";

            DataSet valid_user = returnQuery("SELECT * FROM users WHERE SteamID64=" + id.ConvertToUInt64().ToString());
            bool registered = (valid_user.Tables[0].Rows.Count > 0);

            if (registered)
            {
                DataSet pending_tips = returnQuery("SELECT * FROM tips t WHERE notified=0 AND receiverID64=" + id.ConvertToUInt64().ToString());
                for (int t = 0; t < pending_tips.Tables[0].Rows.Count; t++)
                {
                    SteamID sender = new SteamID();
                    sender.SetFromUInt64(ulong.Parse(pending_tips.Tables[0].Rows[t][1].ToString()));

                    msg += "\n" + getTipNotification(sender, (double)pending_tips.Tables[0].Rows[t][3], (string)pending_tips.Tables[0].Rows[t][4], (string)pending_tips.Tables[0].Rows[t][8], (bool)pending_tips.Tables[0].Rows[t][7]);

                    BotManager.mainLog.Info("Notified user " + getSteamName(id) + " of " + pending_tips.Tables[0].Rows[t][3] +" DOGE tip.");
                }
                returnQuery("UPDATE tips SET notified = 1 WHERE receiverID64 = " + id.ConvertToUInt64().ToString());
            }

            if (registered)
            {
                if (!(bool)valid_user.Tables[0].Rows[0][3])
                    returnQuery("UPDATE users SET responded = 1 WHERE SteamID64 = " + id.ConvertToUInt64().ToString());
            }
            else
            {
                msg += "\n" + "It appears you have not registered yet. Type +register to get started.";
            }

            msg += "\nI have sent you an invite to my group 'DogeTipGroup'. Please accept it!.";
            msg += "\n(this is because I can only have a limited amount of people in my friend list)";
            sendMessage(id, null, false, msg);

            Bot.InviteUserToGroup(id, clanID);

            Bot.SteamFriends.RemoveFriend(id);

            BotManager.mainLog.Info("Player " + getSteamName(id) + " added me.");
        }
Example #6
0
        void ProcessEvent(int key, ExpandoObject obj)
        {
            //Console.WriteLine("Key " + key + " NextLogPos: " + (NextLogPos-1));

            if (key < Interlocked.Read(ref NextLogPos) - 1)
            {
                //Console.WriteLine("Ignoring...");
                return;
            }

            var evt = obj as IDictionary <string, object>;

            if (!evt.ContainsKey("action"))
            {
                return;
            }

            int action;

            if (!Int32.TryParse(evt["action"] as string, out action))
            {
                return;
            }

            string steamid = String.Empty;

            if (evt.ContainsKey("steamid"))
            {
                steamid = evt["steamid"] as string;
            }

            var steamId = new SteamID();

            steamId.SetFromUInt64(UInt64.Parse(steamid));

            if (steamId == OwnSteamId)
            {
                return;
            }

            var appid = evt["appid"] as int?;

            var tradeEvent = new TradeEvent();

            tradeEvent.sender = steamId;

            bool enqueue     = false;
            bool loadForeign = false;

            switch (action)
            {
            case 0: // Item added/remove
            case 1:
            {
                var item = new TradeItem();
                tradeEvent.type = (action == 0) ?
                                  ETradeEventType.ItemAdded : ETradeEventType.ItemRemoved;
                item.appid = appid.Value;
                int.TryParse(evt["assetid"] as string, out item.assetid);
                int.TryParse(evt["contextid"] as string, out item.contextid);
                tradeEvent.item = item;
                if (ForeignInventory == null)
                {
                    LoadForeignInventory(steamId, item.appid, item.contextid);
                    loadForeign = true;
                }
                enqueue = true;
                break;
            }

            case 2: // Ready/unready
            case 3:
            {
                tradeEvent.type = (action == 2) ?
                                  ETradeEventType.Ready : ETradeEventType.Unready;
                var timestamp = evt["timestamp"] as int?;
                tradeEvent.timestamp = (uint)timestamp.Value;
                enqueue = true;
                break;
            }

            case 4: // Confirmed
            {
                tradeEvent.type = ETradeEventType.Confirmed;
                var timestamp = evt["timestamp"] as int?;
                tradeEvent.timestamp = (uint)timestamp.Value;
                enqueue = true;
                break;
            }

            case 7: // Chat message
            {
                string text = String.Empty;
                if (evt.ContainsKey("text"))
                {
                    text = evt["text"] as string;
                }
                tradeEvent.type    = ETradeEventType.Message;
                tradeEvent.message = text;
                enqueue            = true;
                break;
            }

            default:
                Console.WriteLine("Invalid action: " + action);
                break;
            }

            if (loadForeign)
            {
                PendingEvents.Enqueue(tradeEvent);
            }
            else if (enqueue)
            {
                Events.Enqueue(tradeEvent);
            }

            ResetTimer();
        }
        /// <summary>
        /// Tip a user!
        /// </summary>
        public bool command_tip(SteamID sender, SteamID chatID, bool isChatroom)
        {
            if (!user_registered)
            {
                sendMessage(sender, chatID, isChatroom, "You have not registered yet! Type '+register' to get started.");
                return false;
            }

            string message_msg = "";
            user_message = user_message.Replace("\"", "'");
            if (user_message.Contains("'"))
            {
                message_msg = user_message.Substring(user_message.IndexOf("'") + 1, user_message.LastIndexOf("'") - user_message.IndexOf("'") - 1);
                user_message = user_message.Remove(user_message.IndexOf("'") - 1, 2 + user_message.LastIndexOf("'") - user_message.IndexOf("'"));

                message_msg.Replace("'", "");
                user_message.Replace("  ", " ").Replace("'","");//also remove ' for SQL safety
            }

            if (message_msg.Length > 140)
            {
                sendMessage(sender, chatID, isChatroom, "The message you are trying to send is too long. Maximum length is 140 characters.");
                return false;
            }

            string[] message_words = user_message.Split(' ');
            if (message_words.Length < 3)
            {
                sendMessage(sender, chatID, isChatroom, "Sorry, invalid query! Type '+help' for info.");
                return false;
            }
            string message_receiver = message_words[1];
            string message_amount = message_words[2];
            string fulllabel = "";
            double amount;
            if (user_message.Split('\"').Length > 3)
            {
                sendMessage(sender, chatID, isChatroom, "Sorry, invalid query! Type '+help' for info.");
                return false;
            }
            if (!double.TryParse(message_amount.Replace('.', ','), out amount))
            {
                // Amount if not a number. Is it one of the tip amount commands?
                for (int l = 0; l < labels.Length; l++)
                {
                    if (message_amount.Equals(labels[l].label))
                    {
                        if(labels[l].currency==DogeLabel.Currency.USD)
                            amount = Math.Round(labels[l].amount/conversionRate);
                        else
                            amount = labels[l].amount;
                        fulllabel = labels[l].fulllabel;
                        break;
                    }
                }
                if (amount == 0)
                {
                    sendMessage(sender, chatID, isChatroom, "Sorry, invalid amount! Type '+help' for info.");
                    return false;
                }
            }
            if (amount < 5)
            {
                sendMessage(sender, chatID, isChatroom, "Sorry, minimal tip is 5 DOGE. This is in order to prevent spam.");
                return false;
            }
            if (amount > user_balance)
            {
                sendMessage(sender, chatID, isChatroom, "You don't have enough dogecoin for this tip.");
                return false;
            }

            string receiverID64 = "";
            if (message_receiver.Contains("steamcommunity"))
            {
                receiverID64 = getSteamID64(message_receiver);
            }
            else
            {
                message_receiver = message_receiver.Replace("\"", "").Replace("'", "");
                DataSet existing = returnQuery("SELECT * FROM aliases where userID64=" + sender.ConvertToUInt64().ToString() + " AND alias ='" + message_receiver + "'");
                if (existing.Tables[0].Rows.Count > 0)
                    receiverID64 = existing.Tables[0].Rows[0][2].ToString();
            }

            ulong receiverID64ulong;
            if (!ulong.TryParse(receiverID64, out receiverID64ulong))
            {
                sendMessage(sender, chatID, isChatroom, "Sorry, player not found and/or invalid URL! Type '+help' for info.");
                return false;
            }
            if (receiverID64ulong == sender.ConvertToUInt64())
            {
                sendMessage(sender, chatID, isChatroom, "You can't tip yourself silly!");
                return false;
            }

            SteamID receiverID = new SteamID();
            receiverID.SetFromUInt64(receiverID64ulong);

            Tip new_tip = new Tip();
            new_tip.sender = sender;
            new_tip.receiver = receiverID;
            new_tip.amount = amount;
            new_tip.donation = false;
            new_tip.anonymous = false;
            new_tip.message = message_msg;
            new_tip.label = fulllabel;

            if (user_message.Contains(" anon") || user_message.Contains(" anonymous"))
                new_tip.anonymous = true;

            string msg = "Are you sure you want to tip " + getSteamName(new_tip.receiver);
            if (fulllabel.Equals(""))
                msg += " " + new_tip.amount.ToString() + " DOGE";
            else
                msg += " " + new_tip.label + " (" + new_tip.amount.ToString() + " DOGE)";
            if (new_tip.anonymous)
                msg += " anonymously";
            if (!new_tip.message.Equals(""))
                msg += " with the message '"+new_tip.message+"'";
            msg += "?\nPlease type +yes or +no.";
            sendMessage(sender, chatID, isChatroom, msg);

            tip_confirmation.Add(sender);
            tip_pending.Add(new_tip);

            BotManager.mainLog.Info("Player " + getSteamName(sender) + " wants to send a tip (" + amount.ToString() + " DOGE)");
            return true;
        }
Example #8
0
        void ProcessEvent(int key, ExpandoObject obj)
        {
            //Console.WriteLine("Key " + key + " NextLogPos: " + (NextLogPos-1));

            if (key < Interlocked.Read(ref NextLogPos) - 1)
            {
                //Console.WriteLine("Ignoring...");
                return;
            }

            var evt = obj as IDictionary<string, object>;

            if (!evt.ContainsKey("action"))
                return;

            int action;
            if (!Int32.TryParse(evt["action"] as string, out action))
                return;

            string steamid = String.Empty;
            if (evt.ContainsKey("steamid"))
                steamid = evt["steamid"] as string;

            var steamId = new SteamID();
            steamId.SetFromUInt64(UInt64.Parse(steamid));

            if (steamId == OwnSteamId)
                return;

            var appid = evt["appid"] as int?;

            var tradeEvent = new TradeEvent();
            tradeEvent.sender = steamId;

            bool enqueue = false;
            bool loadForeign = false;

            switch (action)
            {
            case 0: // Item added/remove
            case 1:
            {
                var item = new TradeItem();
                tradeEvent.type = (action == 0) ?
                    ETradeEventType.ItemAdded : ETradeEventType.ItemRemoved;
                item.appid = appid.Value;
                int.TryParse(evt["assetid"] as string, out item.assetid);
                int.TryParse(evt["contextid"] as string, out item.contextid);
                tradeEvent.item = item;
                if (ForeignInventory == null)
                {
                    LoadForeignInventory(steamId, item.appid, item.contextid);
                    loadForeign = true;
                }
                enqueue = true;
                break;
            }
            case 2: // Ready/unready
            case 3:
            {
                tradeEvent.type = (action == 2) ?
                    ETradeEventType.Ready : ETradeEventType.Unready;
                var timestamp = evt["timestamp"] as int?;
                tradeEvent.timestamp = (uint)timestamp.Value;
                enqueue = true;
                break;
            }
            case 4: // Confirmed
            {
                tradeEvent.type = ETradeEventType.Confirmed;
                var timestamp = evt["timestamp"] as int?;
                tradeEvent.timestamp = (uint)timestamp.Value;
                enqueue = true;
                break;
            }
            case 7: // Chat message
            {
                string text = String.Empty;
                if (evt.ContainsKey("text"))
                    text = evt["text"] as string;
                tradeEvent.type = ETradeEventType.Message;
                tradeEvent.message = text;
                enqueue = true;
                break;
            }
            default:
                Console.WriteLine("Invalid action: " + action);
                break;
            }

            if (loadForeign)
                PendingEvents.Enqueue(tradeEvent);
            else if (enqueue)
                Events.Enqueue(tradeEvent);

            ResetTimer();
        }