# -*- coding: utf-8 -*- from irc3.plugins.command import command from urllib.parse import urlparse import irc3 import random import string import os ############################################################################################ PATH_TO_PERMS='/var/www/html/d/' ############################################################################################ HTML=""" Redirect

You are being redirected to some interesting page.

If you are not redirected after a few seconds, please click on the link above!

""" ############################################################################################ @irc3.plugin class Plugin: def __init__(self, bot): self.bot = bot ######################################################################################## def turl_generate(self,url): S=list(string.ascii_letters+string.digits) random.shuffle(S); S=''.join(S)[:5] while os.path.isfile(f'{PATH_TO_PERMS}{S}/index.html'): S=list(string.ascii_letters+string.digits) random.shuffle(S); S=''.join(S)[:5] os.mkdir(f'{PATH_TO_PERMS}{S}') f=open(f'{PATH_TO_PERMS}{S}/index.html','w') _HTML=HTML.format(url,url) for _ in _HTML: f.write(_) f.close() return f'{S}' ######################################################################################## def turl_validate(self,url): result=urlparse(url) validation=all([result.scheme,result.netloc,result.path]) if validation: return 1 return 0 ######################################################################################## @command(permission='view') def turl(self,mask,target,args): """turl %%turl ... """ url=''.join(args['']) if self.bot.turl_validate(url): url=self.turl_generate(url) msg=f'{mask.nick}: https://ansibomb.com/d/{url}' self.bot.privmsg(target,self.bot.emo(msg)) ############################################################################################