Update the ping-if with @skizzerz's notes.
This commit is contained in:
parent
75b14a87c1
commit
225fdbc6bb
@ -466,7 +466,7 @@ def pinger(cli, nick, chan, rest):
|
|||||||
var.PINGING = True
|
var.PINGING = True
|
||||||
TO_PING = []
|
TO_PING = []
|
||||||
|
|
||||||
pl = len(var.list_players())
|
|
||||||
|
|
||||||
@hook("whoreply", hookid=800)
|
@hook("whoreply", hookid=800)
|
||||||
def on_whoreply(cli, server, dunno, chan, dunno1,
|
def on_whoreply(cli, server, dunno, chan, dunno1,
|
||||||
@ -476,11 +476,12 @@ def pinger(cli, nick, chan, rest):
|
|||||||
|
|
||||||
if ('G' not in status and '+' not in status and not is_user_stasised(user)[0]):
|
if ('G' not in status and '+' not in status and not is_user_stasised(user)[0]):
|
||||||
acc = var.USERS[user]["account"]
|
acc = var.USERS[user]["account"]
|
||||||
|
lenp = len(var.list_players())
|
||||||
if not is_user_away(user):
|
if not is_user_away(user):
|
||||||
TO_PING.append(user)
|
TO_PING.append(user)
|
||||||
elif acc != "*" and acc in var.PING_IF_PREFS_ACCS and var.PING_IF_PREFS_ACCS[acc] <= pl:
|
elif acc != "*" and acc in var.PING_IF_PREFS_ACCS and var.PING_IF_PREFS_ACCS[acc] <= lenp:
|
||||||
TO_PING.append(user)
|
TO_PING.append(user)
|
||||||
elif not var.ACCOUNTS_ONLY and cloak in var.PING_IF_PREFS and var.PING_IF_PREFS[cloak] <= pl:
|
elif not var.ACCOUNTS_ONLY and cloak in var.PING_IF_PREFS and var.PING_IF_PREFS[cloak] <= lenp:
|
||||||
TO_PING.append(user)
|
TO_PING.append(user)
|
||||||
|
|
||||||
@hook("endofwho", hookid=800)
|
@hook("endofwho", hookid=800)
|
||||||
@ -798,14 +799,26 @@ def fpinger(cli, nick, chan, rest):
|
|||||||
@cmd("pingif", "pingme", "pingat", pm=True)
|
@cmd("pingif", "pingme", "pingat", pm=True)
|
||||||
def altpinger(cli, nick, chan, rest):
|
def altpinger(cli, nick, chan, rest):
|
||||||
"""Pings you when the number of players reaches your preference."""
|
"""Pings you when the number of players reaches your preference."""
|
||||||
if not rest or (rest.isdigit() and int(rest) == 0):
|
altpinged, players = is_user_altpinged(nick)
|
||||||
if is_user_altpinged(nick)[0]:
|
if not rest:
|
||||||
msg = "Your ping preferences have been removed (was {0}).".format(is_user_altpinged(nick)[1])
|
if altpinged:
|
||||||
|
msg = "Your ping preferences are currently set to {0}.".format(players)
|
||||||
|
else:
|
||||||
|
msg = "You do not have any ping preferences currently set."
|
||||||
|
|
||||||
|
if chan == nick:
|
||||||
|
pm(cli, nick, msg)
|
||||||
|
else:
|
||||||
|
cli.notice(nick, msg)
|
||||||
|
|
||||||
|
elif rest.isdigit() and int(rest) == 0:
|
||||||
|
if altpinged:
|
||||||
|
msg = "Your ping preferences have been removed (was {0}).".format(players)
|
||||||
if chan == nick:
|
if chan == nick:
|
||||||
pm(cli, nick, msg)
|
pm(cli, nick, msg)
|
||||||
else:
|
else:
|
||||||
cli.notice(nick, msg)
|
cli.notice(nick, msg)
|
||||||
toggle_altpinged_status(nick, 0, is_user_altpinged(nick)[1])
|
toggle_altpinged_status(nick, 0, players)
|
||||||
elif not rest:
|
elif not rest:
|
||||||
if chan == nick:
|
if chan == nick:
|
||||||
pm(cli, nick, "You need to enter a number.")
|
pm(cli, nick, "You need to enter a number.")
|
||||||
@ -818,23 +831,23 @@ def altpinger(cli, nick, chan, rest):
|
|||||||
cli.notice(nick, "You do not have any preferences set.")
|
cli.notice(nick, "You do not have any preferences set.")
|
||||||
elif rest.isdigit():
|
elif rest.isdigit():
|
||||||
rest = int(rest)
|
rest = int(rest)
|
||||||
if rest >= var.MAX_PLAYERS:
|
if rest > 999:
|
||||||
if chan == nick:
|
if chan == nick:
|
||||||
pm(cli, nick, "Please select a number between 0 and {0}.".format(var.MAX_PLAYERS-1))
|
pm(cli, nick, "Please select a number between 0 and {0}.".format(var.MAX_PLAYERS))
|
||||||
else:
|
else:
|
||||||
cli.notice(nick, "Please select a number between 0 and {0}.".format(var.MAX_PLAYERS-1))
|
cli.notice(nick, "Please select a number between 0 and {0}.".format(var.MAX_PLAYERS))
|
||||||
elif is_user_altpinged(nick)[1] == rest:
|
elif players == rest:
|
||||||
if chan == nick:
|
if chan == nick:
|
||||||
pm(cli, nick, "Your ping preferences are already set to {0}.".format(rest))
|
pm(cli, nick, "Your ping preferences are already set to {0}.".format(rest))
|
||||||
else:
|
else:
|
||||||
cli.notice(nick, "Your ping preferences are already set to {0}.".format(rest))
|
cli.notice(nick, "Your ping preferences are already set to {0}.".format(rest))
|
||||||
elif is_user_altpinged(nick)[0]:
|
elif altpinged:
|
||||||
msg = "Your ping preferences have been changed from {0} to {1}.".format(is_user_altpinged(nick)[1], rest)
|
msg = "Your ping preferences have been changed from {0} to {1}.".format(altpinged, rest)
|
||||||
if chan == nick:
|
if chan == nick:
|
||||||
pm(cli, nick, msg)
|
pm(cli, nick, msg)
|
||||||
else:
|
else:
|
||||||
cli.notice(nick, msg)
|
cli.notice(nick, msg)
|
||||||
toggle_altpinged_status(nick, rest, is_user_altpinged(nick)[1])
|
toggle_altpinged_status(nick, rest, players)
|
||||||
else:
|
else:
|
||||||
if chan == nick:
|
if chan == nick:
|
||||||
pm(cli, nick, "Your ping preferences have been set to {0}.".format(rest))
|
pm(cli, nick, "Your ping preferences have been set to {0}.".format(rest))
|
||||||
@ -849,16 +862,18 @@ def is_user_altpinged(nick):
|
|||||||
cloak = var.USERS[nick]["cloak"]
|
cloak = var.USERS[nick]["cloak"]
|
||||||
acc = var.USERS[nick]["account"]
|
acc = var.USERS[nick]["account"]
|
||||||
else:
|
else:
|
||||||
return False, None
|
return (False, None)
|
||||||
if acc and acc != "*":
|
if acc and acc != "*":
|
||||||
if acc in var.PING_IF_PREFS_ACCS.keys():
|
if acc in var.PING_IF_PREFS_ACCS.keys():
|
||||||
return True, var.PING_IF_PREFS_ACCS[acc]
|
return (True, var.PING_IF_PREFS_ACCS[acc])
|
||||||
elif not var.ACCOUNTS_ONLY and cloak in var.PING_IF_PREFS.keys():
|
elif not var.ACCOUNTS_ONLY and cloak in var.PING_IF_PREFS.keys():
|
||||||
return True, var.PING_IF_PREFS[cloak]
|
return (True, var.PING_IF_PREFS[cloak])
|
||||||
return False, None
|
return (False, None)
|
||||||
|
|
||||||
def toggle_altpinged_status(nick, value, old=None):
|
def toggle_altpinged_status(nick, value, old=None):
|
||||||
# nick should be in var.USERS; if not, let the error propagate
|
# nick should be in var.USERS if not fake; if not, let the error propagate
|
||||||
|
if is_fake_nick(nick):
|
||||||
|
return # don't blow up on fake nicks
|
||||||
cloak = var.USERS[nick]["cloak"]
|
cloak = var.USERS[nick]["cloak"]
|
||||||
acc = var.USERS[nick]["account"]
|
acc = var.USERS[nick]["account"]
|
||||||
if value == 0:
|
if value == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user