Skip to content

Commit 60af125

Browse files
committed
Fix
1 parent 14ecfa2 commit 60af125

3 files changed

Lines changed: 5 additions & 33 deletions

File tree

README.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ WebhookParser
118118
parser = linebot.v3.WebhookParser(
119119
'YOUR_CHANNEL_SECRET',
120120
skip_signature_verification=lambda: False
121+
)
121122
122123
parse(self, body, signature, as_payload=False)
123124
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -137,7 +138,7 @@ If the signature does NOT match, ``InvalidSignatureError`` is raised.
137138
payload = parser.parse(body, signature, as_payload=True)
138139
139140
for event in payload.events:
140-
do_something(payload.event, payload.destination)
141+
do_something(event, payload.destination)
141142
142143
WebhookHandler
143144
~~~~~~~~~~~~~~
@@ -155,6 +156,7 @@ WebhookHandler
155156
handler = linebot.v3.WebhookHandler(
156157
'YOUR_CHANNEL_SECRET',
157158
skip_signature_verification=lambda: False
159+
)
158160
159161
handle(self, body, signature)
160162
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -174,7 +176,7 @@ Add a **handler** method by using this decorator.
174176

175177
.. code:: python
176178
177-
@handler.add(MessageEvent, message=TextMessage)
179+
@handler.add(MessageEvent, message=TextMessageContent)
178180
def handle_message(event):
179181
line_bot_client.reply_message(
180182
ReplyMessageRequest(
@@ -183,7 +185,7 @@ Add a **handler** method by using this decorator.
183185
)
184186
)
185187
186-
When the event is an instance of MessageEvent and event.message is an instance of TextMessage,
188+
When the event is an instance of MessageEvent and event.message is an instance of TextMessageContent,
187189
this handler method is called.
188190

189191
.. code:: python

linebot/v3/async_line_bot_client.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,6 @@ async def __aenter__(self):
201201
async def __aexit__(self, exc_type, exc_value, traceback):
202202
await self.close()
203203

204-
def __enter__(self):
205-
return self
206-
207-
def __exit__(self, exc_type, exc_value, traceback):
208-
self.close_sync()
209-
210204
async def close(self) -> None:
211205
"""Close all underlying async API clients."""
212206
await self._audience_api_client.close()
@@ -217,16 +211,6 @@ async def close(self) -> None:
217211
await self._moduleattach_api_client.close()
218212
await self._shop_api_client.close()
219213

220-
def close_sync(self) -> None:
221-
"""Synchronously close all underlying async API clients (best-effort)."""
222-
self._audience_api_client.__exit__(None, None, None)
223-
self._insight_api_client.__exit__(None, None, None)
224-
self._liff_api_client.__exit__(None, None, None)
225-
self._messaging_api_client.__exit__(None, None, None)
226-
self._module_api_client.__exit__(None, None, None)
227-
self._moduleattach_api_client.__exit__(None, None, None)
228-
self._shop_api_client.__exit__(None, None, None)
229-
230214
def add_audience_to_audience_group(self, add_audience_to_audience_group_request : AddAudienceToAudienceGroupRequest, async_req : Optional[bool] = None, **kwargs) -> Union[None, Awaitable[None]]:
231215
"""add_audience_to_audience_group # noqa: E501
232216

tools/generate_unified_client.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -637,26 +637,12 @@ def generate_async_client(
637637
lines.append(' await self.close()')
638638
lines.append('')
639639

640-
# Sync context manager (AsyncApiClient also supports it)
641-
lines.append(' def __enter__(self):')
642-
lines.append(' return self')
643-
lines.append('')
644-
lines.append(' def __exit__(self, exc_type, exc_value, traceback):')
645-
lines.append(' self.close_sync()')
646-
lines.append('')
647-
648640
lines.append(' async def close(self) -> None:')
649641
lines.append(' """Close all underlying async API clients."""')
650642
for mod in unique_modules:
651643
lines.append(f' await self._{mod}_api_client.close()')
652644
lines.append('')
653645

654-
lines.append(' def close_sync(self) -> None:')
655-
lines.append(' """Synchronously close all underlying async API clients (best-effort)."""')
656-
for mod in unique_modules:
657-
lines.append(f' self._{mod}_api_client.__exit__(None, None, None)')
658-
lines.append('')
659-
660646
# Delegating methods — async client methods are actually ``def`` (not ``async def``).
661647
# They return ``Union[T, Awaitable[T]]``. We delegate as-is.
662648
for cdef, method, call_args in all_methods:

0 commit comments

Comments
 (0)