How to make a Python Telegram Bot which can both send Private Messages to Users and also Group Messages while tagging/mentioning users? #4201
Unanswered
ScarletMcLearn
asked this question in
Q&A
Replies: 2 comments
-
Nevermind. Got it to work using the code below. If you have any suggestions to improve it, please do tell. Thank you! Code: import time bot = Bot(token=TOKEN) while True:# Send a private message to a userbot.send_message(chat_id='USER_ID', text='Hello, this is a private message.')# Send a group message and tag a userbot.send_message(chat_id='GROUP_ID', text='Hello @USERNAME, this is a group message.')# Wait for 5 secondstime.sleep(5)import asyncio bot = Bot(token=TOKEN) List of user IDs who have interacted with the botuser_ids = ['USER_ID1', 'USER_ID2', 'USER_ID3', ...] async def send_messages():
Thank you.
Run the async function using asyncioasyncio.run(send_messages()) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to create a Telegram bot which will send a Private message to a User every 5 seconds.
I also want it to send group messages every 5 second.
The message should tag a particular User (identified by the username provided in the code).
How can I achieve this?
I have gone over the documentation, video tutorials, text resources, and examples, but am lost.
I have tried the echobot and timerbot as well.
But I am not sure to implement the tagging/mention feature.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions