prevent cases where you can unintentionally vote / act on yourself
This commit is contained in:
parent
5f458cc9dc
commit
784bbe0111
@ -235,14 +235,14 @@ def complete_match(string, matches):
|
|||||||
bestmatch = string
|
bestmatch = string
|
||||||
for possible in matches:
|
for possible in matches:
|
||||||
if string == possible:
|
if string == possible:
|
||||||
return string
|
return string, 1
|
||||||
if possible.startswith(string):
|
if possible.startswith(string):
|
||||||
bestmatch = possible
|
bestmatch = possible
|
||||||
num_matches += 1
|
num_matches += 1
|
||||||
if num_matches != 1:
|
if num_matches != 1:
|
||||||
return None
|
return None, num_matches
|
||||||
else:
|
else:
|
||||||
return bestmatch
|
return bestmatch, 1
|
||||||
|
|
||||||
#wrapper around complete_match() used for roles
|
#wrapper around complete_match() used for roles
|
||||||
def get_victim(cli, nick, victim, self_in_list = False):
|
def get_victim(cli, nick, victim, self_in_list = False):
|
||||||
@ -252,10 +252,10 @@ def get_victim(cli, nick, victim, self_in_list = False):
|
|||||||
pl = [x for x in var.list_players() if x != nick or self_in_list]
|
pl = [x for x in var.list_players() if x != nick or self_in_list]
|
||||||
pll = [x.lower() for x in pl]
|
pll = [x.lower() for x in pl]
|
||||||
|
|
||||||
tempvictim = complete_match(victim.lower(), pll)
|
tempvictim, num_matches = complete_match(victim.lower(), pll)
|
||||||
if not tempvictim:
|
if not tempvictim:
|
||||||
#ensure messages about not being able to act on yourself work
|
#ensure messages about not being able to act on yourself work
|
||||||
if nick.lower().startswith(victim.lower()):
|
if num_matches == 0 and nick.lower().startswith(victim.lower()):
|
||||||
return nick
|
return nick
|
||||||
cli.notice(nick, "\u0002{0}\u0002 is currently not playing.".format(victim))
|
cli.notice(nick, "\u0002{0}\u0002 is currently not playing.".format(victim))
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user