Skip to content

Commit 5cd95a7

Browse files
rnevetRaanan Nevet
authored andcommitted
Notify every 24Hrs
1 parent 2cd2718 commit 5cd95a7

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

plugins/AccountStats.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sqlite3
77

88
BITCOIN_GENESIS_BLOCK_DATE = "2009-01-03 18:15:05"
9-
9+
DAY_IN_SEC = 86400
1010
DB_DROP = "DROP TABLE IF EXISTS history"
1111
DB_CREATE = "CREATE TABLE IF NOT EXISTS history(" \
1212
"id INTEGER UNIQUE, open TIMESTAMP, close TIMESTAMP," \
@@ -23,6 +23,8 @@
2323

2424

2525
class AccountStats(Plugin):
26+
last_notification = 0
27+
2628
def on_bot_init(self):
2729
super(AccountStats, self).on_bot_init()
2830
self.init_db()
@@ -102,6 +104,9 @@ def notify_daily(self):
102104
self.log.log_error('AccountStats DB isn\'t ready.')
103105
return
104106

107+
if self.last_notification != 0 and self.last_notification + DAY_IN_SEC > sqlite3.time.time():
108+
return
109+
105110
cursor = self.db.execute(DB_GET_24HR_EARNED)
106111
output = ''
107112
for row in cursor:
@@ -113,6 +118,7 @@ def notify_daily(self):
113118
output += str(row[0]) + ' ' + str(row[1]) + ' in total\n'
114119
cursor.close()
115120
if output != '':
121+
self.last_notification = sqlite3.time.time()
116122
output = 'Earnings:\n----------\n' + output
117123
self.log.notify(output, self.notify_config)
118124
self.log.log(output)

0 commit comments

Comments
 (0)