Skip to content

Commit

Permalink
welcome: fix bug when chat have no welcome data
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMissx committed Jun 15, 2021
1 parent 4bc4faa commit 89009a1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions anjani_bot/plugins/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from anjani_bot.utils import MessageParser, ParsedChatMember


class RawGreeting(MessageParser):
class RawGreeting(plugin.Plugin, MessageParser):
welcome_db: AsyncIOMotorCollection
lock: asyncio.locks.Lock

Expand Down Expand Up @@ -77,8 +77,8 @@ async def welc_pref(self, chat_id) -> bool:
async def welc_msg(self, chat_id) -> str:
"""Get chat welcome string"""
data = await self.welcome_db.find_one({"chat_id": chat_id})
if message := data.get("custom_welcome"):
return message, data.get("button")
if data:
return data.get("custom_welcome"), data.get("button")
return await self.default_welc(chat_id), None

async def clean_service(self, chat_id) -> bool:
Expand Down Expand Up @@ -130,7 +130,7 @@ async def prev_welcome(self, chat_id, msg_id: int) -> Union[int, bool]:
return False


class Greeting(plugin.Plugin, RawGreeting):
class Greeting(RawGreeting):
name: ClassVar[str] = "Greetings"
helpable: ClassVar[bool] = True

Expand Down

0 comments on commit 89009a1

Please sign in to comment.