void OnTimerElapsed(object sender, ElapsedEventArgs e) { byte[] avatarHash = bot.SteamFriends.GetFriendAvatar(bot.SteamUser.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(bot.SteamUser.SteamID, avatarHash, AvatarDownloaded); } else { AvatarHash = null; avatarBox.Image = ComposeAvatar(null); } bot.LoadFriends(); if (Application.OpenForms.Count < 1) { Friends friends = new Friends(bot, steam_name.Text); friends.Show(); friends.Activate(); } friends_list.SetObjects(ListFriends.Get(showOnlineFriendsOnlyToolStripMenuItem.Checked)); Console.WriteLine("Friends list refreshed."); }
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 { } } }
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(); }
private void Friends_Load(object sender, EventArgs e) { friends_list.Height = friends_list.Height + list_friendreq.Height; friends_list.Location = new Point(friends_list.Left, friends_list.Top - list_friendreq.Height); byte[] avatarHash = bot.SteamFriends.GetFriendAvatar(bot.SteamUser.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(bot.SteamUser.SteamID, avatarHash, AvatarDownloaded); } else { AvatarHash = null; avatarBox.Image = ComposeAvatar(null); } }