Rewrote auth system, added #kick and arguments to #deop

This commit is contained in:
Juhani Haverinen 2013-07-08 19:57:42 +03:00
parent 395770d9ae
commit c25af3b204
2 changed files with 42 additions and 11 deletions

View File

@ -1,17 +1,19 @@
import eliza
import threading
concmd=['/q']
concmd=['/q','/debg']
doctor=eliza.eliza()
opnicks=['nortti','nortti_','shikhin','shikhin_','shikhin__','sortiecat','martinFTW','graphitemaster','XgF','sprocklem']
trusted=['nortti','nortti_','shikhin','shikhin_','shikhin__','sortiecat','martinFTW','graphitemaster','XgF','sprocklem']
opchans=['#osdev-offtopic']
oprights={}
for i in opnicks:
for i in trusted:
oprights[i]=opchans
autoops={}
msgs={}
msglock=threading.Lock()
authcmds={}
authcmdlock=threading.Lock()
msglock.acquire()
f=open('msgs.txt','r')
@ -25,7 +27,14 @@ for line in f:
f.close()
msglock.release()
def addauthcmd(nick,cmd):
authcmdlock.acquire()
if nick not in trusted:
return
if nick not in authcmds:
authcmds[nick]=[]
authcmds[nick].append(cmd)
authcmdlock.release()
def parse((line,irc)):
line=line.split(' ')
nick=line[0].split('!')[0][1:]
@ -35,12 +44,26 @@ def parse((line,irc)):
irc.send('PRIVMSG %s :%s'%(chan,' '.join(line[4:])))
elif line[3]==':#op':
if len(line)==4:
addauthcmd(nick,'MODE %s +o %s'%(chan,nick))
irc.send('PRIVMSG NickServ :ACC '+nick)
else:
for name in line[4:]:
irc.send('PRIVMSG NickServ :ACC '+name)
addauthcmd(nick,'MODE %s +o %s'%(chan,name))
irc.send('PRIVMSG NickServ :ACC '+nick)
elif line[3]==':#deop':
irc.send('MODE %s -o %s'%(chan,nick))
if len(line)==4:
addauthcmd(nick,'MODE %s -o %s'%(chan,nick))
irc.send('PRIVMSG NickServ :ACC '+nick)
else:
for name in line[4:]:
addauthcmd(nick,'MODE %s -o %s'%(chan,name))
irc.send('PRIVMSG NickServ :ACC '+nick)
elif line[3]==':#kick':
if len(line)>4:
addauthcmd(nick,'KICK %s %s :%s'%(chan,line[4],' '.join(line[5:])))
irc.send('PRIVMSG NickServ :ACC '+nick)
else:
irc.send('PRIVMSG %s :Usage #kick nick reason'%chan)
elif line[3]==':#src':
irc.send('PRIVMSG %s :https://github.com/JuEeHa/oonbotti2'%chan)
elif line[3]==':#msg':
@ -65,11 +88,17 @@ def parse((line,irc)):
elif line[3][1:] in ('oonbotti:', 'oonbotti', 'oonbotti,', 'oonbotti2', 'oonbotti2:', 'oonbotti2,'):
irc.send('PRIVMSG %s :%s: %s'%(chan,nick,doctor.respond(' '.join(line[4:]))))
elif line[1]=='NOTICE' and line[0].split('!')[0]==':NickServ' and line[4]=='ACC':
if line[3][1:] in oprights and int(line[5])==3:
for opchan in oprights[line[3][1:]]:
irc.send('MODE %s +o %s'%(opchan,line[3][1:]))
authcmdlock.acquire()
if line[3][1:] in trusted and line[3][1:] in authcmds and line[5]=='3':
for i in authcmds.pop(line[3][1:]):
irc.send(i)
else:
authcmds.pop(line[3][1:])
authcmdlock.release()
elif line[1]=='JOIN' and nick in autoops and chan in autoops[nick]:
irc.send('PRIVMSG NickServ :ACC '+nick)
elif line[1]=='482':
irc.send('PRIVMSG %s :Not op'%line[3])
msglock.acquire()
if (line[1]=='PRIVMSG' or line[1]=='JOIN') and nick in msgs:
@ -88,13 +117,15 @@ def execcmd(cmdline):
def help(cmd):
if cmd=='':
return '#echo #op #deop #src #msg #readmsg #help'
return '#echo #op #deop #kick #src #msg #readmsg #help'
elif cmd=='#echo':
return '#echo text echo text back'
elif cmd=='#op':
return '#op [nick] give nick or yourself op rights in case nick/you is/are trusted by oonbotti2 and identified with NickServ'
elif cmd=='#deop':
return '#deop remove your oprights (added due to irrarional demand by shikhin and sortiecat)'
return '#deop [nick] remove your/nick\'s op rights (added due to irrational demand by shikhin and sortiecat, nick support added for same reason)'
elif cmd=='#kick':
return '#kick nick reason kicks nick with specified reason'
elif cmd=='#src':
return '#src paste a link to oonbotti2\'s git repo'
elif cmd=='#msg':

Binary file not shown.