356 lines
15 KiB
Python
356 lines
15 KiB
Python
# -*- coding: utf-8 -*-
|
|
from irc3.plugins.command import command
|
|
import irc3
|
|
import os
|
|
import random
|
|
import ipdb
|
|
from random import randint
|
|
|
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
KRYPTR = []
|
|
BOTNAMES = []
|
|
BOTNICKS = []
|
|
TOTAL_BOTS = 0
|
|
READY_BOTS = []
|
|
LOCK_KRYLON = 1
|
|
INTERRUPTED = 0
|
|
|
|
class KRYLON():
|
|
def __init__(self,bot,channel):
|
|
self.bot = bot
|
|
self.channel = channel
|
|
self.KRYLON_FILE = ['a'*40,'b'*40,'c'*40,'d'*40,'e'*40,'f'*40,'g'*40,'h'*40,'1'*40,'2'*40,'3'*40,'4'*40,'5'*40,'6'*40,'7'*40,'8'*40]
|
|
self.__run__()
|
|
def __run__(self):
|
|
self.KRYLON_FILE.reverse()
|
|
self.FILE_BUFFER=self.KRYLON_FILE
|
|
self.FILE_LINES = len(self.KRYLON_FILE)
|
|
self.INIT = 0
|
|
self.STARTED = 0
|
|
self.FINISHED = 0
|
|
self.FILE_INDEX = 0
|
|
self.KRYLON_FILE_LOCK = [] # BITWISE FILE LOCK SET
|
|
for _ in range(len(self.KRYLON_FILE)):
|
|
self.KRYLON_FILE_LOCK.append(1)
|
|
self.BOTS_MODE_LOCK = [] # BITWISE R/W BOT LOCK SET
|
|
for _ in range(len(READY_BOTS)):
|
|
self.BOTS_MODE_LOCK.append(zip('1','1'))
|
|
R=[]; W=[]; _X=-1; _Y=-1; # BITWISE R/W BOT LOCK UNSET
|
|
for _ in range(len(READY_BOTS)):
|
|
_X,_Y=list(self.BOTS_MODE_LOCK[_])[0]
|
|
R.append(int(_X))
|
|
W.append(int(_Y))
|
|
self.BOTS_MODE_READ=R
|
|
self.BOTS_MODE_WRIT=W
|
|
|
|
@irc3.plugin
|
|
class Plugin(object):
|
|
def __init__(self, context):
|
|
self.log = context.log
|
|
self.context = context
|
|
self.channel = context.config.channel
|
|
self._ST8 = 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
|
|
|
|
# @irc3.event(irc3.rfc.PRIVMSG)
|
|
# def on_privmsg(self, mask=None, data=None, **kw):
|
|
# BOT=self.context
|
|
# if mask.nick == 'd':
|
|
# MSG="rando lock on instance to see inheritance: {} <> {}".format(KRYPTR[0].rando,KRYPTR)
|
|
# CHN=self.channel
|
|
# BOT.privmsg(CHN,MSG)
|
|
|
|
# def rotate(self,botlist):
|
|
# pass
|
|
|
|
def spraying(self, mask, channel, **kw):
|
|
s=self
|
|
s._kbr = []; s._kbw = []; s._kbl = [];
|
|
s._chn = channel
|
|
s._ptr = KRYPTR[0]
|
|
for index in range(len(s._ptr.BOTS_MODE_READ)):
|
|
s._kbr.append(s._ptr.BOTS_MODE_READ[index])
|
|
s._kbw.append(s._ptr.BOTS_MODE_WRIT[index])
|
|
s._kbl.append(s._ptr.KRYLON_FILE_LOCK[index])
|
|
s._fbu = s._ptr.FILE_BUFFER
|
|
s._fli = s._ptr.FILE_LINES
|
|
s._fin = s._ptr.FILE_INDEX
|
|
s._bna = BOTNAMES
|
|
s._bni = BOTNICKS
|
|
if s._ptr.INIT == 0:
|
|
s._ST8 = 0
|
|
s._ptr.INIT = 1
|
|
if s._ST8 <= 5 and KRYPTR[0].FINISHED == 1:
|
|
s._int = INTERRUPTED
|
|
# <--- LOOSE VARIABLE MAY COMPLICATE THINGS FROM RE-REFERENCES
|
|
INTERRUPTED = 0
|
|
s._ST8 = 3
|
|
s._who = self.context.nick
|
|
|
|
@irc3.event(irc3.rfc.JOIN)
|
|
def welcome(self, mask, channel, **kw):
|
|
if LOCK_KRYLON == 1:
|
|
if mask.nick == self.context.nick:
|
|
READY_BOTS.append(self.context.nick)
|
|
BOTCNT = len(self.context.config.botnet)
|
|
if len(READY_BOTS) == BOTCNT:
|
|
TOTAL_BOTS = BOTCNT;
|
|
BOT=self.context
|
|
CHN=channel
|
|
k=KRYLON(BOT,CHN)
|
|
KRYPTR.append(k)
|
|
self.spraying(mask,channel,**kw)
|
|
|
|
@irc3.event(irc3.rfc.CONNECTED)
|
|
def connected(self, **kw):
|
|
if LOCK_KRYLON == 1:
|
|
for _ in [x for x in self.context.config.botnet]:
|
|
if kw['me'] in self.context.config.botnet[_].nick:
|
|
BOTNAMES.append(_)
|
|
BOTNICKS.append(kw['me'])
|
|
self.context.join(self.channel)
|
|
|
|
@irc3.event(irc3.rfc.PRIVMSG)
|
|
def on_privmsg(self, mask=None, data=None, **kw):
|
|
if self._ST8 == 2:
|
|
for i,B0T.nick in enumerate(BOTNICKS):
|
|
if BOTNICKS[i] == B0T.nick:
|
|
MSG="<< initial complications getting into the areas to do art ops, a server/channel/max-limit/key or invite only type issue >>"
|
|
#redundant code//change later
|
|
MSG+="(BOT)NICK/NAME:{}/{} <>".format(BOTNICKS[i],BOTNAMES[i])
|
|
MSG+="LOCK:{} READ:{} WRITE:{}".format(self._kbl[B1N],self._kbr[B1N],self._kbw[B1N])
|
|
MSG+="LINES:{} INDEX:{} INTERRUPTED:{}".format(self._fli,self._fin,self._int)
|
|
self.context.privmsg(CHN,MSG)
|
|
if self._ST8 >= 3:
|
|
NOTBOT=0
|
|
B0T = self.context
|
|
CHN = B0T.config.channel
|
|
try:
|
|
B1N = BOTNICKS.index(b0t.nick)
|
|
except:
|
|
pass
|
|
if not mask.nick == b0t.nick:
|
|
NOTBOT=1
|
|
if self.STARTED == 1 and self.FINISHED == 0:
|
|
if not self._fli <=0:
|
|
self.INTERRUPTED+=1
|
|
rando = random.randint(1,5)
|
|
MSG=''
|
|
if rando == 1:
|
|
MSG+='no cellphones plz'
|
|
elif rando == 2:
|
|
MSG+='mind being quiet?'
|
|
elif rando == 3:
|
|
MSG+='trying to do something here...'
|
|
elif rando == 4:
|
|
MSG+='have you seen this before?'
|
|
elif rando == 5:
|
|
MSG+='there could be a secret message'
|
|
self.context.privmsg(CHN,MSG)
|
|
KRYPTR[0].FILE_BUFFER=KRYPTR[0].KRYLON_FILE
|
|
KRYPTR[0].FILE_LINES = len(KRYPTR[0].KRYLON_FILE)
|
|
KRYPTR[0].FILE_INDEX = 0
|
|
self.spraying(mask,self.channel,**kw)
|
|
self._ST8 = 5
|
|
else:
|
|
NOTBOT=0
|
|
if self._ST8 == 3:
|
|
for i,B0T.nick in enumerate(BOTNICKS):
|
|
if BOTNICKS[i] == B0T.nick:
|
|
MSG="<< ART OP SIMULATION >>"
|
|
#redundant code//change later
|
|
MSG+="(BOT)NICK/NAME:{}/{} <>".format(BOTNICKS[i],BOTNAMES[i])
|
|
MSG+="LOCK:{} READ:{} WRITE:{}".format(self._kbl[B1N],self._kbr[B1N],self._kbw[B1N])
|
|
MSG+="LINES:{} INDEX:{} INTERRUPTED:{}".format(self._fli,self._fin,self._int)
|
|
self.context.privmsg(CHN,MSG)
|
|
if self._ST8 == 4:
|
|
for i,B0T.nick in enumerate(BOTNICKS):
|
|
if BOTNICKS[i] == B0T.nick:
|
|
MSG="<< done with no interruptions >>"
|
|
#redundant code//change later
|
|
MSG+="(BOT)NICK/NAME:{}/{} <>".format(BOTNICKS[i],BOTNAMES[i])
|
|
MSG+="LOCK:{} READ:{} WRITE:{}".format(self._kbl[B1N],self._kbr[B1N],self._kbw[B1N])
|
|
MSG+="LINES:{} INDEX:{} INTERRUPTED:{}".format(self._fli,self._fin,self._int)
|
|
self.context.privmsg(CHN,MSG)
|
|
if self._ST8 == 5:
|
|
for i,B0T.nick in enumerate(BOTNICKS):
|
|
if BOTNICKS[i] == B0T.nick:
|
|
MENTALITY=self.INTERRUPTED
|
|
DIAGNOSIS=''
|
|
if MENTALITY < 3:
|
|
DIAGNOSIS='mild'
|
|
elif MENTALITY > 5 and mentality < 10:
|
|
DIAGNOSIS='notice me notice me type,'
|
|
elif MENTALITY > 10 and MENTALITY <= 20:
|
|
DIAGNOSIS='jack hoffish and almost k00nt like'
|
|
elif MENTALITY > 35 and MENTALITY < 50:
|
|
DIAGNOSIS='almost twitter/facbook/google type censorship'
|
|
elif MENTALITY >= 50:
|
|
DIAGNOSIS='semi-stalkerish and have not got received my valentines card yet kind of show on the teddy bear where artwork hurt you kind of'
|
|
MSG="<< done with some {} interruptions >>".format(DIAGNOSIS)
|
|
#redundant code//change later
|
|
MSG+="(BOT)NICK/NAME:{}/{} <>".format(BOTNICKS[i],BOTNAMES[i])
|
|
MSG+="LOCK:{} READ:{} WRITE:{}".format(self._kbl[B1N],self._kbr[B1N],self._kbw[B1N])
|
|
MSG+="LINES:{} INDEX:{} INTERRUPTED:{}".format(self._fli,self._fin,self._int)
|
|
self.context.privmsg(CHN,MSG)
|
|
if self._ST8 == 6:
|
|
for i,B0T.nick in enumerate(BOTNICKS):
|
|
if BOTNICKS[i] == B0T.nick:
|
|
MSG="<< someone or something is inihibiting the operations, we may not finish the op >>"
|
|
#redundant code//change later
|
|
MSG+="(BOT)NICK/NAME:{}/{} <>".format(BOTNICKS[i],BOTNAMES[i])
|
|
MSG+="LOCK:{} READ:{} WRITE:{}".format(self._kbl[B1N],self._kbr[B1N],self._kbw[B1N])
|
|
MSG+="LINES:{} INDEX:{} INTERRUPTED:{}".format(self._fli,self._fin,self._int)
|
|
self.context.privmsg(CHN,MSG)
|
|
if self._ST8 == 7:
|
|
for i,B0T.nick in enumerate(BOTNICKS):
|
|
if BOTNICKS[i] == B0T.nick:
|
|
MSG="<< im now offended and attacking the source of the problems, probably not gonna go well >>"
|
|
#redundant code//change later
|
|
MSG+="(BOT)NICK/NAME:{}/{} <>".format(BOTNICKS[i],BOTNAMES[i])
|
|
MSG+="LOCK:{} READ:{} WRITE:{}".format(self._kbl[B1N],self._kbr[B1N],self._kbw[B1N])
|
|
MSG+="LINES:{} INDEX:{} INTERRUPTED:{}".format(self._fli,self._fin,self._int)
|
|
self.context.privmsg(CHN,MSG)
|
|
if self._ST8 == 8:
|
|
for i,B0T.nick in enumerate(BOTNICKS):
|
|
if BOTNICKS[i] == B0T.nick:
|
|
MSG="<< finshed the op but people are definitely gonna be pissed >>"
|
|
#redundant code//change later
|
|
MSG+="(BOT)NICK/NAME:{}/{} <>".format(BOTNICKS[i],BOTNAMES[i])
|
|
MSG+="LOCK:{} READ:{} WRITE:{}".format(self._kbl[B1N],self._kbr[B1N],self._kbw[B1N])
|
|
MSG+="LINES:{} INDEX:{} INTERRUPTED:{}".format(self._fli,self._fin,self._int)
|
|
self.context.privmsg(CHN,MSG)
|
|
if self._ST8 == 9:
|
|
for i,B0T.nick in enumerate(BOTNICKS):
|
|
if BOTNICKS[i] == B0T.nick:
|
|
MSG="<< being shunted by forces of an administration access. failsafed and self-shutting down >>"
|
|
#redundant code//change later
|
|
MSG+="(BOT)NICK/NAME:{}/{} <>".format(BOTNICKS[i],BOTNAMES[i])
|
|
MSG+="LOCK:{} READ:{} WRITE:{}".format(self._kbl[B1N],self._kbr[B1N],self._kbw[B1N])
|
|
MSG+="LINES:{} INDEX:{} INTERRUPTED:{}".format(self._fli,self._fin,self._int)
|
|
self.context.privmsg(CHN,MSG)
|
|
|
|
|
|
# """
|
|
# @irc3.event(rfc.ERR_BADCHANNELKEY)
|
|
# def myevent(bot, srv=None, me=None, channel=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_BANNEDFROMCHAN)
|
|
# def myevent(bot, srv=None, me=None, channel=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_CANNOTSENDTOCHAN)
|
|
# def myevent(bot, srv=None, me=None, channel=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_CHANNELISFULL)
|
|
# def myevent(bot, srv=None, me=None, channel=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_NOPRIVILEGES)
|
|
# def myevent(bot, srv=None, me=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_NOSUCHCHANNEL)
|
|
# def myevent(bot, srv=None, me=None, channel=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_NOSUCHCHANNEL)
|
|
# def myevent(bot, srv=None, me=None, channel=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_NOTONCHANNEL)
|
|
# def myevent(bot, srv=None, me=None, channel=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.CTCP, iotype="out")
|
|
# def myevent(bot, event=None, target=None, ctcp=None):
|
|
|
|
# @irc3.event(rfc.INVITE)
|
|
# def myevent(bot, mask=None, channel=None, tags=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.JOIN)
|
|
# def myevent(bot, mask=None, channel=None, tags=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.JOIN_PART_QUIT, iotype="out")
|
|
# def myevent(bot, event=None, channel=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.KICK)
|
|
# def myevent(bot, mask=None, event=None, channel=None, target=None, data=None, tags=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.MODE)
|
|
# def myevent(bot, mask=None, event=None, target=None, modes=None, data=None, tags=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.MY_PRIVMSG)
|
|
# def myevent(bot, mask=None, event=None, target=None, data=None, tags=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.NEW_NICK, iotype="out")
|
|
# def myevent(bot, new_nick=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.PING)
|
|
# def myevent(bot, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.PONG)
|
|
# def myevent(bot, server=None, data=None, tags=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.PRIVMSG)
|
|
# def myevent(bot, mask=None, event=None, target=None, data=None, tags=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.QUIT, iotype="out")
|
|
# def myevent(bot, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.TOPIC)
|
|
# def myevent(bot, mask=None, channel=None, data=None, tags=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_ALREADYREGISTRED)
|
|
# def myevent(bot, srv=None, me=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_NOTREGISTERED)
|
|
# def myevent(bot, srv=None, me=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_ERRONEUSNICKNAME)
|
|
# def myevent(bot, srv=None, me=None, nick=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_NOLOGIN)
|
|
# def myevent(bot, srv=None, me=None, nick=None, data=None):
|
|
# # do something
|
|
|
|
# @irc3.event(rfc.ERR_PASSWDMISMATCH)
|
|
# def myevent(bot, srv=None, me=None, data=None):
|
|
# # do something
|
|
# """ |