Browse Source

fix regression where wolf relay stopped working, add !simple database code

master
jcao219 13 years ago
parent
commit
2e19497d3d
  1. 15
      modules/common.py
  2. 20
      modules/wolfgame.py
  3. 17
      settings/wolfgame.py

15
modules/common.py

@ -8,10 +8,7 @@ import traceback @@ -8,10 +8,7 @@ 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): @@ -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)
@ -100,9 +94,6 @@ def connect_callback(cli): @@ -100,9 +94,6 @@ def connect_callback(cli):
need_ghost = False
def prepare_stuff(*args):
if var.MODULE_READY:
return
cli.join(botconfig.CHANNEL)
cli.msg("ChanServ", "op "+botconfig.CHANNEL)
@ -111,8 +102,6 @@ def connect_callback(cli): @@ -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:

20
modules/wolfgame.py

@ -310,7 +310,24 @@ def back_from_away(cli, nick, *rest): @@ -310,7 +310,24 @@ def back_from_away(cli, nick, *rest):
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): @@ -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): @@ -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:

17
settings/wolfgame.py

@ -18,6 +18,7 @@ KILL_IDLE_TIME = 300 @@ -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 @@ -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",
@ -171,11 +173,16 @@ with conn: @@ -171,11 +173,16 @@ with conn:
c = conn.cursor()
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:
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')
c.execute('CREATE TABLE roles (id INTEGER PRIMARY KEY AUTOINCREMENT, role TEXT)')
@ -202,6 +209,14 @@ def add_away(clk): @@ -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…
Cancel
Save