krylon/plugins/krylon.py
2021-03-08 07:16:21 -06:00

417 lines
16 KiB
Python

# -*- coding: utf-8 -*-
from irc3.plugins.command import command
import irc3
import os
import random
import ipdb
from random import randint
from re import compile
from irc3 import rfc
dir_path = os.path.dirname(os.path.realpath(__file__))
KRYPTR = []
BOTNAMES = []
BOTNICKS = []
TOTAL_BOTS = 0
READY_BOTS = []
LOCK_KRYLON = 1 # 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
def spraying(self, mask, channel, **kw):
self.kbr = []; self.kbw = []; self.kbl = [];
self.chn = channel
self.ptr = KRYPTR[0]
for index in range(len(self.ptr.BOTS_MODE_READ)):
self.kbr.append(self.ptr.BOTS_MODE_READ[index])
self.kbw.append(self.ptr.BOTS_MODE_WRIT[index])
self.kbl.append(self.ptr.KRYLON_FILE_LOCK[index])
self.fbu = self.ptr.FILE_BUFFER
self.fli = self.ptr.FILE_LINES
self.fin = self.ptr.FILE_INDEX
self.bna = BOTNAMES
self.bni = BOTNICKS
self.b1n = BOTNICKS.index(self.context.nick)
if self.ptr.INIT == 0:
self._ST8 = 0
self.ptr.INIT = 1
if self._ST8 <= 5 and KRYPTR[0].FINISHED == 1:
self.int = INTERRUPTED
INTERRUPTED = 0
self._ST8 = 3
self.who = self.context.nick
#INIT FIRST PASS
try:
if self.ptr.INIT == 0:
print('<<<<<<> JUST INIT <>>>>>>') # test if initialized for first pass, fails on purpose
except:
self.STARTED = 1
self.FINISHED = 0
self.exe = 1 # set to recognize execution
self.cyc = 0 # how many cycles within this operation, e.g. amount of bots pass through this function
self.ops = 0 # how many completed operations, cycles reset, ops continue to count
for y in len(self.context.config.botnet):
if not y == self.b1n:
self.kbr[y] = 0
else:
self.kbw[y] = 1
self.context.privmsg("#sh0rtbus","rfc test")
@irc3.event(irc3.rfc.JOIN)
def welcome(self, mask, channel, **kw):
if LOCK_KRYLON == 1:
B0T = self.context
for i,B0T.nick in enumerate(BOTNICKS):
if BOTNICKS[i] == B0T.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(rfc.PRIVMSG, iotype="out")
def krylon_event(bot, mask=None, event=None, target=None, data=None):
self._add_event(event, user=mask, data=data, channel=target)
# bot.context.privmsg("#sh0rtbus","this bot: {} sent smth".format(bot.nick))
# ipdb.set_trace()
@irc3.event(irc3.rfc.PRIVMSG)
def on_privmsg(self, mask=None, data=None, **kw):
B0T=self.context
self.BYPASSING=0
if mask.nick == 'd': self.BYPASSING=1
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 or self.BYPASSING == 1:
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 KRYPTR[0].STARTED == 1 and KRYPTR[0].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, you know... probably have not even received their actual valentine card yet. definitely got lost in the mail im sure but hey, show on this teddy bear where this artwork hurts 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
# """