Commit 2ee2ec69 authored by Emil Svensson's avatar Emil Svensson

Update plugins/down.py

parent 7f6f7668
# -*- coding: utf-8 -*-
import urllib
import json
import html.parser
import http.client
from telegram.ext.dispatcher import run_async
from helpers import send_typing_action
class Down():
def __init__(self, bot, config):
bot.registerCommand("down","<dns> http(s) only",self.handleDown,True)
@run_async
@send_typing_action
def handleDown(self, update, context):
try:
conn = http.client.HTTPSConnection("api.downfor.cloud")
conn.request("GET", "/httpcheck/%s" % context.args[0])
if json.loads(conn.getresponse().read().decode('utf-8'))["isDown"]:
message = "%s is down" % context.args[0]
else:
message = "%s is up" % context.args[0]
except urllib.error.URLError:
message = "No result. https://downforeveryoneorjustme.com is down."
except IndexError:
message = "seams like you inputed an inavlid url"
update.message.reply_text(message)
mainclass = Down
# -*- coding: utf-8 -*-
import urllib
import json
import html.parser
import http.client
from telegram.ext.dispatcher import run_async
from helpers import send_typing_action
class Down():
def __init__(self, bot, config):
bot.registerCommand("down","<dns> http(s) only",self.handleDown,True)
@run_async
@send_typing_action
def handleDown(self, update, context):
try:
conn = http.client.HTTPSConnection("api-prod.downfor.cloud")
conn.request("GET", "/httpcheck/%s" % context.args[0])
if json.loads(conn.getresponse().read().decode('utf-8'))["isDown"]:
message = "%s is down" % context.args[0]
else:
message = "%s is up" % context.args[0]
except urllib.error.URLError:
message = "No result. https://downforeveryoneorjustme.com is down."
except IndexError:
message = "seams like you inputed an inavlid url"
update.message.reply_text(message)
mainclass = Down
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment