-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Kamuri Amorim edited this page Oct 6, 2022
·
1 revision
You can install it using pip: pip install icqbotpy.
First, let's do the necessary imports:
from ICQBot import ICQBot, Dispatcher, executor
from ICQBot.messages import ReceivedMessageNow initialize the bot and dispatcher instances. You can get a token from @metabot.
bot = ICQBot("TOKEN")
dp = Dispatcher(bot)Next, let's create a command! We will start with a simple /start:
@dp.message_handler(commands="/start")
async def start(message: ReceivedMessage):
return await message.reply("Hello! I'm a simple bot!")To create a command that echoes every text message sent to the bot:
@dp.message_handler()
async def echo(message: ReceivedMessage):
await message.reply(message.text)Easy, isn't it? Now, to run the bot, just add this to the end of your file:
if __name__ == "__main__":
executor(dp)from ICQBot import ICQBot, Dispatcher, executor
from ICQBot.messages import ReceivedMessage
bot = ICQBot("TOKEN")
dp = Dispatcher(bot)
@dp.message_handler(commands="/start")
async def start(message: ReceivedMessage):
return await message.reply("Hello! I'm a simple bot!")
@dp.message_handler()
async def echo(message: ReceivedMessage):
await message.reply(message.text)
if __name__ == "__main__":
executor(dp)You can see more examples on this file.