Skip to content

Commit 7e75ade

Browse files
shgeokue
authored andcommitted
Fix flask-kitchensink (#151)
* Fix LocationSendMessage (location from user doesn't include title) * Add user_id in follow/unfollow events * Change environment variables error messages
1 parent bc91679 commit 7e75ade

File tree

1 file changed

+6
-8
lines changed
  • examples/flask-kitchensink

1 file changed

+6
-8
lines changed

examples/flask-kitchensink/app.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,8 @@
5252
# get channel_secret and channel_access_token from your environment variable
5353
channel_secret = os.getenv('LINE_CHANNEL_SECRET', None)
5454
channel_access_token = os.getenv('LINE_CHANNEL_ACCESS_TOKEN', None)
55-
if channel_secret is None:
56-
print('Specify LINE_CHANNEL_SECRET as environment variable.')
57-
sys.exit(1)
58-
if channel_access_token is None:
59-
print('Specify LINE_CHANNEL_ACCESS_TOKEN as environment variable.')
55+
if channel_secret is None or channel_access_token is None:
56+
print('Specify LINE_CHANNEL_SECRET and LINE_CHANNEL_ACCESS_TOKEN as environment variables.')
6057
sys.exit(1)
6158

6259
line_bot_api = LineBotApi(channel_access_token)
@@ -379,7 +376,7 @@ def handle_location_message(event):
379376
line_bot_api.reply_message(
380377
event.reply_token,
381378
LocationSendMessage(
382-
title=event.message.title, address=event.message.address,
379+
title='Location', address=event.message.address,
383380
latitude=event.message.latitude, longitude=event.message.longitude
384381
)
385382
)
@@ -445,13 +442,14 @@ def handle_file_message(event):
445442

446443
@handler.add(FollowEvent)
447444
def handle_follow(event):
445+
app.logger.info("Got Follow event:" + event.source.user_id)
448446
line_bot_api.reply_message(
449447
event.reply_token, TextSendMessage(text='Got follow event'))
450448

451449

452450
@handler.add(UnfollowEvent)
453-
def handle_unfollow():
454-
app.logger.info("Got Unfollow event")
451+
def handle_unfollow(event):
452+
app.logger.info("Got Unfollow event:" + event.source.user_id)
455453

456454

457455
@handler.add(JoinEvent)

0 commit comments

Comments
 (0)