File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66import sqlite3
77
88BITCOIN_GENESIS_BLOCK_DATE = "2009-01-03 18:15:05"
9-
9+ DAY_IN_SEC = 86400
1010DB_DROP = "DROP TABLE IF EXISTS history"
1111DB_CREATE = "CREATE TABLE IF NOT EXISTS history(" \
1212 "id INTEGER UNIQUE, open TIMESTAMP, close TIMESTAMP," \
2323
2424
2525class 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 )
You can’t perform that action at this time.
0 commit comments