I set webhook to my telegram chatbot with the help of CherryPy. And now I am trying to handle data which I receive through webhook. I found the variable in cherrypy webhook class which contains needed json data. In my code, the variable name is json_string. I need to call this variable everywhere in my python script. How I can do that? Thanks.
class WebhookServer(object):
@cherrypy.expose
def index(self):
if 'content-length' in cherrypy.request.headers and \
'content-type' in cherrypy.request.headers and \
cherrypy.request.headers['content-type'] == 'application/json':
length = int(cherrypy.request.headers['content-length'])
json_string = cherrypy.request.body.read(length).decode("utf-8")
update = telebot.types.Update.de_json(json_string)
bot.process_new_updates([update])
return ''
else:
raise cherrypy.HTTPError(403)