I'm trying to develop a simple bot, that can retrieve photo from user and then do several operations with media file. I'm using telebot (https://github.com/eternnoir/pyTelegramBotAPI) for design.
As far as I can see from the wiki, I can divide income messages by content_type
using special handlers.
However, when I wrote such simple method:
#main.py
@bot.message_handler(content_types= ["photo"])
def verifyUser(message):
print ("Got photo")
percent = userFace.verify(message.photo, config.photoToCompare)
bot.send_message(message.chat.id, "Percentage: " + str(percent))
def getData(json_string):
updates = telebot.types.Update.de_json(json_string)
bot.process_new_updates([updates])
#server.py
app = Flask(__name__)
@app.route("/", methods=["POST", "GET"])
def hello():
json_string = request.get_data()
getData(json_string)
print("....")
print(request.data)
return 'test is runing'
if __name__ == '__main__':
app.run(host='0.0.0.0')
I get such mistake which I can't classify whether I'm doing something wrong or there is a problem with API
obj = cls.check_json(json_type)
File "/usr/local/lib/python2.7/dist-packages/telebot/types.py", line 77, in check_json
return json.loads(json_type)
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
I'm new to bot design, so I don't know, whether I'm following the right way. I will be glad to hear the common practice of working with photo media files.