fix regression where wolf relay stopped working, add !simple database code
This commit is contained in:
parent
42cbe54656
commit
5106785720
@ -8,10 +8,7 @@ import traceback
|
|||||||
from settings import common as var
|
from settings import common as var
|
||||||
|
|
||||||
def on_privmsg(cli, rawnick, chan, msg):
|
def on_privmsg(cli, rawnick, chan, msg):
|
||||||
if var.MODULE_READY:
|
currmod = ld.MODULES[ld.CURRENT_MODULE]
|
||||||
currmod = ld.MODULES[ld.CURRENT_MODULE]
|
|
||||||
else:
|
|
||||||
currmod = None
|
|
||||||
|
|
||||||
if botconfig.IGNORE_HIDDEN_COMMANDS and (chan.startswith("@#") or chan.startswith("+#")):
|
if botconfig.IGNORE_HIDDEN_COMMANDS and (chan.startswith("@#") or chan.startswith("+#")):
|
||||||
return
|
return
|
||||||
@ -62,10 +59,7 @@ def on_privmsg(cli, rawnick, chan, msg):
|
|||||||
cli.msg(chan, "An error has occurred and has been logged.")
|
cli.msg(chan, "An error has occurred and has been logged.")
|
||||||
|
|
||||||
def __unhandled__(cli, prefix, cmd, *args):
|
def __unhandled__(cli, prefix, cmd, *args):
|
||||||
if var.MODULE_READY:
|
currmod = ld.MODULES[ld.CURRENT_MODULE]
|
||||||
currmod = ld.MODULES[ld.CURRENT_MODULE]
|
|
||||||
else:
|
|
||||||
currmod = None
|
|
||||||
|
|
||||||
if cmd in set(list(HOOKS.keys())+(list(currmod.HOOKS.keys()) if currmod else list())):
|
if cmd in set(list(HOOKS.keys())+(list(currmod.HOOKS.keys()) if currmod else list())):
|
||||||
largs = list(args)
|
largs = list(args)
|
||||||
@ -100,9 +94,6 @@ def connect_callback(cli):
|
|||||||
need_ghost = False
|
need_ghost = False
|
||||||
|
|
||||||
def prepare_stuff(*args):
|
def prepare_stuff(*args):
|
||||||
if var.MODULE_READY:
|
|
||||||
return
|
|
||||||
|
|
||||||
cli.join(botconfig.CHANNEL)
|
cli.join(botconfig.CHANNEL)
|
||||||
cli.msg("ChanServ", "op "+botconfig.CHANNEL)
|
cli.msg("ChanServ", "op "+botconfig.CHANNEL)
|
||||||
|
|
||||||
@ -111,8 +102,6 @@ def connect_callback(cli):
|
|||||||
|
|
||||||
ld.MODULES[ld.CURRENT_MODULE].connect_callback(cli)
|
ld.MODULES[ld.CURRENT_MODULE].connect_callback(cli)
|
||||||
|
|
||||||
var.MODULE_READY = True
|
|
||||||
|
|
||||||
cli.nick(botconfig.NICK) # just in case
|
cli.nick(botconfig.NICK) # just in case
|
||||||
|
|
||||||
if botconfig.JOIN_AFTER_CLOAKED:
|
if botconfig.JOIN_AFTER_CLOAKED:
|
||||||
|
@ -310,7 +310,24 @@ def back_from_away(cli, nick, *rest):
|
|||||||
|
|
||||||
cli.notice(nick, "You are no longer marked as away.")
|
cli.notice(nick, "You are no longer marked as away.")
|
||||||
|
|
||||||
|
@cmd("simple", raw_nick = True)
|
||||||
|
@pmcmd("simple", raw_nick = True)
|
||||||
|
def mark_simple_role_notify(cli, nick, *rest):
|
||||||
|
"""If you don't want to bot to send you role instructions"""
|
||||||
|
|
||||||
|
nick, _, __, cloak = parse_nick(nick)
|
||||||
|
|
||||||
|
if cloak in var.SIMPLE_ROLE_NOTIFY:
|
||||||
|
var.SIMPLE_ROLE_NOTIFY.remove(cloak)
|
||||||
|
var.remove_simple_rolemsg(cloak)
|
||||||
|
|
||||||
|
cli.notice(nick, "You now no longer receive simple role instructions.")
|
||||||
|
return
|
||||||
|
|
||||||
|
var.SIMPLE_ROLE_NOTIFY.append(cloak)
|
||||||
|
var.add_simple_rolemsg(cloak)
|
||||||
|
|
||||||
|
cli.notice(nick, "You now receive simple role instructions.")
|
||||||
|
|
||||||
@cmd("fping", admin_only=True)
|
@cmd("fping", admin_only=True)
|
||||||
def fpinger(cli, nick, chan, rest):
|
def fpinger(cli, nick, chan, rest):
|
||||||
@ -1899,8 +1916,8 @@ def see(cli, nick, rest):
|
|||||||
|
|
||||||
@hook("featurelist") # For multiple targets with PRIVMSG
|
@hook("featurelist") # For multiple targets with PRIVMSG
|
||||||
def getfeatures(cli, nick, *rest):
|
def getfeatures(cli, nick, *rest):
|
||||||
var.MAX_PRIVMSG_TARGETS = 1
|
|
||||||
for r in rest:
|
for r in rest:
|
||||||
|
print(r)
|
||||||
if r.startswith("TARGMAX="):
|
if r.startswith("TARGMAX="):
|
||||||
x = r[r.index("PRIVMSG:"):]
|
x = r[r.index("PRIVMSG:"):]
|
||||||
if "," in x:
|
if "," in x:
|
||||||
@ -1908,6 +1925,7 @@ def getfeatures(cli, nick, *rest):
|
|||||||
else:
|
else:
|
||||||
l = x[x.index(":")+1:]
|
l = x[x.index(":")+1:]
|
||||||
l = l.strip()
|
l = l.strip()
|
||||||
|
print("** "+l)
|
||||||
if not l or not l.isdigit():
|
if not l or not l.isdigit():
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
@ -18,6 +18,7 @@ KILL_IDLE_TIME = 300
|
|||||||
WARN_IDLE_TIME = 180
|
WARN_IDLE_TIME = 180
|
||||||
PART_GRACE_TIME = 7
|
PART_GRACE_TIME = 7
|
||||||
QUIT_GRACE_TIME = 30
|
QUIT_GRACE_TIME = 30
|
||||||
|
MAX_PRIVMSG_TARGETS = 1
|
||||||
|
|
||||||
LOG_FILENAME = ""
|
LOG_FILENAME = ""
|
||||||
BARE_LOG_FILENAME = ""
|
BARE_LOG_FILENAME = ""
|
||||||
@ -49,6 +50,7 @@ ROLES_GUIDE = { 4 : ( 1 , 1 , 0 , 0 , 0 , 0 , 0
|
|||||||
|
|
||||||
GAME_MODES = {}
|
GAME_MODES = {}
|
||||||
AWAY = [] # cloaks of people who are away.
|
AWAY = [] # cloaks of people who are away.
|
||||||
|
SIMPLE_ROLE_NOTIFY = [] # cloaks of people who !simple, meaning they don't need role instructions
|
||||||
|
|
||||||
ROLE_INDICES = {0 : "seer",
|
ROLE_INDICES = {0 : "seer",
|
||||||
1 : "wolf",
|
1 : "wolf",
|
||||||
@ -171,11 +173,16 @@ with conn:
|
|||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute('CREATE TABLE IF NOT EXISTS away (nick TEXT)')
|
c.execute('CREATE TABLE IF NOT EXISTS away (nick TEXT)')
|
||||||
|
|
||||||
c.execute('SELECT * FROM away')
|
c.execute('CREATE TABLE IF NOT EXISTS simple_role_notify (cloak TEXT)') # people who understand each role
|
||||||
|
|
||||||
|
c.execute('SELECT * FROM away')
|
||||||
for row in c:
|
for row in c:
|
||||||
AWAY.append(row[0])
|
AWAY.append(row[0])
|
||||||
|
|
||||||
|
c.execute('SELECT * FROM simple_role_notify')
|
||||||
|
for row in c:
|
||||||
|
SIMPLE_ROLE_NOTIFY.append(row[0])
|
||||||
|
|
||||||
# populate the roles table
|
# populate the roles table
|
||||||
c.execute('DROP TABLE IF EXISTS roles')
|
c.execute('DROP TABLE IF EXISTS roles')
|
||||||
c.execute('CREATE TABLE roles (id INTEGER PRIMARY KEY AUTOINCREMENT, role TEXT)')
|
c.execute('CREATE TABLE roles (id INTEGER PRIMARY KEY AUTOINCREMENT, role TEXT)')
|
||||||
@ -202,6 +209,14 @@ def add_away(clk):
|
|||||||
with conn:
|
with conn:
|
||||||
c.execute('INSERT into away VALUES (?)', (clk,))
|
c.execute('INSERT into away VALUES (?)', (clk,))
|
||||||
|
|
||||||
|
def remove_simple_rolemsg(clk):
|
||||||
|
with conn:
|
||||||
|
c.execute('DELETE from simple_role_notify where nick=?', (clk,))
|
||||||
|
|
||||||
|
def add_simple_rolemsg(clk):
|
||||||
|
with conn:
|
||||||
|
c.execute('INSERT into simple_role_notify VALUES (?)', (clk,))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_role_stats(acc, role, won, iwon):
|
def update_role_stats(acc, role, won, iwon):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user