0
CherryPyの助けを借りてwebhookを電報のチャットボットに設定しました。そして今、私はwebhookを通じて受け取ったデータを処理しようとしています。私は、必要なjsonデータを含むcherrypy webhookクラスの変数を見つけました。私のコードでは、変数名はです.json_stringです。私はこの変数をPythonスクリプトのどこでも呼び出す必要があります。私はそれをどのようにすることができますか?ありがとう。cherrypy webhookクラスから変数を呼び出す
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)