mirror of https://xfnw.ttm.sh/git/oirc.git
tilde compliance and a few modules ported
This commit is contained in:
parent
9f5cfaf783
commit
ecbac51282
|
@ -3,7 +3,11 @@ import importlib, time, asyncio, random
|
|||
from bot import *
|
||||
|
||||
quitmessages = [
|
||||
"test"
|
||||
"time to die",
|
||||
'you can hide, but you can not run!',
|
||||
"you're next",
|
||||
'bye',
|
||||
'the balun has been popped.',
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
from bot import *
|
||||
|
||||
modulename='botlist'
|
||||
|
||||
@rawm('botlist')
|
||||
async def botlist(s,c,n,m):
|
||||
if m == '!botlist':
|
||||
await message(s,modulename,c,'hi im balun ; prefix . ; owner xfnw')
|
||||
|
||||
|
||||
async def init(self):
|
||||
await self.send(build("MODE",[self.nickname,'+B']))
|
|
@ -1,5 +1,6 @@
|
|||
import modules.identify as ident
|
||||
import asyncio
|
||||
from bot import *
|
||||
|
||||
|
||||
async def bal(self):
|
||||
bals = {}
|
||||
|
@ -32,12 +33,12 @@ async def send(self,c,n,m):
|
|||
await self.message(c, '[\x036coin\x0f] invalid syntax')
|
||||
return
|
||||
try:
|
||||
to = await ident.user(self, m.pop(0))
|
||||
to = self.users[m.pop(0).lower()].account
|
||||
except:
|
||||
await self.message(c, '[\x036coin\x0f] that user is not logged in. refusing so coins are not lost')
|
||||
amount = round(float(m.pop(0)),2)
|
||||
message = ' '.join(m)
|
||||
sender = await ident.user(self, n)
|
||||
sender = self.users[n.lower()].account
|
||||
|
||||
self.ledger.insert(dict(to=to,sender=sender,amount=amount,message=message))
|
||||
|
||||
|
@ -48,7 +49,7 @@ async def balance(self,c,n,m):
|
|||
if len(m) < 1:
|
||||
m = n
|
||||
try:
|
||||
m = await ident.user(self, m)
|
||||
m = self.users[m.lower()].account
|
||||
except:
|
||||
m = m
|
||||
bals = await bal(self)
|
||||
|
@ -76,16 +77,16 @@ async def richest(self,c,n,m):
|
|||
))
|
||||
|
||||
async def init(self):
|
||||
self.ledger = self.db['ledger']
|
||||
self.ledger = shared.db['ledger']
|
||||
self.initfund = 1
|
||||
|
||||
self.cmd['tipcoins'] = send
|
||||
self.cmd['sendcoins'] = send
|
||||
self.cmd['balance'] = balance
|
||||
self.cmd['richest'] = richest
|
||||
|
||||
shared.commands['tipcoins'] = send
|
||||
shared.commands['sendcoins'] = send
|
||||
shared.commands['balance'] = balance
|
||||
shared.commands['richest'] = richest
|
||||
|
||||
|
||||
return
|
||||
self.help['sendcoins'] = ['sendcoins <recipient> <amount> [message] - send someone coins. note (more)','this does NOT verify transactions went through!! check your balance after']
|
||||
self.help['balance'] = ['balance [person] - check someone\'s balance','coins owo']
|
||||
self.help['richest'] = ['richest - who has the most coins','coins owo']
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
import subprocess
|
||||
|
||||
from bot import *
|
||||
|
||||
def isfloat(value):
|
||||
try:
|
||||
|
@ -16,7 +16,7 @@ async def rpninp(self, chan, nick, msg):
|
|||
try:
|
||||
msg = msg.replace('+',' + ')
|
||||
msg = msg.replace('a',' a ')
|
||||
msg = msg.replace('-',' - ')
|
||||
#msg = msg.replace('-',' - ')
|
||||
msg = msg.replace('s',' s ')
|
||||
msg = msg.replace('\\',' \\ ')
|
||||
msg = msg.replace('*',' * ')
|
||||
|
@ -81,12 +81,12 @@ async def rpntoggle(self, chan, nick, msg):
|
|||
await self.message(chan, '[\x036rpn\x0f] rpn outputting has been enabled')
|
||||
|
||||
async def init(self):
|
||||
self.help['rpn'] = ['rpn <inp> - simple reverse polish notation calculator (more)', 'it has an alias of . so you can just do {}. <inp>, and if enabled it will also parse floats and functions as input. there are 4 functions, add (+|a), subtract (-|s), multiply (*|x|m), and devide (/|d), and p to print register 0'.format(self.prefix)]
|
||||
self.cmd['rpn'] = rpntinp
|
||||
self.cmd['.'] = rpntinp
|
||||
self.rawm['rpn'] = rpninp
|
||||
self.cmd['rt'] = rpntoggle
|
||||
self.help['rt'] = ['rt - toggle the output of rpn calculatons into the channel', 'rpn is cool']
|
||||
#self.help['rpn'] = ['rpn <inp> - simple reverse polish notation calculator (more)', 'it has an alias of . so you can just do {}. <inp>, and if enabled it will also parse floats and functions as input. there are 4 functions, add (+|a), subtract (-|s), multiply (*|x|m), and devide (/|d), and p to print register 0'.format(self.prefix)]
|
||||
shared.commands['rpn'] = rpntinp
|
||||
shared.commands['.'] = rpntinp
|
||||
shared.rawm['rpn'] = rpninp
|
||||
shared.commands['rt'] = rpntoggle
|
||||
#self.help['rt'] = ['rt - toggle the output of rpn calculatons into the channel', 'rpn is cool']
|
||||
|
||||
self.rpnhist = {}
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
|
||||
import importlib, time, asyncio, pydle
|
||||
|
||||
async def commit(self, chan, source, msg):
|
||||
await self.quit('{} told me to commit {}'.format(source,msg))
|
||||
|
||||
async def quit(self, chan, source, msg):
|
||||
await self.quit('{} told me to {}'.format(source,msg))
|
||||
|
||||
|
||||
|
||||
async def reloadmods(self, chan, source, msg):
|
||||
await self.message(chan, '[\x036admin\x0f] reloading modules...')
|
||||
self.oldcmd = self.cmd
|
||||
self.cmd = {}
|
||||
self.rawm = {}
|
||||
self.help = {}
|
||||
try:
|
||||
for i in self.modules:
|
||||
importlib.reload(self.modules[i])
|
||||
await self.modules[i].init(self)
|
||||
#await self.message(chan, '[\x036admin\x0f] load {} sucess!'.format(i))
|
||||
await self.message(chan, '[\x036admin\x0f] done! {} modules reloaded!'.format(len(self.modules)))
|
||||
except:
|
||||
await self.message(chan, '[\x036admin\x0f] reload failed... attempting to recover...')
|
||||
self.cmd = self.oldcmd
|
||||
|
||||
|
||||
async def part(self, chan, source, msg):
|
||||
await self.message(chan, '[\x036admin\x0f] bye {}'.format(msg))
|
||||
await self.part(msg)
|
||||
|
||||
async def join(self, chan, source, msg):
|
||||
self.t = time.time()+1
|
||||
await self.message(chan, '[\x036admin\x0f] joined {}'.format(msg))
|
||||
await self.join(msg)
|
||||
|
||||
async def joins(self, chan, source, msg):
|
||||
await self.message(chan, '[\x036admin\x0f] I will drop commands for some seconds to ignore chanhistory...')
|
||||
for i in self.chandb.all():
|
||||
self.t = time.time() + 5
|
||||
try:
|
||||
await self.join(i['name'])
|
||||
await asyncio.sleep(3)
|
||||
print('joined {}'.format(i['name']))
|
||||
except pydle.client.AlreadyInChannel:
|
||||
print('I am already in {}'.format(i['name']))
|
||||
await asyncio.sleep(3)
|
||||
await self.message(chan, '[\x036admin\x0f] Sucess!')
|
||||
|
||||
async def aexec(self, code):
|
||||
# Make an async function with the code and `exec` it
|
||||
exec(
|
||||
f'async def __ex(self): ' +
|
||||
''.join(f'\n {l}' for l in code.split('\n'))
|
||||
)
|
||||
|
||||
# Get `__ex` from local variables, call it and return the result
|
||||
return await locals()['__ex'](self)
|
||||
|
||||
|
||||
async def ev(self, chan, source, msg):
|
||||
msg = msg.split(' ')
|
||||
try:
|
||||
await self.message(chan, '[\x036admin\x0f] ok, output: {}'.format(
|
||||
str(await aexec(self, ' '.join(msg)))[:400]
|
||||
))
|
||||
except:
|
||||
await self.message(chan, '[\x036admin\x0f] exception in eval!')
|
||||
|
||||
async def send(self, c, n, m):
|
||||
msg = m.split(' ')
|
||||
await self.message(msg.pop(0), ' '.join(msg))
|
||||
await self.message(c, '[\x036admin\x0f] sent')
|
||||
|
||||
async def shut(self, c, n, m):
|
||||
self.qtime[c] = time.time()+(60*10)
|
||||
await self.message(c, '[\x036admin\x0f] Ok, il be back in 10 minutes')
|
||||
|
||||
async def schans(self, c, n, m):
|
||||
self.chandb.delete()
|
||||
for i in self.channels:
|
||||
self.chandb.insert(dict(name=i))
|
||||
await self.message(c, '[\x036admin\x0f] Ok')
|
||||
|
||||
async def addalias(self,c,n,m):
|
||||
al = m.split(' ')[0]
|
||||
m = m[len(al)+1:] # dont use the list since i want trailing spaces
|
||||
if al in self.cmd:
|
||||
await self.message(c,'[\x036admin\x0f] no dont overwrite a command dummy')
|
||||
return
|
||||
self.cmd[al]=Alias(m).alias
|
||||
|
||||
await self.message(c,'[\x036admin\x0f] added "{}" alias for "{}"'.format(al,m))
|
||||
|
||||
|
||||
async def addot(self,c,n,m):
|
||||
al = m.split(' ')[0]
|
||||
m = m[len(al)+1:] # dont use the list since i want trailing spaces
|
||||
if al in self.rawm:
|
||||
await self.message(c,'[\x036admin\x0f] no dont overwrite a command dummy')
|
||||
return
|
||||
self.rawm[al]=Ot(m,al).ot
|
||||
|
||||
await self.message(c,'[\x036admin\x0f] added "{}" trigger for "{}"'.format(al,m))
|
||||
|
||||
|
||||
|
||||
async def addtrigger(self,c,n,m):
|
||||
al = m.split(' ')[0]
|
||||
m = m[len(al)+1:] # dont use the list since i want trailing spaces
|
||||
if al in self.rawm:
|
||||
await self.message(c,'[\x036admin\x0f] no dont overwrite a command dummy')
|
||||
return
|
||||
self.rawm[al]=Trigger(m,al).trigger
|
||||
|
||||
await self.message(c,'[\x036admin\x0f] added "{}" trigger for "{}"'.format(al,m))
|
||||
|
||||
|
||||
|
||||
class Ot():
|
||||
def __init__(self, ms, al):
|
||||
self.ms = str(ms)
|
||||
self.al = str(al)
|
||||
async def ot(alself,self,c,n,m):
|
||||
if alself.al in m and n != self.nickname:
|
||||
asyncio.create_task(self.on_message(c,n,alself.ms.format(m)))
|
||||
self.rawm.pop(alself.al)
|
||||
|
||||
|
||||
|
||||
|
||||
class Trigger():
|
||||
def __init__(self, ms, al):
|
||||
self.ms = str(ms)
|
||||
self.al = str(al)
|
||||
async def trigger(alself,self,c,n,m):
|
||||
if alself.al in m:
|
||||
asyncio.create_task(self.on_message(c,n,alself.ms.format(m)))
|
||||
|
||||
|
||||
class Alias():
|
||||
def __init__(self, ms):
|
||||
self.ms = str(ms)
|
||||
async def alias(alself,self,c,n,m):
|
||||
asyncio.create_task(self.on_message(c,n,alself.ms.format(m)))
|
||||
|
||||
|
||||
|
||||
commands = {
|
||||
'quit': quit,
|
||||
'reload': reloadmods,
|
||||
'commit': commit,
|
||||
'part': part,
|
||||
'join': join,
|
||||
'eval': ev,
|
||||
'send': send,
|
||||
'joins': joins,
|
||||
'shut': shut,
|
||||
'schans': schans,
|
||||
'addalias': addalias,
|
||||
'addtrigger': addtrigger,
|
||||
'addot': addot,
|
||||
}
|
||||
|
||||
async def adminHandle(self, chan, source, msg):
|
||||
if await self.is_admin(source):
|
||||
msg = msg.split(' ')
|
||||
if len(msg) < 1 or not msg[0] in commands:
|
||||
await self.message(chan, '[\x036admin\x0f] Invalid command')
|
||||
return
|
||||
print('[ADMIN MODULE] {} told me to {}!!!'.format(source,msg[0]))
|
||||
asyncio.create_task(commands[msg.pop(0)](self, chan, source, ' '.join(msg)))
|
||||
else:
|
||||
await self.message(chan, '[\x036admin\x0f] You do not have permission to do this')
|
||||
|
||||
|
||||
async def init(self):
|
||||
self.chandb = self.db['chan']
|
||||
self.cmd['admin'] = adminHandle
|
||||
|
||||
self.help['admin'] = ['admin - various bot owner commands (more for subcommands)', 'sub-commands of admin, for more info do help admin <command>: quit reload commit part join joins eval send']
|
||||
self.help['admin quit'] = ['admin quit <message> - make the bot disconnect','no']
|
||||
self.help['admin reload'] = ['admin reload - reload the modules and configs', 'nothing to see here']
|
||||
self.help['admin commit'] = ['admin commit <action> - oh no (more)', 'suggested with <3 by khux']
|
||||
self.help['admin part'] = ['admin part <channel> - leave a channel', ':o']
|
||||
self.help['admin join'] = ['admin join <channel> - make the bot join a channel','...']
|
||||
self.help['admin joins'] = ['admin joins - join more channels', 'dont reconnect to a bunch of chans when the bots crashing etc']
|
||||
self.help['admin eval'] = ['admin eval <command> - absolute power corrupts absolutely', 'lmao']
|
||||
self.help['admin send'] = ['admin send <channel> <message> - send a message', 'lmao']
|
||||
self.help['admin schans'] = ['admin schans - save the commands to join',';p;']
|
||||
|
||||
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
import random
|
||||
|
||||
|
||||
async def coffeeup(self,c,n,m):
|
||||
if c in ['#coffee','#tea','#water','#CAPS','#sodawater']:
|
||||
if (c[1:]+"!" in m and c+'!' not in m) or c=='#coffee' and ('latte!' in m or 'espresso!' in m or 'cappucino!' in m) or c=='#tea' and ('chai!' in m):
|
||||
cc = self.coffee.find_one(name=c)
|
||||
if cc:
|
||||
self.coffee.update(dict(name=c,value=cc['value']+1),['name'])
|
||||
else:
|
||||
self.coffee.insert(dict(name=c,value=1))
|
||||
if c=='#CAPS':
|
||||
await self.message(c, '[\x036drinks\x0f] ・゜゜・。。・゜゜c[~] {} UP!'.format(c[1:].upper()).upper())
|
||||
else:
|
||||
await self.message(c, '[\x036drinks\x0f] ・゜゜・。。・゜゜c[~] {} UP!'.format(c[1:].upper()))
|
||||
elif "cupcount" in m:
|
||||
await self.message(c, '[\x036drinks\x0f] {} delicious cups of {}{} served so far!'.format(
|
||||
self.coffee.find_one(name=c)['value'], random.choice(self.coffeetypes), c[1:]
|
||||
))
|
||||
|
||||
|
||||
|
||||
|
||||
async def init(self):
|
||||
self.rawm['coffeeup'] = coffeeup
|
||||
self.coffee = self.db['coffee']
|
||||
|
||||
self.coffeetypes = [
|
||||
"kum\u200cquat's aeropressed ",
|
||||
"hot ",
|
||||
"OSHA-compliant ",
|
||||
"cmc\u200ccabe's nom nom nom yummy ",
|
||||
"healthy ",
|
||||
]
|
||||
for i in range(len(self.coffeetypes)):
|
||||
self.coffeetypes.append('')
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
|
||||
async def user(self,nick):
|
||||
u = await self.whois(nick)
|
||||
if u and u['account']:
|
||||
return u['account']
|
||||
else:
|
||||
raise Exception('NotLoggedIn')
|
||||
|
||||
async def init(self):
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue