Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
init
  • Loading branch information
brucewzj99 committed Dec 16, 2023
commit b2eabe182401edf6fcf618c55795d400ea1f08c5
3 changes: 2 additions & 1 deletion bot/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ class ConversationState(Enum):
INCOME,
WORK_PLACE,
CPF,
) = range(24)
BACKLOG,
) = range(25)
23 changes: 22 additions & 1 deletion bot/telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,18 @@ def config_subpayment(update, context) -> int:


def add_entry(update, context):
context.user_data.clear()
print(context.user_data)
if context.user_data.get("backlog"):
reply = update.callback_query.data
if utils.check_date_format(reply):
day, month = reply.split(" ")
else:
update.callback_query.message.reply_text(
BACKLOG_DATE_TEXT
)
return add_entry(update, context)
else:
context.user_data.clear()
telegram_id = update.effective_user.id
context.user_data["sheet_id"] = db.get_user_sheet_id(telegram_id)
update.message.reply_text(
Expand Down Expand Up @@ -812,6 +823,15 @@ def cpf(update, context) -> int:
update.callback_query.message.reply_text(ERROR_TEXT)
return ConversationHandler.END

def backlog(update, context) -> int:
context.user_data.clear()
telegram_id = update.effective_user.id
context.user_data["sheet_id"] = db.get_user_sheet_id(telegram_id)
update.message.reply_text(
BACKLOG_DATE_TEXT
)
context.user_data["backlog"] = True
return add_entry(update, context)

def setup_handlers(dispatcher):
# Configuration-related states and handlers
Expand Down Expand Up @@ -867,6 +887,7 @@ def setup_handlers(dispatcher):
CommandHandler("addincome", add_income),
CommandHandler("getdaytransaction", get_day_transaction),
CommandHandler("getoverall", get_overall),
CommandHandler("backlog", backlog),
],
states={
CS.SET_UP: [MessageHandler(Filters.text & ~Filters.command, set_up)],
Expand Down
2 changes: 2 additions & 0 deletions bot/text_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@
CHOOSE_INCOME_SOURCE_TEXT = "Please choose your income source"
CPF_TEXT = "Is there CPF?"
INCOME_LIMIT_TEXT = "You have exceed the number of income allowed! (max 6)"

BACKLOG_DATE_TEXT = "Please enter the date of the entry in this format: DD MMM\ne.g 16 Mar"