Ignore case when sorting names
This commit is contained in:
parent
8c66d97bf5
commit
fc5cc2f0d6
1 changed files with 6 additions and 4 deletions
10
infobot.py
10
infobot.py
|
|
@ -1,5 +1,4 @@
|
||||||
import yaboli
|
import yaboli
|
||||||
import operator
|
|
||||||
|
|
||||||
class InfoBot(yaboli.Bot):
|
class InfoBot(yaboli.Bot):
|
||||||
"""
|
"""
|
||||||
|
|
@ -53,10 +52,14 @@ class InfoBot(yaboli.Bot):
|
||||||
|
|
||||||
elif ("name" in options and options["name"] is not True) or "list" in options:
|
elif ("name" in options and options["name"] is not True) or "list" in options:
|
||||||
clients = []
|
clients = []
|
||||||
|
msg = ""
|
||||||
|
|
||||||
if "name" in options:
|
if "name" in options:
|
||||||
name = self.room.mentionable(options["name"]).lower()
|
name = self.room.mentionable(options["name"]).lower()
|
||||||
|
|
||||||
|
if name[:1] == "@":
|
||||||
|
msg += "Are you sure the name is \"{}\"? You might want to omit the @.\n\n"
|
||||||
|
|
||||||
clients = [c for c in self.room.get_sessions()
|
clients = [c for c in self.room.get_sessions()
|
||||||
if self.room.mentionable(c.name).lower() == name]
|
if self.room.mentionable(c.name).lower() == name]
|
||||||
|
|
||||||
|
|
@ -71,8 +74,7 @@ class InfoBot(yaboli.Bot):
|
||||||
clients = self.room.get_lurkers()
|
clients = self.room.get_lurkers()
|
||||||
|
|
||||||
if clients:
|
if clients:
|
||||||
msg = ""
|
for client in sorted(clients, key=lambda c: c.name.lower()):
|
||||||
for client in sorted(clients, key=operator.attrgetter("name")):
|
|
||||||
msg += "id={}, session_id={}, name={}\n".format(
|
msg += "id={}, session_id={}, name={}\n".format(
|
||||||
repr(client.id),
|
repr(client.id),
|
||||||
repr(client.session_id),
|
repr(client.session_id),
|
||||||
|
|
@ -81,7 +83,7 @@ class InfoBot(yaboli.Bot):
|
||||||
|
|
||||||
msg = msg[:-1] # remove trailing newline
|
msg = msg[:-1] # remove trailing newline
|
||||||
else:
|
else:
|
||||||
msg = "No clients"
|
msg += "No clients"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
people = len(self.room.get_people())
|
people = len(self.room.get_people())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue