fix regression where wolf relay stopped working, add !simple database code
This commit is contained in:
parent
42cbe54656
commit
5106785720
@ -8,11 +8,8 @@ import traceback
|
||||
from settings import common as var
|
||||
|
||||
def on_privmsg(cli, rawnick, chan, msg):
|
||||
if var.MODULE_READY:
|
||||
currmod = ld.MODULES[ld.CURRENT_MODULE]
|
||||
else:
|
||||
currmod = None
|
||||
|
||||
currmod = ld.MODULES[ld.CURRENT_MODULE]
|
||||
|
||||
if botconfig.IGNORE_HIDDEN_COMMANDS and (chan.startswith("@#") or chan.startswith("+#")):
|
||||
return
|
||||
|
||||
@ -62,10 +59,7 @@ def on_privmsg(cli, rawnick, chan, msg):
|
||||
cli.msg(chan, "An error has occurred and has been logged.")
|
||||
|
||||
def __unhandled__(cli, prefix, cmd, *args):
|
||||
if var.MODULE_READY:
|
||||
currmod = ld.MODULES[ld.CURRENT_MODULE]
|
||||
else:
|
||||
currmod = None
|
||||
currmod = ld.MODULES[ld.CURRENT_MODULE]
|
||||
|
||||
if cmd in set(list(HOOKS.keys())+(list(currmod.HOOKS.keys()) if currmod else list())):
|
||||
largs = list(args)
|
||||
@ -99,10 +93,7 @@ def connect_callback(cli):
|
||||
identified = False
|
||||
need_ghost = False
|
||||
|
||||
def prepare_stuff(*args):
|
||||
if var.MODULE_READY:
|
||||
return
|
||||
|
||||
def prepare_stuff(*args):
|
||||
cli.join(botconfig.CHANNEL)
|
||||
cli.msg("ChanServ", "op "+botconfig.CHANNEL)
|
||||
|
||||
@ -111,8 +102,6 @@ def connect_callback(cli):
|
||||
|
||||
ld.MODULES[ld.CURRENT_MODULE].connect_callback(cli)
|
||||
|
||||
var.MODULE_READY = True
|
||||
|
||||
cli.nick(botconfig.NICK) # just in case
|
||||
|
||||
if botconfig.JOIN_AFTER_CLOAKED:
|
||||
|
@ -309,8 +309,25 @@ def back_from_away(cli, nick, *rest):
|
||||
var.remove_away(cloak)
|
||||
|
||||
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)
|
||||
def fpinger(cli, nick, chan, rest):
|
||||
@ -1899,8 +1916,8 @@ def see(cli, nick, rest):
|
||||
|
||||
@hook("featurelist") # For multiple targets with PRIVMSG
|
||||
def getfeatures(cli, nick, *rest):
|
||||
var.MAX_PRIVMSG_TARGETS = 1
|
||||
for r in rest:
|
||||
print(r)
|
||||
if r.startswith("TARGMAX="):
|
||||
x = r[r.index("PRIVMSG:"):]
|
||||
if "," in x:
|
||||
@ -1908,6 +1925,7 @@ def getfeatures(cli, nick, *rest):
|
||||
else:
|
||||
l = x[x.index(":")+1:]
|
||||
l = l.strip()
|
||||
print("** "+l)
|
||||
if not l or not l.isdigit():
|
||||
continue
|
||||
else:
|
||||
|
@ -18,6 +18,7 @@ KILL_IDLE_TIME = 300
|
||||
WARN_IDLE_TIME = 180
|
||||
PART_GRACE_TIME = 7
|
||||
QUIT_GRACE_TIME = 30
|
||||
MAX_PRIVMSG_TARGETS = 1
|
||||
|
||||
LOG_FILENAME = ""
|
||||
BARE_LOG_FILENAME = ""
|
||||
@ -49,6 +50,7 @@ ROLES_GUIDE = { 4 : ( 1 , 1 , 0 , 0 , 0 , 0 , 0
|
||||
|
||||
GAME_MODES = {}
|
||||
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",
|
||||
1 : "wolf",
|
||||
@ -170,11 +172,16 @@ conn = sqlite3.connect("data.sqlite3", check_same_thread = False)
|
||||
with conn:
|
||||
c = conn.cursor()
|
||||
c.execute('CREATE TABLE IF NOT EXISTS away (nick TEXT)')
|
||||
|
||||
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:
|
||||
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
|
||||
c.execute('DROP TABLE IF EXISTS roles')
|
||||
@ -202,6 +209,14 @@ def add_away(clk):
|
||||
with conn:
|
||||
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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user