11using System ;
22using System . Collections . Generic ;
3- using System . Linq ;
43using System . Threading ;
5- using Newtonsoft . Json ;
64using System . Reflection ;
5+ using System . ComponentModel ;
6+ using System . Windows . Forms ;
77
88namespace HourBoostr
99{
@@ -16,10 +16,9 @@ class Session
1616
1717
1818 /// <summary>
19- /// DateTime representing when all
20- /// accounts were initialized
19+ /// Session background worker
2120 /// </summary>
22- private DateTime mInitializedTime ;
21+ public BackgroundWorker mBwg = new BackgroundWorker ( ) ;
2322
2423
2524 /// <summary>
@@ -41,99 +40,93 @@ class Session
4140 public Session ( Config . Settings settings )
4241 {
4342 mSettings = settings ;
44- StartBotAccounts ( ) ;
45- }
46-
47-
48- /// <summary>
49- /// Returns the DateTime of when the application was built
50- /// </summary>
51- /// <returns>DateTime</returns>
52- private DateTime GetBuildDate ( )
53- {
54- var version = Assembly . GetEntryAssembly ( ) . GetName ( ) . Version ;
55- return new DateTime ( 2000 , 1 , 1 ) . Add ( new TimeSpan (
56- TimeSpan . TicksPerDay * version . Build +
57- TimeSpan . TicksPerSecond * 2 * version . Revision ) ) ;
58- }
59-
6043
61- /// <summary>
62- /// Gets the updated account settings from all active bots
63- /// </summary>
64- /// <returns>Config.Settings</returns>
65- public Config . Settings GetUpdatedSettings ( )
66- {
67- var settings = mSettings ;
68- settings . Accounts = new List < Config . AccountSettings > ( ) ;
69- mActiveBotList . ForEach ( o => settings . Accounts . Add ( o . mAccountSettings ) ) ;
70-
71- return settings ;
44+ mBwg . DoWork += MBwg_DoWork ;
45+ mBwg . RunWorkerAsync ( ) ;
7246 }
7347
7448
7549 /// <summary>
76- /// Main function
77- /// This is run on a seperate thread
78- /// This will initialize the bots
50+ /// Backgroundworker to start all bots
7951 /// </summary>
80- private void StartBotAccounts ( )
52+ private void MBwg_DoWork ( object sender , DoWorkEventArgs e )
8153 {
8254 /*Go through account and log them into steam*/
8355 foreach ( var account in mSettings . Accounts )
8456 {
85- if ( string . IsNullOrWhiteSpace ( account . Username ) )
86- continue ;
87-
8857 var bot = new Bot ( account ) ;
8958 mActiveBotList . Add ( bot ) ;
9059
60+ /*We'll wait for the bot to log in before starting on the next bot
61+ We won't wait for it to authenticate, should that be enabled*/
9162 while ( bot . mBotState == Bot . BotState . LoggedOut )
9263 Thread . Sleep ( 100 ) ;
9364 }
9465
95- if ( mActiveBotList . Count == 0 )
96- {
97- Console . WriteLine ( "No account were loaded." ) ;
98- Thread . Sleep ( 1500 ) ;
99- Environment . Exit ( 1 ) ;
100- }
101-
10266 /*Accounts statistics and some fucking baller ascii*/
10367 Console . Clear ( ) ;
10468 Console . WriteLine ( $ "\n _____ _ _ ") ;
10569 Console . WriteLine ( $ " | | |___ _ _ ___| |_ ___ ___ ___| |_ ___ ") ;
10670 Console . WriteLine ( $ " | | . | | | _| . | . | . |_ -| _| _|") ;
10771 Console . WriteLine ( $ " |__|__|___|___|_| |___|___|___|___|_| |_| \n ") ;
10872 Console . WriteLine ( $ " Source: https://github.com/Ezzpify/") ;
109- Console . WriteLine ( $ " Build date: { GetBuildDate ( ) . ToString ( ) } \n ") ;
73+ Console . WriteLine ( $ " Build date: { GetBuildDate ( ) . ToString ( ) } ") ;
74+ Console . WriteLine ( $ " Version: { Application . ProductVersion } \n ") ;
11075 Console . WriteLine ( $ " ----------------------------------------") ;
11176 Console . WriteLine ( $ "\n Loaded { mActiveBotList . Count } accounts\n \n Account list:") ;
112- mActiveBotList . ForEach ( o => Console . WriteLine ( " {0} | {1} Games" , o . mAccountSettings . Username , o . mSteam . games . Count ) ) ;
77+ mActiveBotList . ForEach ( o => Console . WriteLine ( " {0} | {1} Games" , o . mAccountSettings . Details . Username , o . mSteam . games . Count ) ) ;
11378 Console . WriteLine ( $ "\n \n Log:\n ----------------------------------------\n ") ;
114- mInitializedTime = DateTime . Now ;
11579
11680 /*Start status thread*/
11781 mThreadStatus = new Thread ( ThreadStatus ) ;
11882 mThreadStatus . Start ( ) ;
11983 }
12084
12185
86+ /// <summary>
87+ /// Returns the DateTime of when the application was built
88+ /// </summary>
89+ /// <returns>DateTime</returns>
90+ private DateTime GetBuildDate ( )
91+ {
92+ var version = Assembly . GetEntryAssembly ( ) . GetName ( ) . Version ;
93+ return new DateTime ( 2000 , 1 , 1 ) . Add ( new TimeSpan (
94+ TimeSpan . TicksPerDay * version . Build +
95+ TimeSpan . TicksPerSecond * 2 * version . Revision ) ) ;
96+ }
97+
98+
99+ /// <summary>
100+ /// Gets the updated account settings from all active bots
101+ /// </summary>
102+ /// <returns>Config.Settings</returns>
103+ public Config . Settings GetUpdatedSettings ( )
104+ {
105+ var settings = mSettings ;
106+ settings . Accounts = new List < Config . AccountSettings > ( ) ;
107+ mActiveBotList . ForEach ( o => settings . Accounts . Add ( o . mAccountSettings ) ) ;
108+
109+ return settings ;
110+ }
111+
112+
122113 /// <summary>
123114 /// Status for how long the bot has been running
124115 /// </summary>
125116 private void ThreadStatus ( )
126117 {
118+ var initializedTime = DateTime . Now ;
119+
127120 while ( true )
128121 {
129122 /*Get the current time then subtract the time when all bots were done initializing*/
130123 /*This will give us an idea of how long the bot has been running*/
131- TimeSpan timeSpan = DateTime . Now - mInitializedTime ;
124+ TimeSpan timeSpan = DateTime . Now - initializedTime ;
132125 string timeSpentOnline = string . Format ( "{0} Hours {1} Minutes {2} Seconds" ,
133126 ( timeSpan . Days * 24 ) + timeSpan . Hours , timeSpan . Minutes , timeSpan . Seconds ) ;
134-
135- Console . Title = string . Format ( "HourBoostr | Online for: {0}" , timeSpentOnline ) ;
136- Thread . Sleep ( 1000 ) ;
127+
128+ Console . Title = $ " { EndPoint . CONSOLE_TITLE } | Online for: { timeSpentOnline } " ;
129+ Thread . Sleep ( 800 ) ;
137130 }
138131 }
139132 }
0 commit comments