Last active
October 1, 2020 00:05
-
-
Save jqqqqqqqqqq/3915d28a785077c38005341d50250a45 to your computer and use it in GitHub Desktop.
broken water bot
This file contains hidden or 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
from aiogram import Bot, Dispatcher, types | |
from aiogram.utils.markdown import quote_html | |
import asyncio | |
TOKEN = '' | |
MAIN_GRP = -1 | |
MAIN_GRP_LNK = 'https://t.me/111' | |
DISSCUSSION_GRP = -1 | |
DISSCUSSION_GRP_LNK = 'https://t.me/222' | |
async def main(): | |
bot = Bot(token=TOKEN) | |
try: | |
disp = Dispatcher(bot=bot) | |
@disp.message_handler(regexp='off.?topic') | |
async def off_topic(event: types.Message): | |
if event.chat.id == MAIN_GRP: | |
if event.reply_to_message: | |
await event.reply(f'Message moved to ' | |
f'<a href="{DISSCUSSION_GRP_LNK}">off-topic group</a>', | |
parse_mode='html', disable_web_page_preview=True) | |
name = event.reply_to_message.from_user.full_name | |
msg = event.reply_to_message.text | |
await bot.send_message(DISSCUSSION_GRP, f'<b>{quote_html(name)}</b> wrote: {quote_html(msg)}, ⬇️ ᴘʟᴇᴀsᴇ ᴄᴏɴᴛɪɴᴜᴇ ʜᴇʀᴇ ⬇️', parse_mode='html') | |
else: | |
await event.reply(f'Link to <a href="{DISSCUSSION_GRP_LNK}">off-topic group</a>', | |
parse_mode='html', disable_web_page_preview=True) | |
@disp.message_handler(regexp='on.?topic') | |
async def on_topic(event: types.Message): | |
if event.chat.id == DISSCUSSION_GRP: | |
if event.reply_to_message: | |
await event.reply(f'Message moved to ' | |
f'<a href="{MAIN_GRP_LNK}">on-topic group</a>', | |
parse_mode='html', disable_web_page_preview=True) | |
name = event.reply_to_message.from_user.full_name | |
msg = event.reply_to_message.text | |
await bot.send_message(MAIN_GRP, | |
f'<b>{quote_html(name)}</b> wrote: {quote_html(msg)}, ⬇️ ᴘʟᴇᴀsᴇ ᴄᴏɴᴛɪɴᴜᴇ ʜᴇʀᴇ ⬇️', | |
parse_mode='html') | |
else: | |
await event.reply(f'Link to <a href="{MAIN_GRP_LNK}">on-topic group</a>', | |
parse_mode='html', disable_web_page_preview=True) | |
await disp.start_polling() | |
finally: | |
await bot.close() | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment