this post was submitted on 03 Jul 2023
1 points (100.0% liked)

Telegram Bots

41 readers
0 users here now

founded 1 year ago
MODERATORS
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/telegrambots by /u/User_098H5 on 2023-06-26 11:14:33+00:00.


Hello Fellas. I am a beginner. Inam trying to build a telegram bot that can send messages in a channel. I have made the bot and am trying to send the message using a python program, but am getting an error no matter the changes I make to my code. I am typing the code below, please help me if anyone can-

Import telegram Import asyncio

bot = telegram.bot(token='xxxxxxxxxxxxxxx') group_id= '$$$$$$'

async def send_message(message): await bot.send_message(chat_id= group_id,

text=message)

message_to_send= 'hello group members'

loop= asyncio.new_event_loop(loop)

loop.run_until_complete(send_message_to_group(message_to_send)

The error I am getting is- RuntimeError- Cannot run the event loop while another loop is running.

I have a little knowledge of api and am a beginner in programming. I have no experience with telegram bots but want to experiement with it as I have some plans in mind.

My main purpose is broadcasting information, My python program will do some calculations and the result will be broadcasted in the group by this bot.

I gave the context so that in case you gyus have any advise ,suggestions, resources or anything for me I'll very much appretiate it.

Please let me know how I can fox this code and whats wrong with this one.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here