public bool GetFriendGamePlayed(ulong steam_id, ref ulong game_id, ref uint server_ip, ref ushort server_port) { var id = new SteamKit2.SteamID(steam_id); game_id = f.GamePlayed(id); return(true); }
public static string GetSteamIDInfo(SteamBot.Bot bot, SteamKit2.SteamID steamId) { string output = ""; output += "| steamname: " + bot.SteamFriends.GetFriendPersonaName(steamId); output += "\r\n| steamID32: " + steamId.ToString(); output += "\r\n| steamID64: http://steamcommunity.com/profiles/" + steamId.ConvertToUInt64(); output += "\r\n| steamrep: http://steamrep.com/profiles/" + steamId.ConvertToUInt64(); return(output); }
static public void setBotInventory(SteamKit2.SteamID botID, int defindex, int count) { try { MySqlCommand cmd = new MySqlCommand(String.Format("INSERT INTO bot_inventory (bot_id,defindex,count) VALUES ({0},{1},{2}) ON DUPLICATE KEY UPDATE count={2};", botID.ConvertToUInt64(), defindex, count), conn); cmd.ExecuteNonQuery(); } catch (Exception e) { log.Error("Error caching inventory: " + e.Message); } }
static public void wipeBotInventory(SteamKit2.SteamID botID) { try { MySqlCommand cmd = new MySqlCommand("DELETE FROM bot_inventory WHERE bot_id=" + botID.ConvertToUInt64(), conn); cmd.ExecuteNonQuery(); } catch (Exception e) { log.Error("Error wiping cache inventory: " + e.Message); } }
private void status_update_DoWork(object sender, DoWorkEventArgs e) { while (!status_update.CancellationPending) { try { this.steam_name.Text = bot.SteamFriends.GetFriendPersonaName(userSteamId); this.steam_status.Text = bot.SteamFriends.GetFriendPersonaState(userSteamId).ToString(); SteamKit2.SteamID SteamID = userSteamId; byte[] avatarHash = bot.SteamFriends.GetFriendAvatar(SteamID); bool validHash = avatarHash != null && !IsZeros(avatarHash); if ((AvatarHash == null && !validHash && avatarBox.Image != null) || (AvatarHash != null && AvatarHash.SequenceEqual(avatarHash))) { // avatar is already up to date, no operations necessary } else if (validHash) { AvatarHash = avatarHash; CDNCache.DownloadAvatar(SteamID, avatarHash, AvatarDownloaded); } else { AvatarHash = null; avatarBox.Image = ComposeAvatar(null); } if (this.steam_status.Text != prevStatus) { UpdateChat("[" + DateTime.Now + "] " + steam_name.Text + " is now " + steam_status.Text + "." + Environment.NewLine, false); if (Friends.keepLog) { AppendLog(userSteamId, "[" + DateTime.Now + "] " + steam_name.Text + " is now " + steam_status.Text + "." + Environment.NewLine); } prevStatus = this.steam_status.Text; } if (this.steam_name.Text != prevName) { UpdateChat("[" + DateTime.Now + "] " + prevName + " has changed their name to " + steam_name.Text + "." + Environment.NewLine, false); if (Friends.keepLog) { AppendLog(userSteamId, "[" + DateTime.Now + "] " + prevName + " has changed their name to " + steam_name.Text + "." + Environment.NewLine); } ListFriends.UpdateName(userSteamId, steam_name.Text); prevName = this.steam_name.Text; } System.Threading.Thread.Sleep(2000); } catch { } } }
static public int getUserRank(SteamKit2.SteamID id) { try { MySqlCommand cmd = new MySqlCommand("SELECT `rank_id` FROM users WHERE steam_id=" + id.ConvertToUInt64(), conn); return((int)cmd.ExecuteScalar()); } catch (Exception e) { log.Error("Error updating user rank: " + e.Message); } return(-1); }
public void AddChat(string name, SteamKit2.SteamID steamId) { page = new TabPage(); page.Tag = steamId; page.Text = name; page.BackColor = System.Drawing.Color.White; chatTab = new ChatTab(this, bot, steamId); chatTab.Dock = DockStyle.Fill; page.Controls.Add(chatTab); this.ChatTabControl.TabPages.Add(page); this.ChatTabControl.SelectTab(page); this.Text = this.ChatTabControl.SelectedTab.Text + " - Chat"; }
public void GetChatLog() { var userAccountId = new SteamKit2.SteamID(userSteamId).AccountID; var botAccountId = bot.SteamUser.SteamID.AccountID; var url = "http://steamcommunity.com/chat/chatlog/" + userAccountId; var data = new System.Collections.Specialized.NameValueCollection(); data.Add("sessionid", bot.sessionId); var response = SteamTrade.SteamWeb.Fetch(url, "POST", data, bot.botCookies, true, "http://steamcommunity.com/chat/"); try { List <string> history = new List <string>(); var json = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(response); foreach (var item in json) { ulong accountId = item.m_unAccountID; ulong timestamp = item.m_tsTimestamp; string message = item.m_strMessage; DateTime time = UnixTimeStampToDateTime(timestamp); if (accountId == userAccountId) { string date = "[" + time + "] "; string name = bot.SteamFriends.GetFriendPersonaName(userSteamId) + ": "; message = date + name + message + "" + Environment.NewLine; history.Add(message); } else if (accountId == botAccountId) { string date = "[" + time + "] "; string name = Bot.DisplayName + ": "; message = date + name + message + "" + Environment.NewLine; history.Add(message); } } string historyMessage = ""; foreach (var line in history) { historyMessage += line; } text_log.Invoke((Action)(() => { text_log.AppendText(historyMessage, Color.Gray); })); } catch (Exception ex) { Console.WriteLine(ex); } checkrep.RunWorkerAsync(); }
public ChatTab(Chat chat, Bot bot, ulong sid) { InitializeComponent(); this.Chat = chat; this.userSteamId = sid; this.bot = bot; this.StyleManager.OnThemeChanged += metroStyleManager1_OnThemeChanged; this.StyleManager.Theme = Friends.GlobalStyleManager.Theme; this.StyleManager.Style = Friends.GlobalStyleManager.Style; Util.LoadTheme(null, this.Controls, this); this.Theme = Friends.GlobalStyleManager.Theme; this.StyleManager.Style = Friends.GlobalStyleManager.Style; metroStyleManager1_OnThemeChanged(null, EventArgs.Empty); try { this.steam_name.Text = prevName = bot.SteamFriends.GetFriendPersonaName(sid); this.steam_status.Text = prevStatus = bot.SteamFriends.GetFriendPersonaState(sid).ToString(); } catch { } this.chat_status.Text = ""; SteamKit2.SteamID SteamID = sid; try { byte[] avatarHash = bot.SteamFriends.GetFriendAvatar(SteamID); bool validHash = avatarHash != null && !IsZeros(avatarHash); if ((AvatarHash == null && !validHash && avatarBox.Image != null) || (AvatarHash != null && AvatarHash.SequenceEqual(avatarHash))) { // avatar is already up to date, no operations necessary } else if (validHash) { AvatarHash = avatarHash; CDNCache.DownloadAvatar(SteamID, avatarHash, AvatarDownloaded); } else { AvatarHash = null; avatarBox.Image = ComposeAvatar(null); } } catch { } new System.Threading.Thread(GetChatLog).Start(); status_update.RunWorkerAsync(); text_input.Focus(); }
protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { timer.Dispose(); } userID = null; reminder = null; disposed = true; } }
public int GetChatMessage(ulong steam_id, int msg_index, ref Core.Util.Buffer b, ref uint msg_type) { var id = new SteamKit2.SteamID(steam_id); var cm = f.GetChatMessage(id, msg_index); if (cm != null) { var total_wrote = Math.Min(b.Length(), cm.Message.Length); b.Reset(); b.Write(cm.Message.ToCharArray()); msg_type = (uint)cm.Type; return(total_wrote); } return(0); }
private void button_ok_Click(object sender, EventArgs e) { if (text_profile.Text == "" || Regex.IsMatch(text_profile.Text, "^[A-Za-z]$")) { MetroFramework.MetroMessageBox.Show(this, "The SteamID64 is invalid. It cannot be blank or contain letters.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { SteamKit2.SteamID id = Convert.ToUInt64(text_profile.Text); bot.SteamFriends.AddFriend(id); this.Close(); MetroFramework.MetroMessageBox.Show(this, "Friend added successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } }
public static System.Drawing.Color GetColorFromPersonaState(SteamBot.Bot bot, SteamKit2.SteamID steamId) { var state = bot.SteamFriends.GetFriendPersonaState(steamId); if (state != SteamKit2.EPersonaState.Offline) { var isPlayingGame = !string.IsNullOrEmpty(bot.SteamFriends.GetFriendGamePlayedName(steamId)); if (isPlayingGame) { return((System.Drawing.Color)System.Drawing.ColorTranslator.FromHtml("#81b900")); } else { return((System.Drawing.Color)System.Drawing.ColorTranslator.FromHtml("#5db2ff")); } } return(System.Drawing.ColorTranslator.FromHtml("#8a8a8a")); }
public void GetChatLog() { var userAccountId = new SteamKit2.SteamID(userSteamId).AccountID; var botAccountId = bot.SteamUser.SteamID.AccountID; var url = "http://steamcommunity.com/chat/chatlog/" + userAccountId; var data = new System.Collections.Specialized.NameValueCollection(); data.Add("sessionid", bot.sessionId); var response = SteamTrade.SteamWeb.Fetch(url, "POST", data, bot.botCookies, true, "http://steamcommunity.com/chat/"); try { List<string> history = new List<string>(); var json = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(response); foreach (var item in json) { ulong accountId = item.m_unAccountID; ulong timestamp = item.m_tsTimestamp; string message = item.m_strMessage; DateTime time = UnixTimeStampToDateTime(timestamp); if (accountId == userAccountId) { string date = "[" + time + "] "; string name = bot.SteamFriends.GetFriendPersonaName(userSteamId) + ": "; message = date + name + message + "" + Environment.NewLine; history.Add(message); } else if (accountId == botAccountId) { string date = "[" + time + "] "; string name = Bot.DisplayName + ": "; message = date + name + message + "" + Environment.NewLine; history.Add(message); } } string historyMessage = ""; foreach (var line in history) historyMessage += line; text_log.Invoke((Action)(() => { text_log.AppendText(historyMessage, Color.Gray); })); } catch (Exception ex) { Console.WriteLine(ex); } checkrep.RunWorkerAsync(); }
public void SendMsgToFriend(ulong dest_steam_id, uint msg_type, string message_body) { var steam_id = new SteamKit2.SteamID(dest_steam_id); f.SendMsgToFriend(steam_id, (SteamKit2.EChatEntryType)msg_type, message_body); }