Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rking32 committed Aug 20, 2020
1 parent d2412b0 commit f0d8017
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions userge/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import asyncio
import importlib
from types import ModuleType
from typing import List, Awaitable, Any, Optional
from typing import List, Awaitable, Any, Optional, Union

import psutil

Expand Down Expand Up @@ -154,9 +154,11 @@ def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

@property
def bot(self) -> '_UsergeBot':
def bot(self) -> Union['_UsergeBot', 'Userge']:
""" returns usergebot """
if self._bot is None:
if Config.BOT_TOKEN:
return self
raise UsergeBotNotFound("Need BOT_TOKEN ENV!")
return self._bot

Expand Down
2 changes: 1 addition & 1 deletion userge/plugins/admin/gban.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ async def gban_at_entry(message: Message):
elif Config.ANTISPAM_SENTRY:
res = requests.get(f'https://api.cas.chat/check?user_id={user_id}').json()
if res['ok']:
reason = res['result']['messages'][0] if 'result' in res else None
reason = ' | '.join(res['result']['messages']) if 'result' in res else None
await asyncio.gather(
message.client.kick_chat_member(chat_id, user_id),
message.reply(
Expand Down
3 changes: 3 additions & 0 deletions userge/plugins/fun/kang.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ async def kang_(message: Message):
elif replied.document and "tgsticker" in replied.document.mime_type:
is_anim = True
elif replied.sticker:
if not replied.sticker.file_name:
await message.edit("`Sticker has no Name!`")
return
emoji_ = replied.sticker.emoji
is_anim = replied.sticker.is_animated
if not replied.sticker.file_name.endswith('.tgs'):
Expand Down
3 changes: 2 additions & 1 deletion userge/plugins/tools/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ async def shutdown_(message: Message) -> None:
try:
Config.HEROKU_APP.scale_formation_process("worker", 0)
except Exception as h_e: # pylint: disable=broad-except
await message.err(h_e)
await message.edit(f"**heroku error** : `{h_e}`")
await asyncio.sleep(3)
else:
await asyncio.sleep(1)
await message.delete()
Expand Down

0 comments on commit f0d8017

Please sign in to comment.