Skip to content

Commit 5d664dd

Browse files
committed
fix: 修复上次更改中出现的一些问题
refactor: 优化all flags的部分代码
1 parent 938cfcf commit 5d664dd

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

botpy/api.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ async def update_channel_user_permissions(
363363
Returns:
364364
成功执行返回`None`。
365365
"""
366-
payload = {"add": str(add.value), "remove": str(remove.value)}
366+
payload = {"add": str(add.value) if add else None, "remove": str(remove.value) if remove else None}
367367

368368
route = Route(
369369
"PUT", "/channels/{channel_id}/members/{user_id}/permissions", channel_id=channel_id, user_id=user_id
@@ -401,7 +401,7 @@ async def update_channel_role_permissions(
401401
Returns:
402402
成功执行返回`None`。
403403
"""
404-
payload = {"add": str(add.value), "remove": str(remove.value)}
404+
payload = {"add": str(add.value) if add else None, "remove": str(remove.value) if remove else None}
405405

406406
route = Route(
407407
"PUT", "/channels/{channel_id}/roles/{role_id}/permissions", channel_id=channel_id, role_id=role_id
@@ -492,15 +492,15 @@ async def recall_message(self, channel_id: str, message_id: str, hidetip: bool =
492492
Returns:
493493
成功执行返回`None`。
494494
"""
495+
params = {"hidetip": str(hidetip).lower()}
495496

496497
route = Route(
497498
"DELETE",
498-
"/channels/{channel_id}/messages/{message_id}?hidetip={hidetip}",
499+
"/channels/{channel_id}/messages/{message_id}",
499500
channel_id=channel_id,
500501
message_id=message_id,
501-
hidetip=str(hidetip).lower(),
502502
)
503-
return await self._http.request(route)
503+
return await self._http.request(route, params=params)
504504

505505
async def post_keyboard_message(
506506
self,
@@ -1113,8 +1113,8 @@ async def get_reaction_users(
11131113
type=emoji_type,
11141114
id=emoji_id,
11151115
)
1116-
path = {"limit": limit, "cookie": cookie}
1117-
return await self._http.request(route, params=path)
1116+
params = {"limit": limit, "cookie": cookie} if cookie else {"limit": limit}
1117+
return await self._http.request(route, params=params)
11181118

11191119
# 精华消息API
11201120
async def put_pin(self, channel_id: str, message_id: str) -> pins_message.PinsMessage:

botpy/flags.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ def __init__(self, **kwargs: bool) -> None:
128128
@classmethod
129129
def all(cls):
130130
"""打开所有事件的监听"""
131-
bits = max(cls.VALID_FLAGS.values()).bit_length()
132-
value = (1 << bits) - 1
131+
value = max(cls.VALID_FLAGS.values()) * 2 - 1
133132
self = cls.__new__(cls)
134133
self.value = value
135134
return self

0 commit comments

Comments
 (0)