mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-22 02:25:56 +08:00
🚑 safely get dict value
This commit is contained in:
parent
67770ffa6f
commit
d2ae2e2982
@ -237,8 +237,8 @@ class Bot(BaseBot):
|
|||||||
async with httpx.AsyncClient(headers=headers) as client:
|
async with httpx.AsyncClient(headers=headers) as client:
|
||||||
response = await client.post(
|
response = await client.post(
|
||||||
self.api_root + api,
|
self.api_root + api,
|
||||||
json=data["body"],
|
json=data.get("body", {}),
|
||||||
params=data["query"],
|
params=data.get("query", {}),
|
||||||
timeout=self.config.api_timeout)
|
timeout=self.config.api_timeout)
|
||||||
if 200 <= response.status_code < 300:
|
if 200 <= response.status_code < 300:
|
||||||
result = response.json()
|
result = response.json()
|
||||||
@ -293,7 +293,7 @@ class Bot(BaseBot):
|
|||||||
at_sender = at_sender and bool(event.get_user_id())
|
at_sender = at_sender and bool(event.get_user_id())
|
||||||
|
|
||||||
if at_sender and receive_id_type != "union_id":
|
if at_sender and receive_id_type != "union_id":
|
||||||
msg = MessageSegment.at(event.get_user_id(), "StarHeart") + " " + msg
|
msg = MessageSegment.at(event.get_user_id()) + " " + msg
|
||||||
|
|
||||||
msg_type, content = MessageSerializer(msg).serialize()
|
msg_type, content = MessageSerializer(msg).serialize()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user