-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from crestalnetwork/feat/telegram-bot-config-u…
…pdate feat: telegram bot config change handle
- Loading branch information
Showing
7 changed files
with
180 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from aiogram.filters import BaseFilter | ||
from aiogram.types import Message | ||
|
||
from tg.bot import pool | ||
|
||
|
||
class WhitelistedChatIDsFilter(BaseFilter): | ||
def __init__(self): | ||
pass | ||
|
||
async def __call__(self, message: Message) -> bool: | ||
whitelist = pool.bot_by_token(message.bot.token)["cfg"].get( | ||
"whitelist_chat_ids" | ||
) | ||
if whitelist is not None and len(whitelist) > 0: | ||
return str(message.chat.id) in whitelist | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from aiogram.filters import BaseFilter | ||
from aiogram.types import Message | ||
|
||
|
||
class NoBotFilter(BaseFilter): | ||
def __init__(self): | ||
pass | ||
|
||
async def __call__(self, message: Message) -> bool: | ||
return not message.from_user.is_bot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.