fastapi-basic 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fastapi-basic might be problematic. Click here for more details.

@@ -11,3 +11,13 @@ class InternalBaseException(HTTPException):
11
11
  "data": kwargs,
12
12
  }
13
13
  super().__init__(status_code=status_code, detail=detail)
14
+
15
+ class LineBotException(HTTPException):
16
+ def __init__(self, status_code: int = status.HTTP_502_BAD_GATEWAY, code: str = "line_bot_error",
17
+ message: str = "Line bot error", **kwargs):
18
+ detail = {
19
+ "code": code,
20
+ "message": message,
21
+ "data": kwargs,
22
+ }
23
+ super().__init__(status_code=status_code, detail=detail)
@@ -0,0 +1,29 @@
1
+ from linebot import LineBotApi, WebhookHandler
2
+ from linebot.exceptions import LineBotApiError
3
+ from linebot.models import TextMessage, TextSendMessage
4
+
5
+ from ...exception.base_exception import LineBotException
6
+
7
+ class LineBot:
8
+ def __init__(self, channel_access_token: str, channel_secret: str):
9
+ self.channel_access_token = channel_access_token
10
+ self.channel_secret = channel_secret
11
+ self.line_bot_api = LineBotApi(self.channel_access_token)
12
+ self.handler = WebhookHandler(self.channel_secret)
13
+
14
+ async def reply_message(self, event, text: str):
15
+ try:
16
+ self.line_bot_api.reply_message(event.reply_token, TextMessage(text=text))
17
+
18
+ except LineBotApiError as err:
19
+ exception = LineBotException(str(err))
20
+ raise exception
21
+
22
+ async def push_message(self, line_uid: str, text: str):
23
+ try:
24
+ self.line_bot_api.push_message(line_uid, TextSendMessage(text=text))
25
+
26
+ except LineBotApiError as err:
27
+ message = f"Send line message fail, line_uid: {line_uid}, text: {text}, err: {str(err)}"
28
+ exception = LineBotException(message)
29
+ raise exception
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi_basic
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: A short description of your module
5
5
  Home-page: https://github.com/szx21023/fastapi-base
6
6
  Author: szx21023
@@ -22,6 +22,7 @@ Requires-Dist: fastapi==0.115.12
22
22
  Requires-Dist: h11==0.14.0
23
23
  Requires-Dist: idna==3.10
24
24
  Requires-Dist: jmespath==1.0.1
25
+ Requires-Dist: line-bot-sdk==3.12.0
25
26
  Requires-Dist: pydantic==2.11.3
26
27
  Requires-Dist: pydantic_core==2.33.1
27
28
  Requires-Dist: python-dateutil==2.9.0.post0
@@ -6,11 +6,12 @@ fastapi_basic/utils.py,sha256=8ympyQIXsKkxLILTI_7ug85vmKWYKqX0mpADjgHekgU,306
6
6
  fastapi_basic/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  fastapi_basic/database/mongodb.py,sha256=XW7ApqYkR1Jf7LM1HaZ6jzYgajzuu1whKw5cpsjSO-M,1017
8
8
  fastapi_basic/exception/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- fastapi_basic/exception/base_exception.py,sha256=xkpvAI8G96sqXqHgQC_rs2ZPL1liwKVXbXBIPF_8HPQ,473
9
+ fastapi_basic/exception/base_exception.py,sha256=VwMqn85rBeJCF6RIOYUR1eLxbP2aSDhhtAyyhYmBI84,855
10
10
  fastapi_basic/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  fastapi_basic/ext/aws/__init__.py,sha256=N_cwnbv1N-F1SY6NenBOTZe20zGaKFu3UXAu17hFAXY,816
12
12
  fastapi_basic/ext/aws/const.py,sha256=Mmb6lo11aZZDAVy-nK-v_JxtVPPKYUo9GB4ihH7XYuM,68
13
- fastapi_basic-0.1.1.dist-info/METADATA,sha256=vopBHifYhaFjN8jw_Vm1sL2b7uiWfBpiVU0UAJGV3SY,1740
14
- fastapi_basic-0.1.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
15
- fastapi_basic-0.1.1.dist-info/top_level.txt,sha256=Q9PdwWxaB4dy135MQHiroRYOqArdUSaIeEkzYinN6W0,14
16
- fastapi_basic-0.1.1.dist-info/RECORD,,
13
+ fastapi_basic/ext/line/__init__.py,sha256=HKk35M-gOoG3Ccfd2a7Dhy2OhVxuKHgq4qVmHLJXoNQ,1169
14
+ fastapi_basic-0.1.3.dist-info/METADATA,sha256=gVrxcP9DQw-MFVR_Mrp7nYx8YfCZyFGLi6B5lsFBss4,1776
15
+ fastapi_basic-0.1.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
16
+ fastapi_basic-0.1.3.dist-info/top_level.txt,sha256=Q9PdwWxaB4dy135MQHiroRYOqArdUSaIeEkzYinN6W0,14
17
+ fastapi_basic-0.1.3.dist-info/RECORD,,