Научите меня чаще коммитить, описания функций.
This commit is contained in:
parent
e68200fc8e
commit
9460100295
2 changed files with 7 additions and 2 deletions
Binary file not shown.
9
main.py
9
main.py
|
@ -17,12 +17,14 @@ bot = TelegramClient(os.environ['SESSION_NAME'], int(os.environ['API_ID']),
|
|||
|
||||
|
||||
async def check_admin(msg):
|
||||
"""Checks if a user is an admin in the chat"""
|
||||
return any([user.id == msg.sender_id async for user in bot.iter_participants(msg.chat_id,
|
||||
filter=types.ChannelParticipantsAdmins)])
|
||||
|
||||
|
||||
@bot.on(events.NewMessage())
|
||||
async def on_message(msg):
|
||||
"""Handle DM and add chat id to database if not exists"""
|
||||
if msg.is_private:
|
||||
await msg.respond('Я не работаю в личных сообщениях. Добавь меня в группу, для начала работы')
|
||||
raise events.StopPropagation
|
||||
|
@ -34,6 +36,7 @@ async def on_message(msg):
|
|||
|
||||
@bot.on(events.NewMessage(pattern='/help'))
|
||||
async def on_help(msg):
|
||||
"""Send detailed help message"""
|
||||
await msg.reply('Дотупные команды: \n'
|
||||
'/help - помощь\n'
|
||||
'/bs [add/rm] <id стикерапка> - запретить, разрешить стикерпак в группе, можно написать в ответ на стикер из нужного стикерпака\n'
|
||||
|
@ -49,7 +52,8 @@ async def check_user_in_exceptions(user_id, chat_id):
|
|||
|
||||
|
||||
@bot.on(events.NewMessage(pattern='/exc'))
|
||||
async def on_exception(msg):
|
||||
async def manage_exceptions(msg):
|
||||
"""Manage users, that will be ignored by the bot"""
|
||||
if not await check_admin(msg):
|
||||
await msg.reply('Добавлять пользователей в исключения может только админ')
|
||||
raise events.StopPropagation
|
||||
|
@ -113,7 +117,8 @@ async def check_stickerpack_in_banlist(stickerpack_id, chat_id):
|
|||
|
||||
|
||||
@bot.on(events.NewMessage(pattern='/bs'))
|
||||
async def add_stickerpack(msg):
|
||||
async def manage_stickerpack(msg):
|
||||
"""Add or remove stickerpack from banlist"""
|
||||
if not await check_admin(msg):
|
||||
await msg.reply('Добавлять стикеры в банлист может только админ')
|
||||
raise events.StopPropagation
|
||||
|
|
Loading…
Add table
Reference in a new issue