Skip to content

Commit

Permalink
Fixed asStaff for delete_message in Community
Browse files Browse the repository at this point in the history
  • Loading branch information
wittiness committed Jun 22, 2023
1 parent 9b60d1d commit 561a3ac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pymino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__author__ = 'cynical'
__license__ = 'MIT'
__copyright__ = 'Copyright 2023 Cynical'
__version__ = '1.2.1.5'
__version__ = '1.2.1.6'
__description__ = 'A Python wrapper for the aminoapps.com API'

from .bot import Bot as Bot
Expand Down
25 changes: 14 additions & 11 deletions pymino/ext/async_community.py
Original file line number Diff line number Diff line change
Expand Up @@ -4477,20 +4477,23 @@ async def delete_message(self, chatId: str, messageId: str, asStaff: bool = Fals
... else:
... print("Failed to delete message.")
"""
return ApiResponse(
await self.session.handler(
method="POST",
url=f"/x{self.community_id if comId is None else comId}/s/chat/thread/{chatId}/message/{messageId}/admin",
data={
if asStaff:
request_method = "POST"
url = f"/x{self.community_id if comId is None else comId}/s/chat/thread/{chatId}/message/{messageId}/admin"
data = {
"adminOpName": 102,
"adminOpNote": {"content": reason},
"timestamp": int(time() * 1000)
}
)) if asStaff else ApiResponse(
await self.session.handler(
method="DELETE",
url=f"/x{self.community_id if comId is None else comId}/s/chat/thread/{chatId}/message/{messageId}"
))
} if reason is not None else {
"adminOpName": 102,
"timestamp": int(time() * 1000)
}
else:
request_method = "DELETE"
url = f"/x{self.community_id if comId is None else comId}/s/chat/thread/{chatId}/message/{messageId}"
data = None

return ApiResponse(await self.session.handler(method=request_method, url=url, data=data))


@community
Expand Down
24 changes: 14 additions & 10 deletions pymino/ext/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -4407,19 +4407,23 @@ def delete_message(self, chatId: str, messageId: str, asStaff: bool = False, rea
... else:
... print("Failed to delete message.")
"""
return ApiResponse(
self.session.handler(
method = "POST",
url = f"/x{self.community_id if comId is None else comId}/s/chat/thread/{chatId}/message/{messageId}/admin",
if asStaff:
request_method = "POST"
url = f"/x{self.community_id if comId is None else comId}/s/chat/thread/{chatId}/message/{messageId}/admin"
data = {
"adminOpName": 102,
"adminOpNote": {"content": reason},
"timestamp": int(time() * 1000)
"adminOpName": 102,
"adminOpNote": {"content": reason},
"timestamp": int(time() * 1000)
} if reason is not None else {
"adminOpName": 102,
"timestamp": int(time() * 1000)
}
)) if asStaff else ApiResponse(self.session.handler(
method = "DELETE",
else:
request_method = "DELETE"
url = f"/x{self.community_id if comId is None else comId}/s/chat/thread/{chatId}/message/{messageId}"
))
data = None

return ApiResponse(self.session.handler(method=request_method, url=url, data=data))


@community
Expand Down

0 comments on commit 561a3ac

Please sign in to comment.