Skip to content

Commit b2eabe1

Browse files
committed
init
1 parent d5bb05f commit b2eabe1

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

bot/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ class ConversationState(Enum):
3232
INCOME,
3333
WORK_PLACE,
3434
CPF,
35-
) = range(24)
35+
BACKLOG,
36+
) = range(25)

bot/telegram_bot.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,18 @@ def config_subpayment(update, context) -> int:
298298

299299

300300
def add_entry(update, context):
301-
context.user_data.clear()
301+
print(context.user_data)
302+
if context.user_data.get("backlog"):
303+
reply = update.callback_query.data
304+
if utils.check_date_format(reply):
305+
day, month = reply.split(" ")
306+
else:
307+
update.callback_query.message.reply_text(
308+
BACKLOG_DATE_TEXT
309+
)
310+
return add_entry(update, context)
311+
else:
312+
context.user_data.clear()
302313
telegram_id = update.effective_user.id
303314
context.user_data["sheet_id"] = db.get_user_sheet_id(telegram_id)
304315
update.message.reply_text(
@@ -812,6 +823,15 @@ def cpf(update, context) -> int:
812823
update.callback_query.message.reply_text(ERROR_TEXT)
813824
return ConversationHandler.END
814825

826+
def backlog(update, context) -> int:
827+
context.user_data.clear()
828+
telegram_id = update.effective_user.id
829+
context.user_data["sheet_id"] = db.get_user_sheet_id(telegram_id)
830+
update.message.reply_text(
831+
BACKLOG_DATE_TEXT
832+
)
833+
context.user_data["backlog"] = True
834+
return add_entry(update, context)
815835

816836
def setup_handlers(dispatcher):
817837
# Configuration-related states and handlers
@@ -867,6 +887,7 @@ def setup_handlers(dispatcher):
867887
CommandHandler("addincome", add_income),
868888
CommandHandler("getdaytransaction", get_day_transaction),
869889
CommandHandler("getoverall", get_overall),
890+
CommandHandler("backlog", backlog),
870891
],
871892
states={
872893
CS.SET_UP: [MessageHandler(Filters.text & ~Filters.command, set_up)],

bot/text_str.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@
6868
CHOOSE_INCOME_SOURCE_TEXT = "Please choose your income source"
6969
CPF_TEXT = "Is there CPF?"
7070
INCOME_LIMIT_TEXT = "You have exceed the number of income allowed! (max 6)"
71+
72+
BACKLOG_DATE_TEXT = "Please enter the date of the entry in this format: DD MMM\ne.g 16 Mar"

0 commit comments

Comments
 (0)