User Account: Free user
Hi, I am trying to send a message to my telegram chat using telegram BOT API https://api.telegram.org, this URL is whitelisted for free user. When i try to run the code with Pythonanywhere file editor, iam able to get successfull response, and message is sent to my Chat window.
Code
import requests
from env import TELE_BOT_TOKEN as api_token
chat_id=158775078
def send_message(userName, emailId, message):
text = f"""*Name*: {userName}
*MailID*: {emailId}
*Message*:
{message}"""
url = f'https://api.telegram.org/bot{api_token}/sendMessage'
params = { 'chat_id':chat_id, 'text':text, 'parse_mode':'Markdown' }
res = requests.get(url, params=params )
return res.status_code
API endpoint
@api.post('/sendmsg')
def send_tele_msg():
username, emailid, message = request.json.get('userName'), request.json.get('emailId'), request.json.get('message')
msg = telebot.send_message(**request.json)
return {'status': True, 'actual': msg}
Same code is working in my local machine, When giving postman request, server logs which i get are
2020-07-12 11:53:24 Sun Jul 12 11:53:24 2020 - *** HARAKIRI ON WORKER 1 (pid: 6, try: 1) ***
2020-07-12 11:53:24 Sun Jul 12 11:53:24 2020 - HARAKIRI !!! worker 1 status !!!
2020-07-12 11:53:24 Sun Jul 12 11:53:24 2020 - HARAKIRI [core 0] 10.0.0.52 - POST /api/v1/sendmsg since 1594554203
2020-07-12 11:53:24 Sun Jul 12 11:53:24 2020 - HARAKIRI !!! end of worker 1 status !!!
2020-07-12 11:53:24 DAMN ! worker 1 (pid: 6) died, killed by signal 9 :( trying respawn ...
2020-07-12 11:53:24 Respawned uWSGI worker 1 (new pid: 11)
Kindly help me on this.