SurvBot/com.py

33 lines
702 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
2019-11-16 14:46:38 +00:00
login = config.loginPath
2019-11-15 14:45:37 +00:00
loginDataJson = {}
2019-11-16 14:46:38 +00:00
config.token
config.chat_id
2019-11-15 14:45:37 +00:00
def saveImage(img):
2019-11-16 14:46:38 +00:00
name = '{}'.format(int(time.time()))
path = config.photos + name + '.png'
2019-11-15 14:45:37 +00:00
cv2.imwrite(path, img)
return path
def notify(path):
global loginDataJson
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