# -*- coding: utf-8 -*- from irc3.plugins.command import command import irc3 import os import random testfile = ['a'*40,'b'*40,'c'*40,'d'*40,'1'*40,'2'*40,'3'*40,'4'*40] KRYLON_FILE = testfile TOTAL_BOTS = 0 CONNECTED_BOTS = [] ONLINE_BOTS = [] INITIALIZED = 0 dir_path = os.path.dirname(os.path.realpath(__file__)) @irc3.plugin class Plugin(object): def __init__(self, context): self.log = context.log self.context = context self.channel = context.config.channel self.init = 0 self.total_bots = 0 def __emoj(self,s): emote_db = '%s/emote.db' % dir_path emoj = random.choice(list(open(emote_db))) random.randint(0,1) if random.randint(0,1) == 0: emoj = "\x0304{}\x0F".format(emoj) else: emoj = "\x0303{}\x0F".format(emoj) s = s + ' ▶ ' + emoj return s def __greet(self): greet_db = '%s/greet.db' % dir_path greet = random.choice(list(open(greet_db))) return greet def __symbol(self): symbol_db = '%s/symbol.db' % dir_path symbol = random.choice(list(open(symbol_db))) return symbol def __bok(self): MSG="" for i in range(random.randint(1,25)): for _ in "bok": for __ in range(random.randint(1,10)): ___ = random.randint(1,2) if ___ == 1: MSG+="b" else: MSG+="B" for __ in range(random.randint(1,10)): ___ = random.randint(1,2) if ___ == 1: MSG+="o" else: MSG+="O" for __ in range(random.randint(1,10)): ___ = random.randint(1,2) if ___ == 1: MSG+="k" else: MSG+="K" __ = random.randint(1,2) if __ == 1: MSG+="" else: MSG+=" " __ = random.randint(1,2) for __ in "bu": ___ = random.randint(1,2) if ___ == 1: MSG+=__.upper()*random.randint(1,7) else: MSG+=__.lower()*random.randint(1,7) if __ == 1: MSG+="" else: MSG+=" " __ = random.random.randint(1,2) if __ == 1: MSG+="bok"*random.randint(0,3) else: MSG+="BOK"*random.randint(0,3) __ = random.randint(1,2) if __ == 1: MSG+="" else: MSG+=" " for __ in "gock": ___ = random.randint(1,2) if ___ == 1: MSG+=__.upper()*random.randint(1,7) else: MSG+=__.lower()*random.randint(1,7) __ = random.random.randint(1,2) if __ == 1: MSG+="" else: MSG+=" " __ = random.random.randint(1,2) if __ == 1: MSG+="gok"*random.randint(0,3) else: MSG+="GOK"*random.randint(0,3) def krylon(self): if self.init == 0: KRYLON_FILE.reverse() self.init = 1 NICK='d' MSG='{}: <<>>'.format(NICK) CHN='#sh0rtbus' MSG = self.__emoj(MSG) self.context.privmsg(CHN,MSG) @irc3.event(irc3.rfc.JOIN) def welcome(self, mask, channel, **kw): if mask.nick == self.context.nick: ONLINE_BOTS.append(self.context.nick) NICK='d' SYMBOL=self._Plugin__symbol() GREET=self._Plugin__greet() BID='BOT' BOT=self.context bots='___'.join(BOT.config['botnet']).strip().split('___') for _ in bots: if BOT.config['botnet'][_].nick == BOT.nick: BID= _ MSG='{}: {} {} < {}'.format(NICK,SYMBOL,GREET,BID) CHN=self.channel MSG = self._Plugin__emoj(MSG) BOT.privmsg(CHN,MSG) if len(ONLINE_BOTS) == len(self.context.config.botnet): self.krylon() @irc3.event(irc3.rfc.PRIVMSG) def on_privmsg(self, mask=None, data=None, **kw): BOT=self.context if "bok" in data.lower(): WHO = mask.nick SYM = self._Plugin__symbol() BOK = self._Plugin__bok() CHN = self.channel MSG='{}: {} {}'.format(WHO,SYM,BOK) MSG = self._Plugin__emoj(MSG) BOT.privmsg(CHN,MSG) @irc3.event(irc3.rfc.CONNECTED) def connected(self, **kw): for _ in [x for x in self.context.config.botnet]: if kw['me'] in self.context.config.botnet[_].nick: CONNECTED_BOTS.append((_,kw['me'])) self.context.join(self.channel)