1- using ChatLogger . User2Json ;
1+ using ChatLogger . Helpers ;
2+ using ChatLogger . User2Json ;
23using ChatLogger . UserSettings ;
34using Newtonsoft . Json ;
45using SteamKit2 ;
@@ -16,6 +17,7 @@ namespace ChatLogger
1617 public class AccountLogin
1718 {
1819 public static string UserPersonaName , UserCountry , CurrentUsername ;
20+ public static int CurrentPersonaState = 1 ;
1921
2022 public static SteamClient steamClient ;
2123 public static SteamUser steamUser ;
@@ -173,7 +175,7 @@ static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
173175
174176 if ( is2FA )
175177 {
176- SteamGuard SteamGuard = new SteamGuard ( "Phone" , user ) ;
178+ SteamGuard SteamGuard = new SteamGuard ( "Phone" , user ) ;
177179 SteamGuard . ShowDialog ( ) ;
178180
179181 bool UserInputCode = true ;
@@ -251,15 +253,23 @@ static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
251253 UserCountry = callback . IPCountryCode ;
252254
253255 IsLoggedIn = true ;
254-
255- steamFriends . SetPersonaState ( EPersonaState . Online ) ;
256-
256+ var ListUserSettings = JsonConvert . DeserializeObject < RootObject > ( File . ReadAllText ( Program . AccountsJsonFile ) ) ;
257+ foreach ( var a in ListUserSettings . Accounts )
258+ {
259+ if ( a . username == user )
260+ {
261+ steamFriends . SetPersonaState ( Extensions . statesList [ a . LoginState ] ) ;
262+ a . LastLoginTime = DateTimeOffset . UtcNow . ToUnixTimeSeconds ( ) . ToString ( ) ;
263+ CurrentPersonaState = a . LoginState ;
264+ }
265+ }
266+ File . WriteAllText ( Program . AccountsJsonFile , JsonConvert . SerializeObject ( ListUserSettings , Formatting . Indented ) ) ;
257267 }
258268
259269 static void OnDisconnected ( SteamClient . DisconnectedCallback callback )
260270 {
261271 DisconnectedCounter ++ ;
262-
272+ CurrentPersonaState = 0 ;
263273 if ( isRunning )
264274 {
265275 if ( DisconnectedCounter >= MaxDisconnects )
@@ -275,7 +285,7 @@ static void OnDisconnected(SteamClient.DisconnectedCallback callback)
275285
276286 steamClient . Connect ( ) ;
277287 }
278-
288+
279289 static void OnLoginKey ( SteamUser . LoginKeyCallback callback )
280290 {
281291 myUniqueId = callback . UniqueID . ToString ( ) ;
@@ -304,6 +314,7 @@ static void OnLoginKey(SteamUser.LoginKeyCallback callback)
304314 static void OnLoggedOff ( SteamUser . LoggedOffCallback callback )
305315 {
306316 IsLoggedIn = false ;
317+ CurrentPersonaState = 0 ;
307318 Console . WriteLine ( "[" + Program . BOTNAME + "] - Logged off of Steam: {0}" , callback . Result ) ;
308319 InfoForm . InfoHelper . CustomMessageBox . Show ( "Error" , "Logged off of Steam:" + callback . Result ) ;
309320 }
@@ -325,7 +336,7 @@ static void OnAccountInfo(SteamUser.AccountInfoCallback callback)
325336 UserPersonaName = callback . PersonaName ;
326337 UserCountry = callback . Country ;
327338 }
328-
339+
329340 static void OnFriendMsg ( SteamFriends . FriendMsgCallback callback )
330341 {
331342 if ( callback . EntryType == EChatEntryType . ChatMsg )
@@ -335,7 +346,7 @@ static void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
335346 string Message = callback . Message ; Message = Regex . Replace ( Message , @"\t|\n|\r" , "" ) ; //741iq
336347
337348 var Settingslist = JsonConvert . DeserializeObject < ChatLoggerSettings > ( File . ReadAllText ( Program . SettingsJsonFile ) ) ;
338-
349+
339350 string pathLog = Settingslist . PathLogs + @"\ChatLogs\" + steamClient . SteamID . ConvertToUInt64 ( ) + @"\[" + FriendID + "] - " + steamFriends . GetFriendPersonaName ( FriendID ) + ".txt" ;
340351
341352
@@ -428,6 +439,7 @@ public static void Logout()
428439 IsLoggedIn = false ;
429440 steamUser . LogOff ( ) ;
430441 DisconnectedCounter = 0 ;
442+ CurrentPersonaState = 0 ;
431443 CurrentUsername = null ;
432444 }
433445
0 commit comments