Skip to content

Commit 5ef9386

Browse files
committed
• Only gather country image and steam avatar one time (fix)
• Fixed startup account (WTFF) • Added auto update detector!
1 parent 7f52e47 commit 5ef9386

9 files changed

Lines changed: 2224 additions & 32 deletions

File tree

ChatLogger/AccountLogin.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
248248
steamID = steamClient.SteamID.ConvertToUInt64().ToString();
249249
CurrentSteamID = steamClient.SteamID.ConvertToUInt64();
250250
myUserNonce = callback.WebAPIUserNonce;
251-
251+
UserCountry = callback.IPCountryCode;
252252

253253
IsLoggedIn = true;
254254

@@ -325,8 +325,7 @@ static void OnAccountInfo(SteamUser.AccountInfoCallback callback)
325325
UserPersonaName = callback.PersonaName;
326326
UserCountry = callback.Country;
327327
}
328-
329-
328+
330329
static void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
331330
{
332331
if (callback.EntryType == EChatEntryType.ChatMsg)

ChatLogger/ChatLogger.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,14 @@
135135
<Compile Include="SteamGuard.Designer.cs">
136136
<DependentUpon>SteamGuard.cs</DependentUpon>
137137
</Compile>
138+
<Compile Include="Update.cs">
139+
<SubType>Form</SubType>
140+
</Compile>
141+
<Compile Include="Update.Designer.cs">
142+
<DependentUpon>Update.cs</DependentUpon>
143+
</Compile>
138144
<Compile Include="User2Json\ChatLoggerSettings.cs" />
145+
<Compile Include="User2Json\GitHubApi.cs" />
139146
<Compile Include="User2Json\SteamLoginUsers.cs" />
140147
<Compile Include="User2Json\UserSettings.cs" />
141148
<EmbeddedResource Include="AddAcc.resx">
@@ -163,6 +170,9 @@
163170
<EmbeddedResource Include="SteamGuard.resx">
164171
<DependentUpon>SteamGuard.cs</DependentUpon>
165172
</EmbeddedResource>
173+
<EmbeddedResource Include="Update.resx">
174+
<DependentUpon>Update.cs</DependentUpon>
175+
</EmbeddedResource>
166176
<None Include="packages.config" />
167177
<None Include="Properties\Settings.settings">
168178
<Generator>SettingsSingleFileGenerator</Generator>

ChatLogger/EditAcc.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void EditSelected(string user)
4141

4242
var Settingslist = JsonConvert.DeserializeObject<ChatLoggerSettings>(File.ReadAllText(Program.SettingsJsonFile));
4343

44-
if (Settingslist.startupAcc == selectedSteamID)
44+
if (Settingslist.startupAcc == selectedSteamID && Settingslist.startupAcc.ToString().Length > 0)
4545
{
4646
toggle_autoLogin.Enabled = true;
4747
toggle_autoLogin.Checked = true;
@@ -63,15 +63,20 @@ private void BTN_SUBMIT_Click(object sender, EventArgs e)
6363
a.password = txtBox_pw.Text;
6464
}
6565
}
66+
File.WriteAllText(Program.AccountsJsonFile, JsonConvert.SerializeObject(list, Formatting.Indented));
6667

67-
string output = JsonConvert.SerializeObject(list, Formatting.Indented);
68-
File.WriteAllText(Program.AccountsJsonFile, output);
69-
7068
var Settingslist = JsonConvert.DeserializeObject<ChatLoggerSettings>(File.ReadAllText(Program.SettingsJsonFile));
71-
string SaveAccStartup = JsonConvert.SerializeObject(Settingslist, Formatting.Indented);
72-
File.WriteAllText(Program.SettingsJsonFile, SaveAccStartup);
7369

70+
if (!toggle_autoLogin.Checked)
71+
{
72+
Settingslist.startupAcc = 0;
73+
}
74+
else
75+
{
76+
Settingslist.startupAcc = selectedSteamID;
77+
}
7478

79+
File.WriteAllText(Program.SettingsJsonFile, JsonConvert.SerializeObject(Settingslist, Formatting.Indented));
7580
Close();
7681
}
7782

ChatLogger/Main.cs

Lines changed: 83 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,70 @@ public partial class Main : MetroFramework.Forms.MetroForm
2929
public static string SelectedUser = "";
3030
private static List<SteamLoginUsers> _users;
3131

32+
[Obsolete]
33+
private void RafadexAutoUpdate601IQ()
34+
{
35+
try
36+
{
37+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
38+
using (WebClient client = new WebClient())
39+
{
40+
client.Headers.Add("User-Agent", "Steam ChatLog");
41+
42+
43+
Uri uri = new Uri(Program.GITHUB_PROJECT);
44+
string releases = client.DownloadString(uri);
45+
var git = JsonConvert.DeserializeObject<List<GitHubApi.GithubRelease>>(releases);
46+
foreach (var g in git)
47+
{
48+
if (g.tag_name != Program.Version)
49+
{
50+
this.Hide();
51+
this.Enabled = false;
52+
Console.WriteLine("New update: " + g.tag_name);
53+
Form Update = new Update(g.tag_name);
54+
Update.Show();
55+
56+
}
57+
else
58+
{
59+
this.Enabled = true;
60+
var Settingslist = JsonConvert.DeserializeObject<ChatLoggerSettings>(File.ReadAllText(Program.SettingsJsonFile));
61+
62+
if (Settingslist.startupAcc != 0)
63+
{
64+
var list = JsonConvert.DeserializeObject<RootObject>(File.ReadAllText(Program.AccountsJsonFile));
65+
66+
foreach (var a in list.Accounts)
67+
{
68+
if (a.SteamID == Settingslist.startupAcc)
69+
{
70+
usernameJSON = a.username;
71+
passwordJSON = a.password;
72+
}
73+
}
74+
// Start Login
75+
Thread doLogin = new Thread(() => AccountLogin.UserSettingsGather(usernameJSON, passwordJSON));
76+
doLogin.Start();
77+
}
78+
}
79+
}
80+
}
81+
}
82+
catch (Exception tete)
83+
{
84+
InfoForm.InfoHelper.CustomMessageBox.Show("Alert", "Try https://github.com/sp0ok3r/ChatLogger");
85+
}
86+
}
87+
88+
89+
90+
3291
public Main()
3392
{
3493
InitializeComponent();
3594
metroTabControl.SelectedTab = metroTab_AddAcc;
3695
this.components.SetStyle(this);
37-
3896
Region = System.Drawing.Region.FromHrgn(Helpers.Extensions.CreateRoundRectRgn(0, 0, Width, Height, 5, 5));
3997

4098
lbl_connecting.Visible = false;
@@ -48,13 +106,14 @@ public Main()
48106

49107
private void Main_Shown(object sender, EventArgs e)
50108
{
109+
RafadexAutoUpdate601IQ();
51110
System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
52111
t.Tick += new EventHandler(Trolha_Tick);
53112
t.Interval = 2000;
54113
t.Start();
55114

56115
var Settingslist = JsonConvert.DeserializeObject<ChatLoggerSettings>(File.ReadAllText(Program.SettingsJsonFile));
57-
116+
58117
combox_Colors.SelectedIndex = Settingslist.startupColor;
59118

60119
if (Settingslist.Separator.Length > 0)
@@ -65,7 +124,8 @@ private void Main_Shown(object sender, EventArgs e)
65124
if (Settingslist.PathLogs.Length > 0)
66125
{
67126
txtBox_logDir.Text = Settingslist.PathLogs.Replace(@"\\", @"\");
68-
}else
127+
}
128+
else
69129
{
70130
Settingslist.PathLogs = Program.ChatLogsFolder;
71131
txtBox_logDir.Text = Program.ChatLogsFolder;
@@ -76,15 +136,19 @@ private void Main_Shown(object sender, EventArgs e)
76136
if (Settingslist.startup)
77137
{
78138
toggle_startWindows.Checked = true;
79-
}else{
139+
}
140+
else
141+
{
80142
toggle_startWindows.Checked = false;
81143
}
82144

83145
if (Settingslist.startMinimized)
84146
{
85147
chck_Minimized.Checked = true;
86148
this.WindowState = FormWindowState.Minimized;
87-
}else{
149+
}
150+
else
151+
{
88152
chck_Minimized.Checked = false;
89153
this.WindowState = FormWindowState.Normal;
90154
}
@@ -94,7 +158,7 @@ private void Main_Shown(object sender, EventArgs e)
94158
toggle_playSound.Checked = true;
95159
Stream str = Properties.Resources.ChatLogger_Success;
96160
SoundPlayer snd = new SoundPlayer(str);
97-
snd.Play();
161+
snd.Play();
98162
}
99163
else { toggle_playSound.Checked = false; }
100164
}
@@ -300,14 +364,19 @@ private void Trolha_Tick(object sender, EventArgs e)
300364
panel_steamStates.Visible = true;
301365
picBox_SteamAvatar.Visible = true;
302366

303-
byte[] data = new WebClient().DownloadData("https://www.countryflags.io/" + AccountLogin.UserCountry + "/flat/16.png");
304-
MemoryStream ms = new MemoryStream(data);
305-
btnLabel_PersonaAndFlag.Image = Image.FromStream(ms);
367+
if (picBox_SteamAvatar.Image == null && btnLabel_PersonaAndFlag.Image == null)
368+
{
369+
picBox_SteamAvatar.ImageLocation = AccountLogin.GetAvatarLink(AccountLogin.CurrentSteamID);
370+
371+
byte[] data = new WebClient().DownloadData("https://www.countryflags.io/" + AccountLogin.UserCountry + "/flat/16.png");
372+
373+
MemoryStream ms = new MemoryStream(data);
374+
btnLabel_PersonaAndFlag.Image = Image.FromStream(ms);
375+
}
306376

307377
btnLabel_PersonaAndFlag.Invoke(new Action(() => btnLabel_PersonaAndFlag.Text = AccountLogin.UserPersonaName));
308378

309379
panel_steamStates.BackColor = Color.LightSkyBlue;
310-
picBox_SteamAvatar.ImageLocation = AccountLogin.GetAvatarLink(AccountLogin.CurrentSteamID);
311380
lbl_currentUsername.Invoke(new Action(() => lbl_currentUsername.Text = AccountLogin.CurrentUsername));
312381
}
313382
else
@@ -321,7 +390,7 @@ private void Trolha_Tick(object sender, EventArgs e)
321390

322391

323392
btn_login2selected.Enabled = true;
324-
btnLabel_PersonaAndFlag.Image = Properties.Resources.notloggedFlag;
393+
//btnLabel_PersonaAndFlag.Image = Properties.Resources.notloggedFlag;
325394
btnLabel_PersonaAndFlag.Invoke(new Action(() => btnLabel_PersonaAndFlag.Text = "None"));
326395

327396

@@ -451,8 +520,8 @@ private void btn_setpathLogs_Click(object sender, EventArgs e)
451520
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
452521
{
453522
var Settingslist = JsonConvert.DeserializeObject<ChatLoggerSettings>(File.ReadAllText(Program.SettingsJsonFile));
454-
455-
Settingslist.PathLogs = fbd.SelectedPath;
523+
524+
Settingslist.PathLogs = fbd.SelectedPath;
456525
txtBox_logDir.Text = fbd.SelectedPath;
457526
File.WriteAllText(Program.SettingsJsonFile, JsonConvert.SerializeObject(Settingslist, new JsonSerializerSettings { Formatting = Formatting.Indented }));
458527
}
@@ -483,7 +552,4 @@ private void pictureBox1_Click(object sender, EventArgs e)
483552
Process.Start("https://github.com/sp0ok3r/ChatLogger");
484553
}
485554
}
486-
}
487-
488-
489-
//.Replace(@"\\", @"\");
555+
}

ChatLogger/Program.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ namespace ChatLogger
1010
static class Program
1111
{
1212
public static readonly string BOTNAME = "ChatLogger";
13-
public static readonly string BOTNAMELowerCaps = "ChatLogger";
1413

15-
public static readonly string spkDomain = "https://github.com/sp0ok3r/SteamChatLogger";
16-
public static readonly string Version = "1.0.0";
14+
public static readonly string GITHUB_PROJECT = "https://api.github.com/repos/sp0ok3r/ChatLogger/releases";
15+
public static readonly string Version = "1.0.1";
1716

1817

1918
public static readonly string ExecutablePath = Path.GetDirectoryName(Application.ExecutablePath);
@@ -22,9 +21,7 @@ static class Program
2221
public static readonly string SentryFolder = ExecutablePath + @"\Sentry\";
2322
public static readonly string ChatLogsFolder = ExecutablePath + @"\ChatLogs\";
2423

25-
/// <summary>
26-
/// The main entry point for the application.
27-
/// </summary>
24+
2825
[STAThread]
2926
static void Main()
3027
{

0 commit comments

Comments
 (0)