def index(self): 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 ''
def get_updates(): """This func provides url for telebot webhook.""" json_string = request.stream.read().decode("utf-8") update = types.Update.de_json(json_string) bot.process_new_updates([update]) return "All OK"
def webhook(): if flask.request.headers.get('content-type') == 'application/json': json_string = flask.request.get_data().decode('utf-8') update = telebot.types.Update.de_json(json_string) bot.process_new_updates([update]) return '' else: flask.abort(403)
def bot_app(): if request.method == 'POST': update_json = request.get_data().decode('utf-8') update = telebot.types.Update.de_json(update_json) bot.process_new_updates([update]) return 'ok', 200 else: return ('This is sochnye bitochky bot app')
def do_POST(self): self.send_response(200) self.end_headers() content_length = int(self.headers['Content-Length']) content = self.rfile.read(content_length).decode('utf-8') update = telebot.types.Update.de_json(content) bot.process_new_updates([update])
def handle_update(): if(flask.request.headers.get("content-type") == "application/json"): json_string = flask.request.get_data().decode("utf-8") update = Update.de_json(json_string) bot.process_new_updates([update]) return '' else: flask.abort(403)
def webhook(): if request.headers.get("content-type") == "application/json": print(request.headers) print(datetime.now()) # length = request.headers["content-length"] json_string = request.get_data().decode("utf-8") update = Update.de_json(json_string) print(update) bot.process_new_updates([update]) return "OK", 200 return abort(403)
def webhook(): if request.headers.get("content-type") == "application/json": json_string = request.get_data().decode("utf-8") update = Update.de_json(json_string) was_error = False tic = time() try: bot.process_new_updates([update]) except Exception as err: answer = "Кажется, произошла ошибка.\n" \ "Возможно, информация по этому поводу есть в нашем " \ "канале - @Spbu4u_news\nИ ты всегда можешь связаться с " \ "<a href='https://t.me/eeonedown'>разработчиком</a>" was_error = True if update.message is not None: try: bot.send_message(update.message.chat.id, answer, disable_web_page_preview=True, parse_mode="HTML") bot.send_message(ids["my"], str(err) + "\n\nWas sent: True") except ApiException as ApiExcept: json_err = loads(ApiExcept.result.text) if json_err["description"] == "Forbidden: bot was " \ "blocked by the user": delete_user(update.message.chat.id) logging.info("USER LEFT {0}".format( update.message.chat.id)) else: logging.info("ERROR: {0}".format( json_err["description"])) else: pass finally: write_log(update, time() - tic, was_error) return "OK", 200 else: abort(403)
def get_message(): upd = [telebot.types.Update.de_json(request.stream.read().decode("utf-8"))] bot.process_new_updates(upd) return "Create and process new updates", 200
def get_message(): vk_bot.process_new_updates( [telebot.types.Update.de_json(request.stream.read().decode("utf-8"))]) return "POST", 200
def get_message(): update = types.Update.de_json(request.stream.read().decode('utf-8')) bot.process_new_updates([update]) return 'OK', 200
def getMessage(): bot.process_new_updates( [Update.de_json(request.stream.read().decode("utf-8"))]) return "!", 200
def get_message(): bot.process_new_updates( [types.Update.de_json(flask.request.stream.read().decode("utf-8"))]) return "!", 200
def handle_tm_message(): bot.process_new_updates( [telebot.types.Update.de_json(request.stream.read().decode("utf-8"))]) return "OK", 200
def test_route(): json_string = request.get_data().decode("utf-8") print(json_string) update = Update.de_json(json_string) bot.process_new_updates([update]) return "OK", 200
def webhook(request): print('income') data = json.loads(request.body.decode('utf-8')) update = telebot.types.Update.de_json(data) bot.process_new_updates([update]) return HttpResponse(content="Ok", status=200)