Answer the question
In order to leave comments, you need to log in
How to write several values in the channel_id of a telegram bot?
def send_telegram(text: str):
token = "token"
url = "https://api.telegram.org/bot"
channel_id = "123123123"
url += token
method = url + "/sendMessage"
r = requests.post(method, data={
"chat_id": channel_id,
"text": text
})
if r.status_code != 200:
raise Exception("post_text error")
Answer the question
In order to leave comments, you need to log in
I did find the solution though!
Let's say that we have the following function responsible for sending the bot:
def bot1(text: str):
token = "my_token"
url = "https://api.telegram.org/bot"
channel_id = "My_id"
url += token
method = url + "/sendMessage"
r = requests.post(method, data={
"chat_id": channel_id,
"text": text
})
if r.status_code != 200:
raise Exception("post_text error")
def ище2(text: str):
token = "my_token"
url = "https://api.telegram.org/bot"
channel_id = "My_id"
url += token
method = url + "/sendMessage"
r = requests.post(method, data={
"chat_id": channel_id,
"text": text
})
if r.status_code != 200:
raise Exception("post_text error")
channel_id = "My_id"
def start():
if __name__ == '__main__':
bot1(то_что_надо_отправить)
bot2(то_что_надо_отправить)
time.sleep(some_seconds)
start()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question