|
7 | 7 | logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) |
8 | 8 |
|
9 | 9 | db = DBHelper() |
10 | | -f = open("master.txt", "r") |
11 | | -master = int(f.readline()) |
12 | | -if not master: |
13 | | - logging.error("Error occurred, have you filled the master.txt file with your master id?") |
14 | | - exit() |
15 | 10 |
|
16 | 11 |
|
17 | 12 | handler = MessageHandler() |
|
29 | 24 | # i found those code here https://apps.timwhitlock.info/emoji/tables/unicode :) |
30 | 25 | emoji = { |
31 | 26 | "moneybag": u'\U0001F4B0', |
32 | | - "moneywings": u'\U0001F4B8' |
| 27 | + "moneywings": u'\U0001F4B8', |
| 28 | + "openhands": u'\U0001F450' |
33 | 29 | } |
34 | 30 |
|
35 | 31 |
|
@@ -70,16 +66,22 @@ def text_handler(text, chat_id): |
70 | 66 | month = datetime.now().strftime("%m") |
71 | 67 | rows = db.get_income(month) |
72 | 68 | logging.info(rows) |
73 | | - message = "Current month income list:\n\n" |
74 | | - for r in rows: |
75 | | - message = message + str(r).replace("(", "").replace(")", "").replace("'", "") + "\n" |
| 69 | + if rows: |
| 70 | + message = "Current month income list:\n\n" |
| 71 | + for r in rows: |
| 72 | + message = message + str(r).replace("(", "").replace(")", "").replace("'", "") + "\n" |
| 73 | + else: |
| 74 | + message = "No income to be displayed here " + emoji["openhands"] |
76 | 75 | elif text == "/listoutcome": |
77 | 76 | month = datetime.now().strftime("%m") |
78 | 77 | rows = db.get_outcome(month) |
79 | 78 | logging.info(rows) |
80 | | - message = "Current month outcome list:\n\n" |
81 | | - for r in rows: |
82 | | - message = message+str(r).replace("(", "").replace(")", "").replace("'", "")+"\n" |
| 79 | + if rows: |
| 80 | + message = "Current month outcome list:\n\n" |
| 81 | + for r in rows: |
| 82 | + message = message+str(r).replace("(", "").replace(")", "").replace("'", "")+"\n" |
| 83 | + else: |
| 84 | + message = "No income to be displayed here " + emoji["openhands"] |
83 | 85 | handler.send_message(message, chat_id) |
84 | 86 |
|
85 | 87 |
|
|
0 commit comments