Skip to content

Commit

Permalink
Merge pull request #16 from jakewheeler/py-deps
Browse files Browse the repository at this point in the history
Bump deps
  • Loading branch information
jakewheeler authored Jun 18, 2024
2 parents c2da149 + 198ee39 commit dd4b8aa
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ LineBotPy.code-workspace
.env
creds.json
.DS_Store
virtEnv/*
venv/*
42 changes: 28 additions & 14 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@

from flask import Flask, request, abort

from linebot import LineBotApi, WebhookHandler
from linebot.exceptions import InvalidSignatureError
from linebot.models import (
from linebot.v3 import (
WebhookHandler
)
from linebot.v3.exceptions import (
InvalidSignatureError
)
from linebot.v3.messaging import (
Configuration,
ApiClient,
MessagingApi,
ReplyMessageRequest,
TextMessage
)
from linebot.v3.webhooks import (
MessageEvent,
TextMessage,
TextSendMessage,
TextMessageContent
)

#### bot code ####
Expand All @@ -30,7 +40,7 @@
print("Specify LINE_CHANNEL_ACCESS_TOKEN as environment variable.")
sys.exit(1)

line_bot_api = LineBotApi(channel_access_token)
configuration = Configuration(access_token=channel_access_token)
handler = WebhookHandler(channel_secret)


Expand All @@ -56,23 +66,27 @@ def callback():


# Handle text messages
@handler.add(MessageEvent, message=TextMessage)
@handler.add(MessageEvent, message=TextMessageContent)
def handle_message(event):
# user_line_id = event.source.user_id
chat_msg = event.message.text

# handle all normal bot commands
response = bot.handle_cmd(chat_msg)
send_response(response, event.reply_token)


def send_response(response, reply_token):
if response != "":
line_bot_api.reply_message(reply_token, TextSendMessage(text=response))
if response == "":
return

with ApiClient(configuration) as api_client:
line_bot_api = MessagingApi(api_client)
line_bot_api.reply_message_with_http_info(
ReplyMessageRequest(
reply_token=event.reply_token,
messages=[TextMessage(text=response)]
)
)


if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
port = int(os.environ.get("PORT", 8000))
app.run(host="0.0.0.0", port=port)

6 changes: 6 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
flask
requests
gunicorn
line-bot-sdk
pytz
python-dotenv
111 changes: 86 additions & 25 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,86 @@
aiohttp==3.8.3
aiosignal==1.2.0
async-timeout==4.0.2
attrs==22.1.0
certifi==2022.9.24
charset-normalizer==2.1.1
click==8.1.3
Flask==2.2.2
frozenlist==1.3.1
future==0.18.2
gunicorn==20.1.0
idna==3.4
importlib-metadata==5.0.0
itsdangerous==2.1.2
Jinja2==3.1.2
line-bot-sdk==2.3.0
MarkupSafe==2.1.1
multidict==6.0.2
python-dotenv==0.21.0
pytz==2022.5
requests==2.28.1
urllib3==1.26.12
Werkzeug==2.2.2
yarl==1.8.1
zipp==3.10.0
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile
#
aenum==3.1.15
# via line-bot-sdk
aiohttp==3.9.5
# via line-bot-sdk
aiosignal==1.3.1
# via aiohttp
annotated-types==0.7.0
# via pydantic
attrs==23.2.0
# via aiohttp
blinker==1.8.2
# via flask
certifi==2024.6.2
# via requests
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via flask
deprecated==1.2.14
# via line-bot-sdk
flask==3.0.3
# via -r requirements.in
frozenlist==1.4.1
# via
# aiohttp
# aiosignal
future==1.0.0
# via line-bot-sdk
gunicorn==22.0.0
# via -r requirements.in
idna==3.7
# via
# requests
# yarl
itsdangerous==2.2.0
# via flask
jinja2==3.1.4
# via flask
line-bot-sdk==3.11.0
# via -r requirements.in
markupsafe==2.1.5
# via
# jinja2
# werkzeug
multidict==6.0.5
# via
# aiohttp
# yarl
packaging==24.1
# via gunicorn
pydantic==2.7.4
# via line-bot-sdk
pydantic-core==2.18.4
# via pydantic
python-dateutil==2.9.0.post0
# via line-bot-sdk
python-dotenv==1.0.1
# via -r requirements.in
pytz==2024.1
# via -r requirements.in
requests==2.31.0
# via
# -r requirements.in
# line-bot-sdk
six==1.16.0
# via python-dateutil
typing-extensions==4.12.2
# via
# pydantic
# pydantic-core
urllib3==2.2.2
# via
# line-bot-sdk
# requests
werkzeug==3.0.3
# via flask
wrapt==1.16.0
# via deprecated
yarl==1.9.4
# via aiohttp
2 changes: 1 addition & 1 deletion runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.9.15
python-3.12.4

0 comments on commit dd4b8aa

Please sign in to comment.