Skip to content

Commit

Permalink
added new google form (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
brucewzj99 authored May 12, 2024
1 parent 98fab78 commit 9c91418
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
58 changes: 29 additions & 29 deletions bot/telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def start(update, context):
return CS.SET_UP
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -126,11 +126,11 @@ def set_up(update, context) -> int:

except GoogleSheetError as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
except DatabaseError as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
except Exception as e:
update.message.reply_text(GSHEET_ERROR_TEXT)
Expand Down Expand Up @@ -207,7 +207,7 @@ def config_handler(update, context) -> int:
return CS.CONFIG_SETUP
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand All @@ -228,7 +228,7 @@ def config_setup(update, context) -> int:
return CS.CONFIG_CATEGORY
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END
update.callback_query.edit_message_text(END_TEXT, reply_markup=None)
Expand Down Expand Up @@ -264,7 +264,7 @@ def config_category(update, context) -> int:
return CS.CONFIG_SUBCATEGORY
except Exception as e:
update.callback_query.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand All @@ -288,7 +288,7 @@ def config_subcategory(update, context) -> int:
return CS.CONFIG_PAYMENT
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand All @@ -309,7 +309,7 @@ def config_payment(update, context) -> int:
return CS.CONFIG_SUBPAYMENT
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand All @@ -336,7 +336,7 @@ def config_subpayment(update, context) -> int:
return ConversationHandler.END
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand All @@ -358,7 +358,7 @@ def add_entry(update, context):
return CS.ENTRY
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -407,7 +407,7 @@ def remarks(update: Update, context) -> int:
return CS.CATEGORY
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -453,7 +453,7 @@ def category(update, context) -> int:
return CS.PAYMENT
except Exception as e:
update.callback_query.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -481,7 +481,7 @@ def subcategory(update, context) -> int:
return CS.PAYMENT
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -513,7 +513,7 @@ def payment(update, context) -> int:
update.callback_query.message.reply_text("Transaction logged.")
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -542,7 +542,7 @@ def subpayment(update, context) -> int:
update.callback_query.message.reply_text("Transaction logged.")
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -671,7 +671,7 @@ def add_transport(update, context):
)
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -700,7 +700,7 @@ def add_transport(update, context):
return CS.QUICK_ADD_TRANSPORT
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand All @@ -719,7 +719,7 @@ def add_others(update, context):
)
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand All @@ -737,7 +737,7 @@ def add_others(update, context):
)
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return CS.QUICK_ADD_CATEGORY

Expand Down Expand Up @@ -775,7 +775,7 @@ def quick_add(update, context) -> int:
return ConversationHandler.END
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END
except Exception as e:
Expand All @@ -784,7 +784,7 @@ def quick_add(update, context) -> int:


def help(update, context):
update.message.reply_text(HELP_TEXT)
update.message.reply_text(HELP_TEXT, parse_mode=ParseMode.HTML)


def get_day_transaction(update, context):
Expand All @@ -799,7 +799,7 @@ def get_day_transaction(update, context):
return CS.HANDLE_GET_TRANSACTION
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand All @@ -816,7 +816,7 @@ def get_overall(update, context):
return CS.HANDLE_GET_OVERALL
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -860,7 +860,7 @@ def handle_get_transaction(update, context):
return CS.HANDLE_GET_TRANSACTION
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -898,7 +898,7 @@ def handle_get_overall(update, context):
return CS.HANDLE_GET_OVERALL
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand All @@ -915,7 +915,7 @@ def add_income(update, context):
return CS.INCOME
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -944,7 +944,7 @@ def income(update, context) -> int:
return CS.WORK_PLACE
except Exception as e:
update.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -978,7 +978,7 @@ def cpf(update, context) -> int:
update.callback_query.message.reply_text(INCOME_LIMIT_TEXT)
except Exception as e:
update.callback_query.message.reply_text(
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down Expand Up @@ -1102,7 +1102,7 @@ def notify_preview(update, context):
query.edit_message_text(text="Message sending cancelled.")
except Exception as e:
query.edit_message_text(
text=ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e))
text=ERROR_TEXT + "\nError:\n" + utils.sanitize_error_message(str(e)), parse_mode=ParseMode.HTML
)
return ConversationHandler.END

Expand Down
6 changes: 4 additions & 2 deletions bot/text_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

GOOGLE_API_EMAIL = os.getenv("GOOGLE_API_EMAIL")
GOOGLE_TEMPLATE = "http://tinyurl.com/ymm-2024-expense-sheet"
GOOGLE_FORM = "https://forms.gle/kXySdv3Wjv7QmSug7"
SETUP_TEXT = (
"Please set up your Google sheet by following the steps below.\n\n"
+ f"1. Head over to <a href='{GOOGLE_TEMPLATE}'>Expense Tracker Template</a>\n"
Expand All @@ -14,7 +15,7 @@
+ "6. Copy your entire Google Sheet URL and send it over\n"
+ "Example: https://docs.google.com/spreadsheets/d/abcd1234/edit\n"
)
ERROR_TEXT = "There seems to be an error, please try again later. If the problem persists, please report it at github.com/brucewzj99/tele-tracker-v2/issues\nwith the error message.\n"
ERROR_TEXT = f"There seems to be an error, please try again later. If the problem persists, please report it over at this <a href='{GOOGLE_FORM}'>form.</a>\n"
SUCCESS_LINK_TEXT = "Google sheet successfully linked! Please proceed to configure your Dropdown sheet.\nOnce completed, type /addentry to add your first entry!"
GSHEET_ERROR_TEXT = f"There seems to be an error linking your google sheet, have you shared your Google Sheet with {GOOGLE_API_EMAIL} yet?"
GSHEET_WRONG_TEXT = (
Expand Down Expand Up @@ -49,13 +50,14 @@
+ "Remember to configure your Dropdown sheet to get started on this bot.\n\n"
+ "/config - Update Sheet Settings\n"
+ "/addentry - Add Expense Entry\n"
+ "/backlog - Add transaction in the past\n"
+ "/addtransport - Quick Add Transport Entry\n"
+ "/addothers - Quick Add Other Entry\n"
+ "/addincome - Add Income Entry\n"
+ "/getdaytransaction - Retrieve transaction from dates\n"
+ "/getoverall - Retrieve overall transaction for a month\n"
+ "/cancel - Cancel Conversation\n"
+ "\nTo report bugs or request any features, please create a issue at https://github.com/brucewzj99/tele-tracker-v2/issues\n"
+ f"\nTo report bugs, give your feedback or request any features, please do so via this <a href='{GOOGLE_FORM}'>form.</a>\n"
+ "\nYou can support me by buying me a coffee at https://ko-fi.com/brucewzj"
)

Expand Down
4 changes: 4 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Release Notes
## Version 2.4.1 - Date 12 May 2024
### Enhancement 🔥
- Added google form for reporting bugs, feedbacks and feature requests

## Version 2.4 - Date 6 May 2024
### Enhancement 🔥
- Clearer error messages for users
Expand Down

0 comments on commit 9c91418

Please sign in to comment.