|
|
|
@ -70,6 +70,25 @@ async def send_welcome(message: types.Message):
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["channel_id"]) |
|
|
|
|
async def get_channel_id(message: types.Message) -> None: |
|
|
|
|
"""Возвращает id канала по его имени""" |
|
|
|
|
if message["from"]["id"] not in ADMINS: |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
c_id = message.text[12:] |
|
|
|
|
|
|
|
|
|
result = await bot.send_message( |
|
|
|
|
chat_id=c_id, |
|
|
|
|
text="ping", |
|
|
|
|
disable_notification=True, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
await message.reply( |
|
|
|
|
f"Ид чата {c_id}: *{result.sender_chat.id}*", parse_mode="Markdown" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["mes"]) |
|
|
|
|
@auth |
|
|
|
|
async def send_to_chanel(message: types.Message): |
|
|
|
@ -82,7 +101,7 @@ async def send_to_chanel(message: types.Message):
|
|
|
|
|
disable_notification=True, |
|
|
|
|
parse_mode="Markdown", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
print(result.sender_chat.id) |
|
|
|
|
await clean_up(message_id=result.message_id, delay_min=DELAY_TIME) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -150,9 +169,6 @@ async def add_me(message: types.Message):
|
|
|
|
|
|
|
|
|
|
finded_token: Token = next((t for t in tokens_list if t.token == user_token), None) |
|
|
|
|
|
|
|
|
|
if finded_token.expired(): |
|
|
|
|
print("Пизда токену") |
|
|
|
|
|
|
|
|
|
# если с токеном все впорядке, то добавляем юзера в базу |
|
|
|
|
if finded_token and not finded_token.expired(): |
|
|
|
|
new_user: Allowed_user = Allowed_user( |
|
|
|
@ -185,6 +201,30 @@ async def add_me(message: types.Message):
|
|
|
|
|
await message.reply(msg, reply=False, parse_mode="Markdown") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["stop"]) |
|
|
|
|
@auth |
|
|
|
|
async def stop_and_panic(message: types.Message) -> None: |
|
|
|
|
"""Panic-button для бота. |
|
|
|
|
|
|
|
|
|
При нажатии: |
|
|
|
|
- кидает юзера в чс чата и удаляет его, |
|
|
|
|
- удаляет из белого списка. |
|
|
|
|
""" |
|
|
|
|
u_id = message["from"]["id"] |
|
|
|
|
finded_user: Allowed_user = ( |
|
|
|
|
session.query(Allowed_user).filter(Allowed_user.user_id == u_id).first() |
|
|
|
|
) |
|
|
|
|
await bot.kick_chat_member( |
|
|
|
|
chat_id=CHAT_ID, user_id=finded_user.user_id, revoke_messages=True |
|
|
|
|
) |
|
|
|
|
session.delete(finded_user) |
|
|
|
|
session.commit() |
|
|
|
|
|
|
|
|
|
# рассылка сообщения админам что юзер нажал паническую кнопку. Нужны ид чатов. |
|
|
|
|
# for admin_id in ADMINS: |
|
|
|
|
# await bot.send_meassage() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["wlc"]) |
|
|
|
|
@auth |
|
|
|
|
async def wlc(message: types.Message): |
|
|
|
|