Add option for Vgr's reverse (opt-in) ping mode
This commit is contained in:
parent
9fc3d081ac
commit
92a0c62f95
@ -247,9 +247,16 @@ def pinger(cli, nick, chan, rest):
|
|||||||
if not var.PINGING: return
|
if not var.PINGING: return
|
||||||
if user in (botconfig.NICK, nick): return # Don't ping self.
|
if user in (botconfig.NICK, nick): return # Don't ping self.
|
||||||
|
|
||||||
if (var.PINGING and 'G' not in status and
|
if (all((not var.OPT_IN_PING,
|
||||||
'+' not in status and cloak not in var.AWAY):
|
'G' not in status, # not /away
|
||||||
|
'+' not in status, # not already joined (voiced)
|
||||||
|
cloak not in var.AWAY)) or
|
||||||
|
all((var.OPT_IN_PING, '+' not in status,
|
||||||
|
cloak in var.PING_IN))):
|
||||||
|
|
||||||
TO_PING.append(user)
|
TO_PING.append(user)
|
||||||
|
else:
|
||||||
|
print(var.OPT_IN_PING, var.PINGING, status, cloak)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -271,6 +278,26 @@ def pinger(cli, nick, chan, rest):
|
|||||||
cli.who(botconfig.CHANNEL)
|
cli.who(botconfig.CHANNEL)
|
||||||
|
|
||||||
|
|
||||||
|
@cmd("simple", raw_nick = True)
|
||||||
|
@pmcmd("simple", raw_nick = True)
|
||||||
|
def mark_simple_notify(cli, nick, *rest):
|
||||||
|
"""If you want the bot to NOTICE you for every interaction"""
|
||||||
|
|
||||||
|
nick, _, __, cloak = parse_nick(nick)
|
||||||
|
|
||||||
|
if cloak in var.SIMPLE_NOTIFY:
|
||||||
|
var.SIMPLE_NOTIFY.remove(cloak)
|
||||||
|
var.remove_simple_rolemsg(cloak)
|
||||||
|
|
||||||
|
cli.notice(nick, "You now no longer receive simple role instructions.")
|
||||||
|
return
|
||||||
|
|
||||||
|
var.SIMPLE_NOTIFY.append(cloak)
|
||||||
|
var.add_simple_rolemsg(cloak)
|
||||||
|
|
||||||
|
cli.notice(nick, "You now receive simple role instructions.")
|
||||||
|
|
||||||
|
if not var.OPT_IN_PING:
|
||||||
@cmd("away", raw_nick=True)
|
@cmd("away", raw_nick=True)
|
||||||
@pmcmd("away", raw_nick=True)
|
@pmcmd("away", raw_nick=True)
|
||||||
def away(cli, nick, *rest):
|
def away(cli, nick, *rest):
|
||||||
@ -302,24 +329,34 @@ 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_notify(cli, nick, *rest):
|
|
||||||
"""If you want the bot to NOTICE you for every interaction"""
|
|
||||||
|
|
||||||
nick, _, __, cloak = parse_nick(nick)
|
else: # if OPT_IN_PING setting is on
|
||||||
|
@cmd("in", raw_nick=True)
|
||||||
if cloak in var.SIMPLE_NOTIFY:
|
@pmcmd("in", raw_nick=True)
|
||||||
var.SIMPLE_NOTIFY.remove(cloak)
|
def get_in(cli, nick, *rest):
|
||||||
var.remove_simple_rolemsg(cloak)
|
"""Get yourself in the ping list"""
|
||||||
|
nick, _, _, cloak = parse_nick(nick)
|
||||||
cli.notice(nick, "You now no longer receive simple role instructions.")
|
if cloak in var.PING_IN:
|
||||||
|
cli.notice(nick, "You are already on the list")
|
||||||
return
|
return
|
||||||
|
var.PING_IN.append(cloak)
|
||||||
|
var.add_ping(cloak)
|
||||||
|
|
||||||
var.SIMPLE_NOTIFY.append(cloak)
|
cli.notice(nick, "You are now on the list.")
|
||||||
var.add_simple_rolemsg(cloak)
|
|
||||||
|
@cmd("out", raw_nick=True)
|
||||||
|
@pmcmd("out", raw_nick=True)
|
||||||
|
def get_out(cli, nick, *rest):
|
||||||
|
"""Removes yourself from the ping list"""
|
||||||
|
nick, _, _, cloak = parse_nick(nick)
|
||||||
|
if cloak in var.PING_IN:
|
||||||
|
var.PING_IN.remove(cloak)
|
||||||
|
var.remove_ping(cloak)
|
||||||
|
|
||||||
|
cli.notice(nick, "You are no longer in the list.")
|
||||||
|
return
|
||||||
|
cli.notice(nick, "You are not in the list.")
|
||||||
|
|
||||||
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):
|
||||||
|
@ -13,8 +13,6 @@ NIGHT_TIME_LIMIT = 120
|
|||||||
NIGHT_TIME_WARN = 0 # should be less than NIGHT_TIME_LIMIT
|
NIGHT_TIME_WARN = 0 # should be less than NIGHT_TIME_LIMIT
|
||||||
DAY_TIME_LIMIT_WARN = 780
|
DAY_TIME_LIMIT_WARN = 780
|
||||||
DAY_TIME_LIMIT_CHANGE = 120 # seconds after DAY_TIME_LIMIT_WARN has passed
|
DAY_TIME_LIMIT_CHANGE = 120 # seconds after DAY_TIME_LIMIT_WARN has passed
|
||||||
START_WITH_DAY = False
|
|
||||||
WOLF_STEALS_GUN = False
|
|
||||||
KILL_IDLE_TIME = 300
|
KILL_IDLE_TIME = 300
|
||||||
WARN_IDLE_TIME = 180
|
WARN_IDLE_TIME = 180
|
||||||
PART_GRACE_TIME = 7
|
PART_GRACE_TIME = 7
|
||||||
@ -80,6 +78,13 @@ RULES = ("#wolfgame channel rules: 1) Be nice to others. 2) Do not share informa
|
|||||||
"family-friendly. 7) Do not paste PM's from the bot during the game. "+
|
"family-friendly. 7) Do not paste PM's from the bot during the game. "+
|
||||||
"8) Use common sense. 9) Waiting for timeouts is discouraged.")
|
"8) Use common sense. 9) Waiting for timeouts is discouraged.")
|
||||||
|
|
||||||
|
# Other settings:
|
||||||
|
START_WITH_DAY = False
|
||||||
|
WOLF_STEALS_GUN = False # at night, the wolf can steal steal the victim's bullets
|
||||||
|
|
||||||
|
OPT_IN_PING = False # instead of !away/!back, users can opt-in to be pinged
|
||||||
|
PING_IN = [] # cloaks of users who have opted in for ping
|
||||||
|
|
||||||
is_role = lambda plyr, rol: rol in ROLES and plyr in ROLES[rol]
|
is_role = lambda plyr, rol: rol in ROLES and plyr in ROLES[rol]
|
||||||
|
|
||||||
def plural(role):
|
def plural(role):
|
||||||
@ -172,7 +177,7 @@ conn = sqlite3.connect("data.sqlite3", check_same_thread = False)
|
|||||||
|
|
||||||
with conn:
|
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)') # whoops, i mean cloak, not nick
|
||||||
|
|
||||||
c.execute('CREATE TABLE IF NOT EXISTS simple_role_notify (cloak TEXT)') # people who understand each role
|
c.execute('CREATE TABLE IF NOT EXISTS simple_role_notify (cloak TEXT)') # people who understand each role
|
||||||
|
|
||||||
@ -196,10 +201,12 @@ with conn:
|
|||||||
'teamwins SMALLINT, individualwins SMALLINT, totalgames SMALLINT, '+
|
'teamwins SMALLINT, individualwins SMALLINT, totalgames SMALLINT, '+
|
||||||
'UNIQUE(player, role))'))
|
'UNIQUE(player, role))'))
|
||||||
|
|
||||||
|
if OPT_IN_PING:
|
||||||
|
c.execute('CREATE TABLE IF NOT EXISTS ping (cloak text)')
|
||||||
|
|
||||||
|
c.execute('SELECT * FROM ping')
|
||||||
|
for row in c:
|
||||||
|
PING_IN.append(row[0])
|
||||||
|
|
||||||
|
|
||||||
def remove_away(clk):
|
def remove_away(clk):
|
||||||
@ -218,6 +225,12 @@ def add_simple_rolemsg(clk):
|
|||||||
with conn:
|
with conn:
|
||||||
c.execute('INSERT into simple_role_notify VALUES (?)', (clk,))
|
c.execute('INSERT into simple_role_notify VALUES (?)', (clk,))
|
||||||
|
|
||||||
|
def remove_ping(clk):
|
||||||
|
with conn:
|
||||||
|
c.execute('DELETE from ping where cloak=?', (clk,))
|
||||||
|
def add_ping(clk):
|
||||||
|
with conn:
|
||||||
|
c.execute('INSERT into ping 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