Example #1
0
                         caption=emoji.emojize(caption, use_aliases=True),
                         reply_to_message_id=None,
                         allow_sending_without_reply=True)


class Flok(Filter):
    messages = ['ото Флок', 'ото флок']

    async def check(self, message: types.Message):
        text = message.text
        for x in self.messages:
            if x in text:
                return True
        return False


@dp.message_handler(Flok())
async def sun_answer(message: types.Message):
    photo_url = 'https://i.pinimg.com/564x/64/be/7b/64be7b73ab1039eed89732e48961e322.jpg'
    caption = "Новенький, чем-то смахивает на Жана в кадетском корпусе"
    await bot.send_photo(message.from_user.id,
                         photo_url,
                         caption=emoji.emojize(caption, use_aliases=True),
                         reply_to_message_id=None,
                         allow_sending_without_reply=True)


if __name__ == "__main__":
    dp.bind_filter(SunFilter)
    executor.start_polling(dp, skip_updates=False)
Example #2
0
from functools import partial

from aiogram import Bot, Dispatcher
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher.webhook import DEFAULT_WEB_PATH, get_new_configured_app
from aiogram.utils import executor
from aiohttp import web

from botapp.utils import DeepLinkFilter

TOKEN = os.getenv('BOT_TOKEN')
storage = MemoryStorage()

bot = Bot(TOKEN, parse_mode='HTML')
dp = Dispatcher(bot, storage=storage)
dp.bind_filter(DeepLinkFilter)

# register handlers
from . import poll, other_cmds, posting
from .posting import make_new_post

start_polling = partial(executor.start_polling, dp)


def start_webhook():
    app = get_webapp()
    web.run_app(app, port=os.getenv('bot_port'))


def get_webapp():
    def set_webhook(_):