def channel_delvoice(nick,host,chan,arg): auth = getauth(nick) flag = getflag(chan,auth) target = getauth(arg.split()[0]) uatarget = arg.split()[0] if flag == "n": if auth != target: if wmatch(uatarget, "*!*@*"): entry = True for data in _chandb.execute("select flags from channel where channel='%s' and auth = '%s' and flags='v'" % (chan,uatarget)): entry = False if entry is False: _chandb.execute("delete from channel where channel='%s' and auth='%s' and flags='v'" % (chan,uatarget)) put("NOTICE %s :[%s] %s has been removed from the voices list" % (nick,chan,uatarget)) else: put("NOTICE %s :[%s] %s is not on the voices list" % (nick,chan,uatarget)) else: entry = True for data in _chandb.execute("select flags from channel where channel='%s' and auth='%s' and flags='v'" % (chan,target)): entry = False if entry is False: _chandb.execute("delete from channel where channel='%s' and auth='%s' and flags='v'" % (chan,target)) put("NOTICE %s :[%s] %s has been removed from the voices list" % (nick,chan,target)) put("MODE %s -v %s" % (chan,arg.split()[0])) else: put("NOTICE %s :[%s] %s is not on the voices list" % (nick,chan,target)) else: put("NOTICE %s :[%s] You cannot remove yourself!" % (nick,chan))
def channel_addvoice(nick,host,chan,arg): auth = getauth(nick) flag = getflag(chan,auth) target = getauth(arg.split()[0]) uatarget = arg.split()[0] if flag == "n": if auth != target: if wmatch(uatarget, "*!*@*"): entry = False for data in _chandb.execute("select flags from channel where channel='%s' and auth = '%s' and flags='v'" % (chan,uatarget)): entry = True if entry is False: _chandb.execute("insert into channel values ('%s','%s','v')" % (chan,uatarget)) put("NOTICE %s :[%s] %s has been added to the voices list" % (nick,chan,uatarget)) else: put("NOTICE %s :[%s] %s is already on the voices list" % (nick,chan,uatarget)) else: entry = False for data in _chandb.execute("select flags from channel where channel='%s' and auth='%s' and flags='v'" % (chan,target)): entry = True if entry is False: _chandb.execute("insert into channel values ('%s','%s','v')" % (chan,target)) put("NOTICE %s :[%s] %s has been added to the voices list" % (nick,chan,target)) put("MODE %s +v %s" % (chan,arg.split()[0])) else: put("NOTICE %s :[%s] %s is already on the voices list" % (nick,chan,target)) else: put("NOTICE %s :[%s] You cannot add yourself!" % (nick,chan))
def channel_addvoice(nick, host, chan, arg): auth = getauth(nick) flag = getflag(chan, auth) target = getauth(arg.split()[0]) uatarget = arg.split()[0] if flag == "n": if auth != target: if wmatch(uatarget, "*!*@*"): entry = False for data in _chandb.execute( "select flags from channel where channel='%s' and auth = '%s' and flags='v'" % (chan, uatarget)): entry = True if entry is False: _chandb.execute( "insert into channel values ('%s','%s','v')" % (chan, uatarget)) put("NOTICE %s :[%s] %s has been added to the voices list" % (nick, chan, uatarget)) else: put("NOTICE %s :[%s] %s is already on the voices list" % (nick, chan, uatarget)) else: entry = False for data in _chandb.execute( "select flags from channel where channel='%s' and auth='%s' and flags='v'" % (chan, target)): entry = True if entry is False: _chandb.execute( "insert into channel values ('%s','%s','v')" % (chan, target)) put("NOTICE %s :[%s] %s has been added to the voices list" % (nick, chan, target)) put("MODE %s +v %s" % (chan, arg.split()[0])) else: put("NOTICE %s :[%s] %s is already on the voices list" % (nick, chan, target)) else: put("NOTICE %s :[%s] You cannot add yourself!" % (nick, chan))
def channel_delvoice(nick, host, chan, arg): auth = getauth(nick) flag = getflag(chan, auth) target = getauth(arg.split()[0]) uatarget = arg.split()[0] if flag == "n": if auth != target: if wmatch(uatarget, "*!*@*"): entry = True for data in _chandb.execute( "select flags from channel where channel='%s' and auth = '%s' and flags='v'" % (chan, uatarget)): entry = False if entry is False: _chandb.execute( "delete from channel where channel='%s' and auth='%s' and flags='v'" % (chan, uatarget)) put("NOTICE %s :[%s] %s has been removed from the voices list" % (nick, chan, uatarget)) else: put("NOTICE %s :[%s] %s is not on the voices list" % (nick, chan, uatarget)) else: entry = True for data in _chandb.execute( "select flags from channel where channel='%s' and auth='%s' and flags='v'" % (chan, target)): entry = False if entry is False: _chandb.execute( "delete from channel where channel='%s' and auth='%s' and flags='v'" % (chan, target)) put("NOTICE %s :[%s] %s has been removed from the voices list" % (nick, chan, target)) put("MODE %s -v %s" % (chan, arg.split()[0])) else: put("NOTICE %s :[%s] %s is not on the voices list" % (nick, chan, target)) else: put("NOTICE %s :[%s] You cannot remove yourself!" % (nick, chan))
def channel_modes(nick,host,chan,arg): auth = getauth(nick) hostmask = nick+"!"+host flag = getflag(chan,auth) hostflag = gethostflag(chan,hostmask) if flag == "n" or flag == "o" or hostflag == "o": _chandb.execute("update info set modes='%s' where channel='%s'" % (arg,chan)) put("MODE %s %s" % (chan,arg))
def invite(nick,host,chan,arg): auth = getauth(nick) flag = getflag(chan,auth) hostmask = nick+"!"+host hostflag = gethostflag(chan,hostmask) if flag == "n" or flag == "o" or hostflag == "o": for user in arg.split(): put("INVITE %s %s" % (user,chan))
def invite(nick, host, chan, arg): auth = getauth(nick) flag = getflag(chan, auth) hostmask = nick + "!" + host hostflag = gethostflag(chan, hostmask) if flag == "n" or flag == "o" or hostflag == "o": for user in arg.split(): put("INVITE %s %s" % (user, chan))
def channel_topic(nick,host,chan,arg): auth = getauth(nick) hostmask = nick+"!"+host flag = getflag(chan,auth) hostflag = gethostflag(chan,hostmask) if flag == "n" or flag == "o" or hostflag == "o": _chandb.execute("update info set topic='%s' where channel='%s'" % (arg,chan)) put("TOPIC %s :%s" % (chan,arg))
def exempt(nick, host, chan, arg): auth = getauth(nick) flag = getflag(chan, auth) hostmask = nick + "!" + host hostflag = gethostflag(chan, hostmask) if flag == "n" or flag == "o" or hostflag == "o": if len(arg.split()) > 0: target = arg.split()[0][1:] scut = arg.split()[0][0] if wmatch(target, "*!*@*"): if scut == "+": entry = False for data in _chandb.execute( "select exempt from exempts where channel='%s' and exempt='%s'" % (chan, target)): entry = True if entry is False: _chandb.execute( "insert into exempts values ('%s','%s')" % (chan, target)) put("NOTICE %s :[%s] %s has been added to the exemptlist" % (nick, chan, target)) whochan(chan) else: put("NOTICE %s :[%s] %s is already on the exemptlist" % (nick, chan, target)) elif scut == "-": entry = False for data in _chandb.execute( "select exempt from exempts where channel='%s' and exempt='%s'" % (chan, target)): entry = True if entry is True: _chandb.execute( "delete from exempts where channel='%s' and exempt='%s'" % (chan, target)) put("NOTICE %s :[%s] %s has been removed from the exemptlist" % (nick, chan, target)) put("MODE %s -b %s" % (chan, target)) else: put("NOTICE %s :[%s] %s is not on the exemptlist" % (nick, chan, target)) else: irc_send(nick, "$exempt +/-*!*example@*.example.com") else: irc_send(nick, "$exempt +/-*!*example@*.example.com") else: for data in _chandb.execute( "select exempt from exempts where channel='%s'" % chan): irc_send(nick, "[%s] %s" % (chan, str(data[0])))
def channel_modes(nick, host, chan, arg): auth = getauth(nick) hostmask = nick + "!" + host flag = getflag(chan, auth) hostflag = gethostflag(chan, hostmask) if flag == "n" or flag == "o" or hostflag == "o": _chandb.execute("update info set modes='%s' where channel='%s'" % (arg, chan)) put("MODE %s %s" % (chan, arg))
def channel_register(nick,uhost,arg): password = arg.split()[0] channel = arg.split()[1] if password == c.get("ADMIN", "password"): _chandb.execute("insert into list values ('%s')" % channel) put("JOIN %s" % channel) put("NOTICE %s :%s has been added to the database ... You got owner flags" % (nick,channel)) _chandb.execute("insert into channel values ('%s','%s','n')" % (channel,getauth(nick))) _chandb.execute("insert into info values ('%s','','')" % channel)
def channel_topic(nick, host, chan, arg): auth = getauth(nick) hostmask = nick + "!" + host flag = getflag(chan, auth) hostflag = gethostflag(chan, hostmask) if flag == "n" or flag == "o" or hostflag == "o": _chandb.execute("update info set topic='%s' where channel='%s'" % (arg, chan)) put("TOPIC %s :%s" % (chan, arg))
def voice(nick,host,chan,arg): auth = getauth(nick) flag = getflag(chan,auth) hostmask = nick+"!"+host hostflag = gethostflag(chan,hostmask) if flag == "n" or flag == "o" or hostflag == "o": if len(arg.split()) != 0: mode = "v"*len(arg.split()) putf("MODE %s +%s %s" % (chan,mode,arg)) else: putf("MODE %s +v %s" % (chan,nick))
def on_join_chan(nick,uhost,chan): whois(nick) hostmask = nick + "!" + uhost auth = getauth(nick) flag = getflag(chan,auth) hostflag = gethostflag(chan,hostmask) if flag == "n" or flag == "o" or hostflag == "o": putf("MODE %s +o %s" % (chan,nick)) elif flag == "v" or hostflag == "v": putf("MODE %s +v %s" % (chan,nick))
def deop(nick, host, chan, arg): auth = getauth(nick) flag = getflag(chan, auth) hostmask = nick + "!" + host hostflag = gethostflag(chan, hostmask) if flag == "n" or flag == "o" or hostflag == "o": if len(arg.split()) != 0: mode = "o" * len(arg.split()) putf("MODE %s -%s %s" % (chan, mode, arg)) else: putf("MODE %s -o %s" % (chan, nick))
def on_join_chan(nick, uhost, chan): whois(nick) hostmask = nick + "!" + uhost auth = getauth(nick) flag = getflag(chan, auth) hostflag = gethostflag(chan, hostmask) if flag == "n" or flag == "o" or hostflag == "o": putf("MODE %s +o %s" % (chan, nick)) elif flag == "v" or hostflag == "v": putf("MODE %s +v %s" % (chan, nick))
def channel_register(nick, uhost, arg): password = arg.split()[0] channel = arg.split()[1] if password == c.get("ADMIN", "password"): _chandb.execute("insert into list values ('%s')" % channel) put("JOIN %s" % channel) put("NOTICE %s :%s has been added to the database ... You got owner flags" % (nick, channel)) _chandb.execute("insert into channel values ('%s','%s','n')" % (channel, getauth(nick))) _chandb.execute("insert into info values ('%s','','')" % channel)
def channel_auth(nick,host,chan,arg): whois(nick) put("NOTICE %s :[%s] Trying to auth ..." % (nick,chan)) auth = getauth(nick) hostmask = nick+"!"+host put("NOTICE %s :[%s] Getting flag for %s (%s)..." % (nick,chan,auth,hostmask)) flag = getflag(chan,auth) hostflag = gethostflag(chan,hostmask) put("NOTICE %s :[%s] Flag: %s, Hostflag: %s" % (nick,chan,flag,hostflag)) if flag == "n" or flag == "o" or hostflag == "o": putf("MODE %s +o %s" % (chan,nick)) elif flag == "v" or hostflag == "v": putf("MODE %s +v %s" % (chan,nick))
def kick(nick,host,chan,arg): auth = getauth(nick) flag = getflag(chan,auth) hostmask = nick+"!"+host hostflag = gethostflag(chan,hostmask) if flag == "n" or flag == "o" or hostflag == "o": if len(arg.split()) != 0: target = arg.split()[0] reason = "Requested." if len(arg.split()) != 1: reason = ' '.join(arg.split()[1:]) put("KICK %s %s :%s" % (chan,target,reason))
def kick(nick, host, chan, arg): auth = getauth(nick) flag = getflag(chan, auth) hostmask = nick + "!" + host hostflag = gethostflag(chan, hostmask) if flag == "n" or flag == "o" or hostflag == "o": if len(arg.split()) != 0: target = arg.split()[0] reason = "Requested." if len(arg.split()) != 1: reason = ' '.join(arg.split()[1:]) put("KICK %s %s :%s" % (chan, target, reason))
def channel_auth(nick, host, chan, arg): whois(nick) put("NOTICE %s :[%s] Trying to auth ..." % (nick, chan)) auth = getauth(nick) hostmask = nick + "!" + host put("NOTICE %s :[%s] Getting flag for %s (%s)..." % (nick, chan, auth, hostmask)) flag = getflag(chan, auth) hostflag = gethostflag(chan, hostmask) put("NOTICE %s :[%s] Flag: %s, Hostflag: %s" % (nick, chan, flag, hostflag)) if flag == "n" or flag == "o" or hostflag == "o": putf("MODE %s +o %s" % (chan, nick)) elif flag == "v" or hostflag == "v": putf("MODE %s +v %s" % (chan, nick))
def exempt(nick,host,chan,arg): auth = getauth(nick) flag = getflag(chan,auth) hostmask = nick+"!"+host hostflag = gethostflag(chan,hostmask) if flag == "n" or flag == "o" or hostflag == "o": if len(arg.split()) > 0: target = arg.split()[0][1:] scut = arg.split()[0][0] if wmatch(target, "*!*@*"): if scut == "+": entry = False for data in _chandb.execute("select exempt from exempts where channel='%s' and exempt='%s'" % (chan,target)): entry = True if entry is False: _chandb.execute("insert into exempts values ('%s','%s')" % (chan,target)) put("NOTICE %s :[%s] %s has been added to the exemptlist" % (nick,chan,target)) whochan(chan) else: put("NOTICE %s :[%s] %s is already on the exemptlist" % (nick,chan,target)) elif scut == "-": entry = False for data in _chandb.execute("select exempt from exempts where channel='%s' and exempt='%s'" % (chan,target)): entry = True if entry is True: _chandb.execute("delete from exempts where channel='%s' and exempt='%s'" % (chan,target)) put("NOTICE %s :[%s] %s has been removed from the exemptlist" % (nick,chan,target)) put("MODE %s -b %s" % (chan,target)) else: put("NOTICE %s :[%s] %s is not on the exemptlist" % (nick,chan,target)) else: irc_send(nick,"$exempt +/-*!*example@*.example.com") else: irc_send(nick,"$exempt +/-*!*example@*.example.com") else: for data in _chandb.execute("select exempt from exempts where channel='%s'" % chan): irc_send(nick,"[%s] %s" % (chan,str(data[0])))
def channel_msg_auth(nick,host,arg): if len(arg) == 0: irc_send(nick, "no channel specified") elif arg.startswith("#"): whois(nick) chan = arg.split()[0] put("NOTICE %s :[%s] Trying to auth ..." % (nick,chan)) auth = getauth(nick) hostmask = nick+"!"+host put("NOTICE %s :[%s] Getting flag for %s (%s)..." % (nick,chan,auth,hostmask)) flag = getflag(chan,auth) hostflag = gethostflag(chan,hostmask) put("NOTICE %s :[%s] Flag: %s, Hostflag: %s" % (nick,chan,flag,hostflag)) if flag == "n" or flag == "o" or hostflag == "o": putf("MODE %s +o %s" % (chan,nick)) elif flag == "v" or hostflag == "v": putf("MODE %s +v %s" % (chan,nick)) else: irc_send(nick, "invalid channel")
def channel_msg_auth(nick, host, arg): if len(arg) == 0: irc_send(nick, "no channel specified") elif arg.startswith("#"): whois(nick) chan = arg.split()[0] put("NOTICE %s :[%s] Trying to auth ..." % (nick, chan)) auth = getauth(nick) hostmask = nick + "!" + host put("NOTICE %s :[%s] Getting flag for %s (%s)..." % (nick, chan, auth, hostmask)) flag = getflag(chan, auth) hostflag = gethostflag(chan, hostmask) put("NOTICE %s :[%s] Flag: %s, Hostflag: %s" % (nick, chan, flag, hostflag)) if flag == "n" or flag == "o" or hostflag == "o": putf("MODE %s +o %s" % (chan, nick)) elif flag == "v" or hostflag == "v": putf("MODE %s +v %s" % (chan, nick)) else: irc_send(nick, "invalid channel")