mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
add isdown/isup for websites
This commit is contained in:
@@ -2,11 +2,11 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
import shlex
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import shlex
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
@@ -825,3 +825,17 @@ def translate(argv, **args):
|
|||||||
return {
|
return {
|
||||||
'msg': 'translation: {}'.format(response['responseData']['translatedText'])
|
'msg': 'translation: {}'.format(response['responseData']['translatedText'])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@pluginfunction('isdown', 'check if a website is reachable', ptypes_COMMAND)
|
||||||
|
def isdown(argv, **args):
|
||||||
|
if not argv:
|
||||||
|
return
|
||||||
|
url = argv[0]
|
||||||
|
if 'http' not in url:
|
||||||
|
url = 'http://{}'.format(url)
|
||||||
|
response = requests.get('http://www.isup.me/{}'.format(urlparse(url).hostname)).text
|
||||||
|
if "looks down" in response:
|
||||||
|
return {'msg': '{}: {} looks down'.format(args['reply_user'], url)}
|
||||||
|
elif "is up" in response:
|
||||||
|
return {'msg': '{}: {} looks up'.format(args['reply_user'], url)}
|
||||||
|
|||||||
Reference in New Issue
Block a user