Skip to content

Commit

Permalink
fix: input text's encoding check
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanyu414 committed Jun 10, 2024
1 parent 30a1b8b commit 66ad0b2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ def handle_message(event, db_name = '../db.sqlite3'):
with ApiClient(configuration) as api_client:
line_bot_api = MessagingApi(api_client)


# check if user_id can be seen as utf-8
try:
event.source.user_id.encode('utf-8')
event.message.text.encode('utf-8')
except UnicodeEncodeError as unicode_encode_error:
raise unicode_encode_error

my_line = line.lineFunction(db_name)
line_success, line_user, line_error_message = my_line.create_line_user(event.source.user_id)
if not line_success and line_error_message == 'line_id already exists':
Expand Down

0 comments on commit 66ad0b2

Please sign in to comment.