-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmonitor.py
95 lines (75 loc) · 2.04 KB
/
monitor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from flask import Flask, request, render_template
import json
import re
from unsync import unsync
import uvicorn
from config import (
scheduler,
wcapi,
token,
debug,
fugoku_url,
bot,
types,
sentrydsn,
channel_name,
)
import os
import sentry_sdk
from features.start import start
from features.status import status
from features.dashboard import dashboard
from telethon.tl.functions.photos import GetUserPhotosRequest
server = Flask(__name__)
sentry_sdk.init(
dsn=sentrydsn,
traces_sample_rate=1.0,
traces_sampler=1,
_experiments={
"profiles_sample_rate": 1.0,
}
)
scheduler.start()
@bot.message_handler(commands=["dashboard", "Dashboard"])
def dashboard_command(message):
try:
dashboard(message)
except Exception as e:
print("Error occurred on dashboard", e)
@bot.message_handler(commands=["start", "Start"])
def start_command(message):
try:
start(message)
except Exception as e:
print("Error occurred on start", e)
@bot.message_handler(commands=["status", "Status"])
def status_commandd(message):
try:
status(message)
except Exception as e:
print("Error occurred on status", e)
@server.route("/", methods=["GET"])
def index():
return ("This is a website.", 200, None)
@server.route("/monitor/order", methods=["POST"])
def new_order_hook():
request_object = request.stream.read().decode("utf-8")
return (request_object, 200, None)
@server.route("/" + token, methods=["POST"])
def getMessage():
request_object = request.stream.read().decode("utf-8")
update_to_json = [types.Update.de_json(request_object)]
bot.process_new_updates(update_to_json)
return "got Message bro"
@server.route("/hook")
def webhook():
jurl = fugoku_url
bot.remove_webhook()
bot.set_webhook(jurl + token)
return f"Webhook set to {fugoku_url}"
if debug == True:
bot.remove_webhook()
bot.polling()
else:
if __name__ == "__main__":
server.run(host="0.0.0.0", port=int(os.environ.get("PORT", 5001)))