Skip to content

Commit 6029533

Browse files
committed
v2.0.0 deployed version
1 parent a24f83b commit 6029533

File tree

9 files changed

+63
-10
lines changed

9 files changed

+63
-10
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,7 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161+
.vercel
162+
163+
# My stuff
164+
test_func.py

.vercelignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test.py
2+
LICENSE
3+
release_notes.md
4+
README.md

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Tele-Tracker Bot
22
A python telegram bot to help track daily expenses onto google sheet, hosted on Vercel using Flask.
3+
34
[Version 1](https://github.com/brucewzj99/tele-tracker) was hosted locally with a different version of python-telegram-bot
45

56
## Release Notes

api/templates/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<body>
7272
<div class="container">
7373
<div class="child">
74-
<img src="https://github.com/brucewzj99/tele-tracker-v2/tree/master/api/templates/logo.png" alt="Logo" class="logo" />
74+
<img src="https://github.com/brucewzj99/tele-tracker-v2/blob/main/api/templates/logo.png?raw=true" alt="Logo" class="logo" />
7575
<h1 class="title">tele-tracker-bot</h1>
7676
<h2 class="subtitle">A python telegram bot to help track expenses!</h2>
7777
<p>You can access the bot using this <a href="https://t.me/telefinance_tracker_bot">link</a>.

bot/firebase.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,17 @@ def check_if_user_exists(telegram_id):
2121
def get_user_sheet_id(telegram_id):
2222
ref = db.reference("/users/" + str(telegram_id) + "/sheet_id")
2323
return ref.get()
24+
25+
26+
def get_all_user_id():
27+
ref = db.reference("/users/")
28+
user_ids = [int(user_id) for user_id in ref.get().keys()]
29+
return user_ids
30+
31+
32+
def get_all_sheet_id():
33+
ref = db.reference("/users/")
34+
sheet_ids = []
35+
for value in ref.get().values():
36+
sheet_ids.append(value["sheet_id"])
37+
return sheet_ids

bot/telegram_bot.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,15 @@ def config(update, context):
123123
update.message.reply_text(
124124
"How can i help you today?", reply_markup=create_inline_markup(list)
125125
)
126-
return CS.CONFIG__HANDLER
126+
return CS.CONFIG_HANDLER
127127

128128

129129
def config_handler(update, context) -> int:
130130
reply = update.callback_query.data
131131
update.callback_query.answer()
132132
if reply == "Cancel":
133-
cancel(update, context)
133+
update.callback_query.edit_message_text(END_TEXT, reply_markup=None)
134+
return ConversationHandler.END
134135
update.callback_query.edit_message_text(reply, reply_markup=None)
135136
if reply == "Change Google Sheet":
136137
update.callback_query.message.reply_text(SETUP_TEXT)
@@ -155,15 +156,15 @@ def config_handler(update, context) -> int:
155156
return CS.CONFIG_SETUP
156157
elif reply == "Configure Quick Others":
157158
context.user_data["config"] = EntryType.OTHERS
158-
msg = f'This is your current Others settings.\nClick on "Add new" to add a new one (max 5).\nIf you wish to update, you will have to do so manually in the "Tracker" sheet.\n\nPayment, Category\n'
159+
msg = QUICK_OTHER_TEXT
159160
setting_list = gs.get_quick_add_others(context.user_data["sheet_id"])
160161
keyboard_list = []
161162
if setting_list == None:
162163
msg = f"{msg}No settings found\n"
163164
else:
164165
for setting in setting_list:
165166
msg = f"{msg}{setting}\n"
166-
if len(setting_list) < 5:
167+
if len(setting_list) < QUICK_OTHER_LIMIT:
167168
keyboard_list.append("Add new")
168169
keyboard_list.append("Cancel")
169170
update.callback_query.message.reply_text(
@@ -192,7 +193,8 @@ def config_setup(update, context) -> int:
192193
except Exception as e:
193194
update.callback_query.message.reply_text(ERROR_TEXT)
194195
return ConversationHandler.END
195-
cancel(update, context)
196+
update.callback_query.edit_message_text(END_TEXT, reply_markup=None)
197+
return ConversationHandler.END
196198

197199

198200
def config_category(update, context) -> int:

bot/text_str.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,19 @@
4141

4242
QUICK_SETUP_TRANSPORT = "You have not set up your quick add settings for transport yet, please do so by typing /config"
4343
QUICK_SETUP_OTHER = "You have not set up your quick add settings for others yet, please do so by typing /config"
44+
QUICK_OTHER_LIMIT = 5 # max i can go is 10, but testing with 5 first
45+
QUICK_OTHER_TEXT = f'This is your current Others settings.\nClick on "Add new" to add a new one (max {QUICK_OTHER_LIMIT}).\nIf you wish to update, you will have to do so manually in the "Tracker" sheet.\n\nPayment, Category\n'
4446

4547
HELP_TEXT = (
4648
"To get started, please type /start\n"
4749
+ "Remember to configure your Dropdown sheet to get started on this bot.\n\n"
48-
+ "To configure, type /config\n"
49-
+ "To add entry, type /addentry\n"
50-
+ "To add transport quickly, type /addtransport\n"
51-
+ "To add others quickly, type /addothers\n"
50+
+ "/config - Update Sheet Settings"
51+
+ "/addentry - Add Expense Entry\n"
52+
+ "/addtransport - Quick Add Transport Entry\n"
53+
+ "/addothers - Quick Add Other Entry\n"
54+
+ "/addincome - Add Income Entry\n"
55+
+ "/retrievetransaction - Retrieve transaction from dates\n"
56+
+ "/cancel - Cancel Conversation\n"
5257
)
5358

5459
RETRIEVE_TRANSACTION_TEXT = "Please specify the date and month you wish to retrieve from in this format: DD MMM\ne.g 16 Mar\nor use /cancel to exit"

bot/updates.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from telegram import Bot
2+
import os
3+
import bot.firebase as fb
4+
5+
TOKEN = os.environ.get("BOT_TOKEN")
6+
bot = Bot(token=TOKEN)
7+
8+
9+
def send_new_feature_message(new_feature_message):
10+
users = fb.get_all_user_id()
11+
for user_id in users:
12+
bot.send_message(chat_id=user_id, text=new_feature_message)
13+
14+
15+
def update_gsheet():
16+
sheet_ids = fb.get_all_sheet_id()
17+
for sheet_id in sheet_ids:
18+
pass # gs.update_gsheet(sheet_id)

vercel.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rewrites": [
3+
{ "source": "/(.*)", "destination": "/api/index" }
4+
]
5+
}

0 commit comments

Comments
 (0)