SurvBot/app/com.py

26 lines
612 B
Python
Raw Normal View History

2019-11-15 14:45:37 +00:00
import requests
import json
2019-11-16 14:46:38 +00:00
import config
2019-11-15 14:45:37 +00:00
import time
2019-11-16 14:46:38 +00:00
import cv2
2019-11-15 14:45:37 +00:00
def saveImage(img):
2020-06-03 09:29:24 +00:00
name = '{}'.format(time.time()).split(".")[0]
2019-11-16 14:46:38 +00:00
path = config.photos + name + '.png'
2019-11-15 14:45:37 +00:00
cv2.imwrite(path, img)
return path
def notify(path):
photo = open(path, "rb")
2020-05-24 18:48:40 +00:00
json1 = {"chat_id": config.chat_id}
2019-11-15 14:45:37 +00:00
files = {'photo': photo}
2020-05-24 18:48:40 +00:00
print(requests.post("https://api.telegram.org/bot" + config.token + "/sendPhoto", json1, files=files))
2019-11-15 14:45:37 +00:00
2019-11-16 14:46:38 +00:00
def initEndpoint():
tp = "http://api.telegram.org/bot" + config.token + "/setWebHook?url=" + config.endpoint
requests.get(tp)
print("registered:", tp)
2019-11-15 14:45:37 +00:00