# -*- 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 = 50 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 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))) greet return s def __symbol(self,s): symbol_db = '%s/symbol.db' % dir_path symbol = random.choice(list(open(symbol_db))) symbol return s def krylon(self): if self.init == 0: KRYLON_FILE.reverse() self.init = 1 NICK='d' SYMBOL=self.__symbol() GREET=self.__greet() MSG='{}: {} {} <<>>'.format(NICK,SYMBOL,GREET) 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) if len(ONLINE_BOTS) == TOTAL_BOTS: self.krylon() @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)