Hello, I'm trying to embed advertising in the bot, but it doesn't work. Could you help me. I'm using this test code, in theory, when you enter the /ads command, the bot should show ads, but it doesn't. I also don’t quite understand what needs to be transferred to the update_id. No errors appear in the logs when working.
Perhaps this is all easy to do, but I’m just learning how to work with bots and I’m not good at programming. Sorry :)
"""
This is a echo bot.
It echoes any incoming text messages.
"""
from aiogram import Bot, Dispatcher, executor, types
from IMPORTANT import TOKEN, AD_PROVIDER_TOKEN
import bap
# Initialize bot and dispatcher
bot = Bot(token=TOKEN)
dp = Dispatcher(bot)
dp.setup_middleware(bap.BapMiddleware(AD_PROVIDER_TOKEN))
service = bap.Bap(AD_PROVIDER_TOKEN)
@dp.message_handler(commands=['start', 'help'])
async def send_welcome(message: types.Message):
"""
This handler will be called when user sends `/start` or `/help` command
"""
await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")
@dp.message_handler(commands=['ads'])
async def send_ads(message: types.Message):
await service.send_advertisement(
{
'update_id': 123,
# ...
}
)
@dp.message_handler()
async def echo(message: types.Message):
# old style:
# await bot.send_message(message.chat.id, message.text)
await message.answer(message.text)
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
Hello, I'm trying to embed advertising in the bot, but it doesn't work. Could you help me. I'm using this test code, in theory, when you enter the /ads command, the bot should show ads, but it doesn't. I also don’t quite understand what needs to be transferred to the update_id. No errors appear in the logs when working.
Perhaps this is all easy to do, but I’m just learning how to work with bots and I’m not good at programming. Sorry :)