46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
import irc3
|
|
from irc3.testing import BotTestCase
|
|
import ipdb
|
|
|
|
|
|
testfile = ['a'*40,'b'*40,'c'*40,'d'*40,'1'*40,'2'*40,'3'*40,'4'*40]
|
|
KRYLON_FILE = testfile
|
|
|
|
TOTAL_BOTS = 4
|
|
CONNECTED_BOTS = []
|
|
ONLINE_BOTS = []
|
|
INITIALIZED = 0
|
|
|
|
@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 krylon(self):
|
|
if self.init == 0:
|
|
KRYLON_FILE.reverse()
|
|
self.init = 1
|
|
MSG='sent validation test'
|
|
CHN='#sh0rtbus'
|
|
self.context.privmsg(CHN,MSG)
|
|
BotTestCase.assertSent(['PRIVMSG {} :{}'.format(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)
|