# -*- coding: utf-8 -*- from irc3.plugins.command import command from urllib.parse import urlparse import irc3 import random import string import os ############################################################################################ TURLPATH='/Users/dr1p/m4pl1mp/d/' RSYNC=f"rsync -az {TURLPATH}/* dr1p@ansibomb.com:/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'{TURLPATH}{S}/index.html'): S=list(string.ascii_letters+string.digits) random.shuffle(S); S=''.join(S)[:5] os.mkdir(f'{TURLPATH}{S}') f=open(f'{TURLPATH}{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.turl_validate(url): url=self.turl_generate(url) os.system(f'RSYNC') msg=f'{mask.nick}: https://ansibomb.com/d/{url}' self.bot.privmsg(target,self.bot.emo(msg)) ############################################################################################