mirror of https://xfnw.ttm.sh/git/oirc.git
Compare commits
25 Commits
0a7b54c499
...
773a6b8e6e
Author | SHA1 | Date |
---|---|---|
vulpine | 773a6b8e6e | |
vulpine | b2661792f2 | |
vulpine | 66cc1a6bcd | |
vulpine | cdf122ccce | |
vulpine | ab76b268b8 | |
vulpine | 685ee1e27c | |
vulpine | 2cfd50085c | |
vulpine | 64c42350d2 | |
vulpine | 18dc6fd808 | |
vulpine | 10d1e6e5d7 | |
vulpine | 8ce353c074 | |
vulpine | c20fafe7e6 | |
vulpine | f72e9dcb6b | |
vulpine | 51cfbf555e | |
vulpine | 5d8cfa59a1 | |
vulpine | a238a18d25 | |
vulpine | 8f035e1c18 | |
vulpine | cd6d6d1590 | |
vulpine | e6651438e7 | |
vulpine | 808cb03e91 | |
vulpine | e184142bed | |
vulpine | 2888fa2fbd | |
vulpine | b1299b7752 | |
vulpine | 1e50154087 | |
vulpine | c855d9c8ea |
|
@ -1,51 +0,0 @@
|
|||
import random
|
||||
|
||||
|
||||
async def coffeeup(self,c,n,m):
|
||||
if c == '#coffee':
|
||||
if "coffee!" in m:
|
||||
cc = self.coffee.find_one(name='cupcount')
|
||||
if cc:
|
||||
self.coffee.update(dict(name='cupcount',value=cc['value']+1),['name'])
|
||||
else:
|
||||
self.coffee.insert(dict(name='cupcount',value=1))
|
||||
await self.message(c, '[\x036coffee\x0f] ・゜゜・。。・゜゜c[_] COFFEE UP!')
|
||||
elif "cupcount" in m:
|
||||
await self.message(c, '[\x036coffee\x0f] {} delicious cups of {}coffee served so far!'.format(
|
||||
self.coffee.find_one(name='cupcount')['value'], random.choice(self.coffeetypes)
|
||||
))
|
||||
if c == '#tea':
|
||||
if "tea!" in m:
|
||||
cc = self.coffee.find_one(name='teacount')
|
||||
if cc:
|
||||
self.coffee.update(dict(name='teacount',value=cc['value']+1),['name'])
|
||||
else:
|
||||
self.coffee.insert(dict(name='teacount',value=1))
|
||||
await self.message(c, '[\x036coffee\x0f] ・゜゜・。。・゜゜[_]b TEA UP!')
|
||||
elif "cupcount" in m:
|
||||
await self.message(c, '[\x036coffee\x0f] {} delicious mugs of {}tea served so far!'.format(
|
||||
self.coffee.find_one(name='teacount')['value'], random.choice(self.coffeetypes)
|
||||
))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async def init(self):
|
||||
self.raw['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('')
|
||||
|
||||
|
||||
|
||||
|
|
@ -2,7 +2,7 @@ import modules.identify as ident
|
|||
import asyncio
|
||||
|
||||
async def bal(self):
|
||||
bals = {'bank':self.initfund}
|
||||
bals = {}
|
||||
for t in self.ledger:
|
||||
await asyncio.sleep(0) # yeild control as this is a long operation
|
||||
t['amount'] = float(t['amount'])
|
||||
|
@ -14,12 +14,16 @@ async def bal(self):
|
|||
if t['to'] not in bals:
|
||||
bals[t['to']]=0.00
|
||||
|
||||
if bals[t['sender']] - t['amount'] < 0.0:
|
||||
if t['sender'] != 'bank' and round(bals[t['sender']],2) - t['amount'] < 0.0:
|
||||
self.ledger.delete(id=t['id'])
|
||||
continue # no debt for you
|
||||
bals[t['sender']] += 0 - t['amount']
|
||||
bals[t['to']] += t['amount'] * 0.99
|
||||
bals['bank'] += t['amount'] * 0.01
|
||||
bals[t['to']] += t['amount']
|
||||
|
||||
for i in bals:
|
||||
bals['bank'] += bals[i] * 0.001
|
||||
bals[i] -= bals[i] * 0.001
|
||||
self.initfund = abs(bals['bank'])
|
||||
return bals
|
||||
|
||||
async def send(self,c,n,m):
|
||||
|
@ -57,7 +61,7 @@ async def balance(self,c,n,m):
|
|||
latest['amount'], latest['sender'], latest['message']
|
||||
))
|
||||
else:
|
||||
await self.message(c, '[\x036coin\x0f] {}\u200c{}\'s balance is {} BUTT (BalUn Useless Trading Tokens), {}% of the total supply'
|
||||
await self.message(c, '[\x036coin\x0f] {}\u200c{}\'s balance is {} BUTT (Balun Useless Trading Tokens), {}% of the total supply'
|
||||
.format(m[:1],m[1:],round(bals[m],2),int((bals[m]/self.initfund)*100)))
|
||||
else:
|
||||
await self.message(c, '[\x036coin\x0f] this user has never made a transaction')
|
||||
|
@ -73,9 +77,9 @@ async def richest(self,c,n,m):
|
|||
|
||||
async def init(self):
|
||||
self.ledger = self.db['ledger']
|
||||
self.initfund = 137.0
|
||||
|
||||
self.initfund = 1
|
||||
|
||||
self.cmd['tipcoins'] = send
|
||||
self.cmd['sendcoins'] = send
|
||||
self.cmd['balance'] = balance
|
||||
self.cmd['richest'] = richest
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
import random
|
||||
|
||||
|
||||
async def coffeeup(self,c,n,m):
|
||||
if c in ['#coffee','#tea','#water']:
|
||||
if c[1:]+"!" in m and c+'!' not 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))
|
||||
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.raw['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('')
|
||||
|
||||
|
||||
|
||||
|
|
@ -13,8 +13,8 @@ async def more(self, c, n, m):
|
|||
if c in self.more:
|
||||
moretext = self.more.pop(c)
|
||||
if len(moretext) > 300:
|
||||
self.more[c]=moretext[:250]
|
||||
moretext = moretext[250:]+' (more)'
|
||||
self.more[c]=moretext[250:]
|
||||
moretext = moretext[:250]+' (more)'
|
||||
|
||||
await self.message(c, '[\x036help\x0f] '+moretext)
|
||||
return
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import random
|
||||
|
||||
async def owologger(self,c,n,m):
|
||||
print("<{} {}> {}".format(c,n,m))
|
||||
if m[:len(self.prefix)] == self.prefix:
|
||||
return
|
||||
if c not in self.owolog:
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
|
||||
async def pd(self,c,n,m):
|
||||
|
||||
if n in ['tildebot','BitBot','xfnw'] and m == '・゜゜・。。・゜゜\\_o< QUACK!':
|
||||
self.duckmsg[c] = 0
|
||||
print('duck in',c)
|
||||
elif c in self.duckmsg:
|
||||
self.duckmsg[c] += 1
|
||||
if self.duckmsg[c] == 200 or self.duckmsg[c] == 150 or self.duckmsg[c] == 140:
|
||||
await self.notice(self.ducknotif,'i predict there will be a duck in {} soon'.format(c))
|
||||
|
||||
async def init(self):
|
||||
self.raw['pd'] = pd
|
||||
self.ducknotif='xfnw'
|
||||
self.duckmsg = {}
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
import random
|
||||
|
||||
async def plogger(self,c,n,m):
|
||||
if c not in self.plog:
|
||||
self.plog[c] = []
|
||||
|
||||
self.plog[c].append([n,m])
|
||||
if len(self.plog[c]) > 50:
|
||||
del self.plog[c][:-50]
|
||||
|
||||
|
||||
if c in self.channels and 'o' in self.channels[c]['modes'] and self.nickname in self.channels[c]['modes']['o'] and ('v' not in self.channels[c]['modes'] or n not in self.channels[c]['modes']['v']):
|
||||
# fun time
|
||||
umc = len([i for i in self.plog[c][-10:] if i[0]==n])
|
||||
#await self.message(c,str(umc))
|
||||
if umc > 6:
|
||||
if n in self.wlevel:
|
||||
self.wlevel[n] += 1
|
||||
else:
|
||||
self.wlevel[n] = 0
|
||||
if self.wlevel[n] == 3:
|
||||
await self.set_mode(c,self.mutesyntax[0],self.mutesyntax[1].format(n+'!*@*'))
|
||||
if self.wlevel[n] > 10:
|
||||
self.wlevel[n] = 0
|
||||
await self.kick(c,n,'stop spamming thanks')
|
||||
|
||||
|
||||
|
||||
|
||||
async def init(self):
|
||||
self.plog = {}
|
||||
self.wlevel = {}
|
||||
self.mutesyntax = ['+b','m:{}'] # ['+q','{}'] on freenode
|
||||
self.raw['preventionlog'] = plogger
|
||||
|
|
@ -119,7 +119,7 @@ def formatSec(dt):
|
|||
|
||||
|
||||
async def upnext(self,c,n,m):
|
||||
if 'tildebot' in self.channels[c]['users']:
|
||||
if self.tildebot and c in self.channels and 'tildebot' in self.channels[c]['users']:
|
||||
return # only respond in #tr whilst tildebot is down
|
||||
res = requests.get('https://radio.tildeverse.org/api/station/1/schedule')
|
||||
if res.status_code == 200:
|
||||
|
@ -133,7 +133,7 @@ async def upnext(self,c,n,m):
|
|||
await self.message(c,'[\x036radio\x0f] something went wrong...')
|
||||
|
||||
async def nowplaying(self,c,n,m):
|
||||
if 'tildebot' in self.channels[c]['users']:
|
||||
if self.tildebot and c in self.channels and 'tildebot' in self.channels[c]['users']:
|
||||
return # only respond in #tr whilst tildebot is down
|
||||
res = requests.get("https://radio.tildeverse.org/api/nowplaying/1")
|
||||
if res.status_code == 200:
|
||||
|
@ -200,6 +200,7 @@ async def remindTask(self, n, up, delta_time,c):
|
|||
|
||||
|
||||
async def init(self):
|
||||
self.tildebot = True
|
||||
self.rreminders = {}
|
||||
self.cmd['un'] = upnext
|
||||
self.cmd['upnext'] = upnext
|
||||
|
|
|
@ -13,36 +13,37 @@ def isfloat(value):
|
|||
async def rpninp(self, chan, nick, msg):
|
||||
if chan not in self.rpnhist:
|
||||
self.rpnhist[chan] = [0]
|
||||
self.rpnhist[chan].append(0)
|
||||
del self.rpnhist[chan][15:]
|
||||
try:
|
||||
if isfloat(msg):
|
||||
self.rpnhist[chan].insert(0, float(msg))
|
||||
return
|
||||
elif msg == '+' or msg == 'a':
|
||||
self.rpnhist[chan][0] = self.rpnhist[chan][0]+self.rpnhist[chan].pop(1)
|
||||
elif msg == '-' or msg == 's':
|
||||
self.rpnhist[chan][0] = self.rpnhist[chan].pop(1)-self.rpnhist[chan][0]
|
||||
elif msg == '*' or msg == 'x' or msg == 'm':
|
||||
self.rpnhist[chan][0] = self.rpnhist[chan].pop(1)*self.rpnhist[chan][0]
|
||||
for m in msg.split(' '):
|
||||
self.rpnhist[chan].append(0)
|
||||
del self.rpnhist[chan][15:]
|
||||
if isfloat(m):
|
||||
self.rpnhist[chan].insert(0, float(m))
|
||||
continue
|
||||
elif m == '+' or m == 'a':
|
||||
self.rpnhist[chan][0] = self.rpnhist[chan][0]+self.rpnhist[chan].pop(1)
|
||||
elif m == '-' or m == 's':
|
||||
self.rpnhist[chan][0] = self.rpnhist[chan].pop(1)-self.rpnhist[chan][0]
|
||||
elif m == '*' or m == 'x' or m == 'm':
|
||||
self.rpnhist[chan][0] = self.rpnhist[chan].pop(1)*self.rpnhist[chan][0]
|
||||
|
||||
elif msg == '/' or msg == 'd':
|
||||
try:
|
||||
self.rpnhist[chan][0] = self.rpnhist[chan].pop(1)/self.rpnhist[chan][0]
|
||||
except ZeroDivisionError:
|
||||
self.rpnhist[chan][0] = float('NaN')
|
||||
elif m == '/' or m == 'd':
|
||||
try:
|
||||
self.rpnhist[chan][0] = self.rpnhist[chan].pop(1)/self.rpnhist[chan][0]
|
||||
except ZeroDivisionError:
|
||||
self.rpnhist[chan][0] = float('NaN')
|
||||
|
||||
elif msg == '^' or msg == 'e':
|
||||
self.rpnhist[chan][0] = self.rpnhist[chan].pop(1)**self.rpnhist[chan][0]
|
||||
elif m == '^' or m == 'e':
|
||||
self.rpnhist[chan][0] = self.rpnhist[chan].pop(1)**self.rpnhist[chan][0]
|
||||
|
||||
elif msg == 'p':
|
||||
pass # just dont do anything lol
|
||||
elif msg == 'r':
|
||||
if chan in self.rpnprint:
|
||||
await self.message(chan, '[\x036rpn\x0f] {}'.format(str(self.rpnhist[chan])))
|
||||
return
|
||||
else:
|
||||
return
|
||||
elif msg == 'p':
|
||||
pass # just dont do anything lol
|
||||
elif msg == 'r':
|
||||
if chan in self.rpnprint:
|
||||
await self.message(chan, '[\x036rpn\x0f] {}'.format(str(self.rpnhist[chan])))
|
||||
return
|
||||
else:
|
||||
return
|
||||
except OverflowError:
|
||||
if chan in self.rpnprint:
|
||||
await self.message(chan, '[\x036rpn\x0f] no u ur numbers are too phat')
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
# '[\x0303Pronouns\x03] Pronouns for xfnw: he/him'
|
||||
|
||||
|
||||
async def scraper(self,c,n,m):
|
||||
m = m.split(' ')
|
||||
if len(m) > 4:
|
||||
if m.pop(0) in ('[\x0303Pronouns\x03]', '[Pronouns]') and m.pop(0) == 'Pronouns' and m.pop(0) == 'for':
|
||||
person = m.pop(0)[:-1]
|
||||
pronouns = ' '.join(m)
|
||||
|
||||
print('found pronouns of {}: {}'.format(person,pronouns))
|
||||
self.pronoundb.upsert(dict(nick=person,pronouns=pronouns),['nick'])
|
||||
|
||||
async def getPronouns(self,c,n,m):
|
||||
m = m.strip()
|
||||
if not m:
|
||||
m = n
|
||||
pronoun = self.pronoundb.find_one(nick=m)
|
||||
if pronoun:
|
||||
await self.message(c,'[\x036scrape\x0f] Pronouns for {}: {}'.format(pronoun['nick'],pronoun['pronouns']))
|
||||
else:
|
||||
await self.message(c,'[\x036scrape\x0f] sorry i could not find {}\'s pronouns. (i scrape pronouns from logs, you dont need to set them :3 )'.format(m))
|
||||
|
||||
async def init(self):
|
||||
self.raw['scraper'] = scraper
|
||||
self.pronoundb = self.db['pronouns']
|
||||
|
||||
self.cmd['pronouns'] = getPronouns
|
||||
|
|
@ -16,6 +16,29 @@ async def on_all(self,wtime=100):
|
|||
self.userdb.insert_ignore(dict(user),['id'])
|
||||
print('done')
|
||||
|
||||
|
||||
async def maskfind(self,c,n,m):
|
||||
host = nick = ident = '%'
|
||||
m = m.strip().replace("*","%").split('@')
|
||||
host = m.pop()
|
||||
if len(m) > 0:
|
||||
ni = m.pop().split('!')
|
||||
ident = ni.pop()
|
||||
if len(ni) > 0:
|
||||
nick = ni.pop()
|
||||
|
||||
|
||||
alts = ["{}!{}@{}".format(i['nickname'],i['username'][:1]+"\u200c"+i['username'][1:],i['hostname']) for i in self.userdb.find(hostname={'like':host},username={'like':ident},nickname={'like':nick},order_by='-id')]
|
||||
falt=' '.join([i[:1]+'\u200c'+i[1:] for i in sorted(list(set(alts)))])
|
||||
if len(falt) > 250:
|
||||
self.more[c] = falt[200:]
|
||||
falt = falt[:200]+' (more)'
|
||||
await self.message(c,'[\x036usrinfo\x0f] masks: {}'.format(falt))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async def findalt(self,c,n,m):
|
||||
m = m.strip()
|
||||
user = self.userdb.find_one(nickname={'like':m},order_by='-id')
|
||||
|
@ -45,3 +68,5 @@ async def init(self):
|
|||
|
||||
self.help['findalt'] = ['findalt <nick> - find out who someone\'s alts are',';p']
|
||||
self.cmd['findalt'] = findalt
|
||||
self.help['maskfind'] = ['maskfind <mask> - search masks','OW']
|
||||
self.cmd['maskfind'] = maskfind
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Description=oirc bot
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh -c 'source /home/xfnw/env/bin/activate; cd /home/xfnw/oirc-bot/; PYTHONUNBUFFERED=1 ./bot.py'
|
||||
ExecStart=/bin/sh -c 'cd /home/xfnw/oirc-bot/; PYTHONUNBUFFERED=1 ./bot.py'
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
|
|
Loading…
Reference in New Issue