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 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 irc_bans(text): chan = text.split()[3] host = text.split()[7]+"!"+text.split()[4]+"@"+text.split()[5] for data in _chandb.execute("select ban from bans where channel='%s'" % chan): if wmatch(host.lower(), str(data[0]).lower()): entry = False for data1 in _chandb.execute("select exempt from exempts where channel='%s'" % chan): if wmatch(host.lower(), str(data1[0]).lower()): entry = True for botnick in _cache.execute("select name from botnick"): if str(text.split()[7]).lower() == str(text.split()[2]).lower(): entry = True if entry == False: put("MODE %s +b %s" % (chan,data[0])) put("KICK %s %s :Banned." % (chan,text.split()[7]))
def irc_bans(text): chan = text.split()[3] host = text.split()[7] + "!" + text.split()[4] + "@" + text.split()[5] for data in _chandb.execute("select ban from bans where channel='%s'" % chan): if wmatch(host.lower(), str(data[0]).lower()): entry = False for data1 in _chandb.execute( "select exempt from exempts where channel='%s'" % chan): if wmatch(host.lower(), str(data1[0]).lower()): entry = True for botnick in _cache.execute("select name from botnick"): if str(text.split()[7]).lower() == str( text.split()[2]).lower(): entry = True if entry == False: put("MODE %s +b %s" % (chan, data[0])) put("KICK %s %s :Banned." % (chan, text.split()[7]))
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 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 onCommand(self, uid, args): arg = args.split() if len(arg) == 1: if arg[0].lower() == "list": current_timestamp = int(time.time()) self.msg(uid, "-=- List of Trusts -=-") result = self.query("SELECT id, address, \"limit\", timestamp FROM \"trust\"") for row in result: id = str(row["id"]) address = str(row["address"]) limit = str(row["limit"]) timestamp = self.convert_timestamp(int(int(row["timestamp"])- current_timestamp)) self.msg(uid, "ID: {0} Address: {1} Limit: {2} Time left: {3}".format(id, address, limit, timestamp)) self.msg(uid, "-=- End of list -=-") else: self.msg(uid, "Syntax: TRUST <set|update|del|list|search> [<address|id> [<time (in days)> [<limit>]]]") elif len(arg) == 2: if arg[0].lower() == "search": current_timestamp = int(time.time()) self.msg(uid, "-=- List of Trusts (lookup parameter: " + arg[1] + ") -=-") result = self.query("SELECT id, address, \"limit\", timestamp FROM \"trust\" WHERE id LIKE %s OR address LIKE %s", "%" + arg[1][1:] + "%", "%" + arg[1] + "%") for row in result: id = str(row["id"]) address = str(row["address"]) limit = str(row["limit"]) timestamp = self.convert_timestamp(int(int(row["timestamp"])- current_timestamp)) self.msg(uid, "ID: {0} Address: {1} Limit: {2} Time left: {3}".format(id, address, limit, timestamp)) self.msg(uid, "-=- End of list -=-") elif arg[0].lower() == "del": result = self.query("SELECT id, address, \"limit\" FROM \"trust\" WHERE address = %s", arg[1]) for row in result: self.query("DELETE FROM trust WHERE id = %s", row["id"]) self.msg(uid, "#Trust# " + str(row["address"]) + " (Limit: " + str(row["limit"]) + ") removed") self.msg(uid, "Done.") else: self.msg(uid, "Syntax: TRUST <set|update|del|list|search> [<address|id> [<time (in days)> [<limit>]]]") elif len(arg) == 4: if arg[0].lower() == "set": if arg[2].isdigit() and arg[3].isdigit(): tuid = arg[1] ttime = int(arg[2]) tlimit = int(arg[3]) if tuid != "0.0.0.0" and (wmatch(tuid, "*.*") or wmatch(tuid, "*:*")): for row in self.query("SELECT id FROM \"trust\" WHERE address = %s", tuid): self.msg(uid, "This entry is already active (ID #" + str(row["id"]) + ")!") return 0 etime = int(time.time()) + int(ttime * 60 * 60 * 24) self.query("INSERT INTO \"trust\" (address, \"limit\", timestamp) VALUES (%s, %s, %s)", tuid, tlimit, etime) for row in self.query("SELECT uid FROM online WHERE address = %s OR host = %s", tlimit, tlimit): self.checkconnection(row["uid"]) self.msg(uid, "Done.") self.send_to_op("#Trust# " + tuid + " added (Limit: " + str(tlimit) + ", Time left: " + self.convert_timestamp(int(ttime * 60 * 60 * 24)) + ")") else: self.msg(uid, "Denied.") else: self.msg(uid, "Syntax: TRUST <set|update|del|list|search> [<address|id> [<time (in days)> [<limit>]]]") elif arg[0].lower() == "update": if arg[2].isdigit() and arg[3].isdigit(): tuid = arg[1] ttime = int(arg[2]) tlimit = int(arg[3]) if tuid != "0.0.0.0" and (wmatch(tuid, "*.*") or wmatch(tuid, "*:*")): for row in self.query("SELECT id FROM trust WHERE address = %s", tuid): etime = int(time.time()) + int(ttime * 60 * 60 * 24) self.query("UPDATE \"trust\" SET timestamp = %s, \"limit\" = %s WHERE id = %s", etime, tlimit, row["id"]) for row in self.query("SELECT uid FROM online WHERE address = %s OR host = %s", tuid, tuid): self.checkconnection(row["uid"]) self.msg(uid, "Done.") self.send_to_op("#Trust# " + tuid + " updated (Limit: " + str(tlimit) + ", Time left: " + self.convert_timestamp(int(ttime * 60 * 60 * 24)) + ")") return 0 self.msg("Failed. There is no such record.") else: self.msg(uid, "Denied.") else: self.msg(uid, "Syntax: TRUST <set|update|del|list|search> [<address|id> [<time (in days)> [<limit>]]]") else: self.msg(uid, "Syntax: TRUST <set|update|del|list|search> [<address|id> [<time (in days)> [<limit>]]]") else: self.msg(uid, "Syntax: TRUST <set|update|del|list|search> [<address|id> [<time (in days)> [<limit>]]]")
def gethostflag(chan, host): for data in _chandb.execute( "select auth,flags from channel where channel='%s'" % chan): if wmatch(host.lower(), str(data[0]).lower()): return str(data[1])
def gethostflag(chan,host): for data in _chandb.execute("select auth,flags from channel where channel='%s'" % chan): if wmatch(host.lower(), str(data[0]).lower()): return str(data[1])