Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding "Users Served" counter. Resolves #2
- Loading branch information
1 parent
4dacc1c
commit 37161e1
Showing
5 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import stats_storage | ||
import setting_storage | ||
|
||
async def handle_view_stats (client, message, name, channel): | ||
stats_string = f""" | ||
**Fates Served:** {stats_storage.stats["fates_delivered"]} | ||
**Users:** {setting_storage.get_users_count()} | ||
**Helpless Users:** {setting_storage.get_helpless_users_count()} | ||
""" | ||
await client.send_message(channel, stats_string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pickle | ||
import os | ||
|
||
stats = {} | ||
|
||
def increment_fate(): | ||
stats["fates_delivered"] += 1 | ||
|
||
async def save_stats(): | ||
output = open('stats.pkl', 'wb') | ||
|
||
pickle.dump(stats, output) | ||
output.close() | ||
|
||
def load_stats(): | ||
global stats | ||
if (os.path.isfile('stats.pkl')): | ||
input = open('stats.pkl', 'rb') | ||
stats = pickle.load(input) | ||
input.close() | ||
else: | ||
stats = {} | ||
stats["fates_delivered"] = 0 |