Merge Beta with Stable releases #1
@ -54,11 +54,11 @@ class HoloUser():
|
|||||||
as well as provide better programming experience in case of adding new features, etc.
|
as well as provide better programming experience in case of adding new features, etc.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, user: Union[User, List[User], ChatMember, int, str]) -> None:
|
def __init__(self, user: Union[User, List[User], ChatMember, int]) -> None:
|
||||||
"""A user of Holo bot. Used to simplify DB interaction.
|
"""A user of Holo bot. Used to simplify DB interaction.
|
||||||
|
|
||||||
### Args:
|
### Args:
|
||||||
* user (`Union[User, List[User], ChatMember, int, str]`): Any possible way to identify the user. Pass `User` object, user's telegram ID, username or something...
|
* user (`Union[User, List[User], ChatMember, int]`): Any possible way to identify the user. Pass `User` object, user's telegram ID, etc...
|
||||||
|
|
||||||
### Raises:
|
### Raises:
|
||||||
* UserInvalidError: Provided to `HoloUser` object is not supported
|
* UserInvalidError: Provided to `HoloUser` object is not supported
|
||||||
@ -74,13 +74,14 @@ class HoloUser():
|
|||||||
self.id = user.user.id
|
self.id = user.user.id
|
||||||
elif isinstance(user, int):
|
elif isinstance(user, int):
|
||||||
self.id = user
|
self.id = user
|
||||||
elif isinstance(user, str):
|
# elif isinstance(user, str):
|
||||||
try:
|
# try:
|
||||||
self.id = (app.get_users(user)).id # this line requires testing though
|
# get_users = async_to_sync(app.get_users)
|
||||||
except bad_request_400.UsernameNotOccupied:
|
# self.id = get_users(user).id # this line requires testing though
|
||||||
raise UserInvalidError(user)
|
# except bad_request_400.UsernameNotOccupied:
|
||||||
except bad_request_400.PeerIdInvalid:
|
# raise UserInvalidError(user)
|
||||||
raise UserInvalidError(user)
|
# except bad_request_400.PeerIdInvalid:
|
||||||
|
# raise UserInvalidError(user)
|
||||||
else:
|
else:
|
||||||
raise UserInvalidError(user)
|
raise UserInvalidError(user)
|
||||||
|
|
||||||
@ -244,7 +245,7 @@ class HoloUser():
|
|||||||
self.label = label
|
self.label = label
|
||||||
self.set("label", label)
|
self.set("label", label)
|
||||||
await app.promote_chat_member(configGet("destination_group"), self.id)
|
await app.promote_chat_member(configGet("destination_group"), self.id)
|
||||||
if (not await isAnAdmin(self.id)) and (chat.id == configGet("admin_group")):
|
if not await isAnAdmin(self.id):
|
||||||
await app.set_administrator_title(configGet("destination_group"), self.id, label)
|
await app.set_administrator_title(configGet("destination_group"), self.id, label)
|
||||||
|
|
||||||
async def reset_label(self, chat: Chat) -> None:
|
async def reset_label(self, chat: Chat) -> None:
|
||||||
@ -256,7 +257,7 @@ class HoloUser():
|
|||||||
self.label = ""
|
self.label = ""
|
||||||
self.set("label", "")
|
self.set("label", "")
|
||||||
await app.set_administrator_title(configGet("destination_group"), self.id, "")
|
await app.set_administrator_title(configGet("destination_group"), self.id, "")
|
||||||
if (not await isAnAdmin(self.id)) and (chat.id == configGet("admin_group")):
|
if not await isAnAdmin(self.id):
|
||||||
await app.promote_chat_member(configGet("destination_group"), self.id, privileges=ChatPrivileges(
|
await app.promote_chat_member(configGet("destination_group"), self.id, privileges=ChatPrivileges(
|
||||||
can_manage_chat=False
|
can_manage_chat=False
|
||||||
))
|
))
|
||||||
|
Reference in New Issue
Block a user