From 84ec6dae1a909c062c7ba883a5d628ef20321c3f Mon Sep 17 00:00:00 2001 From: "[d]" Date: Wed, 1 Mar 2023 22:28:46 +0000 Subject: [PATCH] update --- storage/bot/plugins/isup_plugin.py.save | 86 ------------------------- 1 file changed, 86 deletions(-) delete mode 100644 storage/bot/plugins/isup_plugin.py.save diff --git a/storage/bot/plugins/isup_plugin.py.save b/storage/bot/plugins/isup_plugin.py.save deleted file mode 100644 index 9fafde3..0000000 --- a/storage/bot/plugins/isup_plugin.py.save +++ /dev/null @@ -1,86 +0,0 @@ - -# -*- coding: utf-8 -*- ############################################################### SOF -from irc3.plugins.command import command -import irc3 -from urllib.request import Request, urlopen -from urllib.error import URLError, HTTPError -########################################################################################### -########################################################################################### -@irc3.plugin -class Plugin: - ####################################################################################### - ####################################################################################### - def __init__(self, bot): - self.bot = bot - ####################################################################################### - ####################################################################################### - def isup_check(self, domain_or_ip): - msg='' - try: - url=f'http://{domain_or_ip}' - try: - req = Request( - url, - data=None, - headers={ - 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36' - } - ) - response=urlopen(req,timeout=10).read().decode('utf-8') - except HTTPError as e: - msg='maybe -> could not complete the request. error code: {}'.format(e.code) - except URLError as e: - msg='down -> failed to reach the server. reason: {}'.format(e.reason) - else: - msg=f'up -> http://{domain_or_ip} is communicating' - except: - url=f'https://{domain_or_ip}' - try: - req = Request( - url, - data=None, - headers={ - 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36' - } - ) - response=urlopen(req,timeout=10).read().decode('utf-8') - except HTTPError as e: - msg='maybe -> could not complete the request. error code: {}'.format(e.code) - except URLError as e: - msg='down -> failed to reach the server. reason: {}'.format(e.reason) - else: - msg=f'up -> https://{domain_or_ip} is communicating' - finally: - return msg - ####################################################################################### - ####################################################################################### - @command(permission='view') - def isup(self, mask, target, args): - """isup domain - %%isup - """ - domain=args.get('') - domain_noise=domain - try: - domain_noise=domain.split('://')[1] - except: - pass - try: - if not domain_noise: - domain_noise=domain[:domain.find('.')+domain[domain.find('.')+1:].find('/')+1].split('://')[1] - except: - if not domain_noise.find('/')==-1: - domain_noise=domain[:domain.find('.')+domain[domain.find('.')+1:].find('/')+1].split('://')[0] - if domain_noise[-1]=="/": domain_noise=domain_noise[:-1] - if domain_noise[:domain_noise.find(':')].replace('.','').isnumeric() and (len(domain_noise[:domain_noise.find(':')])-3)==len(domain_noise[:domain_noise.find(':')].replace('.','')): - domain=domain_noise - elif domain_noise.replace('.','').isnumeric() and (len(domain_noise)-3) == len(domain_noise.replace('.','')): - domain=domain_noise - elif domain_noise.find('/') == -1 and not domain_noise.find('.') == -1 and domain_noise.replace('.','').isalnum(): - domain=domain_noise - else: - self.bot.privmsg(target,self.bot.emo("{}: doesn't sanitize towards a valid domain/ip".format(domain))) - return - self.bot.privmsg(target,self.bot.emo("{}".format(self.isup_check(domain)))) -####################################################################################### EOF -#.[d].