Hello Buddies, Let's make a Telegram Quote Bot using Pyrogram and python-arq today.
Pre-requisite knowledge:
- Basic Python Programming
- Basic Knowledge about Telegram bots.
Let's start:
First go to @BotFather and create a new bot and Take its bot token.
Then go to @ARQRobot and make a API KEY.
Install these Required Python Packages using pip3 install -U <package name>
:
pyrogram
TgCrypto
python-arq
aiohttp
We need python version greater or equal to 3.9.0 to run this. So if you have python version lower than this. Upgrade it first.
Now let's Setup the Clients
This is how we will setup the clients for the quote bot.
Now let's define how to Quotify
We have defined how to quote
Now let's take on the how to setup the command for using the quote function
We setup q
as the command, and pyrogram takes /
as the default handler
Now we are going to setup that it takes input only when we reply to a text message with the command.
For that we are going to use this:
Now let's check what the user gave with the command, if it's 'r' we will quote the message with the message being replied too. If its an integer we are goin to
quote the given number of messages from the replied message
Now the else: part
Quoting done! Oh but we didn't even started the bot.
Add this in the end to run the bot else it won't even run. Now save the file named bot.py
Now to run and test the bot we will do
python3 -m bot.py
Top comments (0)