Fix incorrect counting and add !recount
This commit is contained in:
parent
c681855981
commit
3dd136fc7d
1 changed files with 48 additions and 24 deletions
50
infobot.py
50
infobot.py
|
|
@ -14,27 +14,39 @@ class InfoBot(yaboli.Bot):
|
||||||
|
|
||||||
self.add_help("count", (
|
self.add_help("count", (
|
||||||
"This bot counts the number of clients connected to a room.\n"
|
"This bot counts the number of clients connected to a room.\n"
|
||||||
"If you open a room in two different tabs, the bot counts you twice.\n"
|
"If you open a room in two different tabs, the bot counts you "
|
||||||
"The euphoria client, on the other hand, usually displays all connections of an "
|
"twice.\n"
|
||||||
"account as one nick in the nick list.\n"
|
"The euphoria client, on the other hand, usually displays all "
|
||||||
"Because of that, this bot's count is always as high as, or higher than, the number "
|
"connections of an account as one nick in the nick list.\n"
|
||||||
"of nicks on the nick list."
|
"Because of that, this bot's count is always as high as, or higher "
|
||||||
|
"than, the number of nicks on the nick list.\n\n"
|
||||||
|
"If the bot's count is off, try a !recount."
|
||||||
))
|
))
|
||||||
|
|
||||||
self.add_help("lurkers", (
|
self.add_help("lurkers", (
|
||||||
"People or bots who are connected to the room but haven't chosen a nick are lurkers.\n"
|
"People or bots who are connected to the room but haven't chosen a "
|
||||||
|
"nick are lurkers.\n"
|
||||||
"The euphoria client doesn't display them in the nick list.\n"
|
"The euphoria client doesn't display them in the nick list.\n"
|
||||||
"This bot differentiates between people (L) and bots (N) who are lurking."
|
"This bot differentiates between people (L) and bots (N) who are "
|
||||||
|
"lurking."
|
||||||
|
))
|
||||||
|
|
||||||
|
self.add_help("changelog", (
|
||||||
|
"- add !recount command\n"
|
||||||
|
"- fix bot counting incorrectly\n"
|
||||||
))
|
))
|
||||||
|
|
||||||
self.help_specific = (
|
self.help_specific = (
|
||||||
"Displays information about the clients in a room in its nick:\n"
|
"Displays information about the clients in a room in its nick:\n"
|
||||||
"(<people>P <bots>B <lurkers>L <bot-lurkers>N)\n\n"
|
"(<people>P <bots>B <lurkers>L <bot-lurkers>N)\n\n"
|
||||||
|
"!recount @{nick} - Recount people in the room\n\n"
|
||||||
"Created by @Garmy using yaboli.\n"
|
"Created by @Garmy using yaboli.\n"
|
||||||
"For additional info, try \"!help @{nick} <topic>\". Topics:\n"
|
"For additional info, try \"!help @{nick} <topic>\". Topics:\n"
|
||||||
)
|
)
|
||||||
self.help_specific += self.list_help_topics()
|
self.help_specific += self.list_help_topics()
|
||||||
|
|
||||||
|
self.register_command("recount", self.command_recount, specific=False)
|
||||||
|
|
||||||
async def update_nick(self):
|
async def update_nick(self):
|
||||||
p = len(self.room.listing.get(types=["account", "agent"], lurker=False))
|
p = len(self.room.listing.get(types=["account", "agent"], lurker=False))
|
||||||
b = 1 + len(self.room.listing.get(types=["bot"], lurker=False))
|
b = 1 + len(self.room.listing.get(types=["bot"], lurker=False))
|
||||||
|
|
@ -52,20 +64,32 @@ class InfoBot(yaboli.Bot):
|
||||||
|
|
||||||
async def on_join(self, session):
|
async def on_join(self, session):
|
||||||
await self.update_nick()
|
await self.update_nick()
|
||||||
|
await self.room.who()
|
||||||
|
await self.update_nick()
|
||||||
|
|
||||||
async def on_part(self, session):
|
async def on_part(self, session):
|
||||||
await self.update_nick()
|
await self.update_nick()
|
||||||
|
await self.room.who()
|
||||||
|
await self.update_nick()
|
||||||
|
|
||||||
async def on_nick(self, session_id, user_id, from_nick, to_nick):
|
async def on_nick(self, session_id, user_id, from_nick, to_nick):
|
||||||
await self.update_nick()
|
await self.update_nick()
|
||||||
|
await self.room.who()
|
||||||
async def on_snapshot(self, user_id, session_id, version, sessions, messages, nick=None,
|
|
||||||
pm_with_nick=None, pm_with_user_id=None):
|
|
||||||
# Not needed because we're updating the nick anyways.
|
|
||||||
#super().on_snapshot(user_id, session_id, version, sessions, messages, nick, pm_with_nick,
|
|
||||||
#pm_with_user_id)
|
|
||||||
await self.update_nick()
|
await self.update_nick()
|
||||||
|
|
||||||
|
async def on_snapshot(self, user_id, session_id, version, sessions,
|
||||||
|
messages, nick=None, pm_with_nick=None,
|
||||||
|
pm_with_user_id=None):
|
||||||
|
# Not needed because we're updating the nick anyways.
|
||||||
|
#super().on_snapshot(user_id, session_id, version, sessions, messages,
|
||||||
|
# nick, pm_with_nick, pm_with_user_id)
|
||||||
|
await self.update_nick()
|
||||||
|
|
||||||
|
async def command_recount(self, message, argstr):
|
||||||
|
await self.room.who()
|
||||||
|
await self.update_nick()
|
||||||
|
await self.room.send("Recalibrated.", message.mid)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print("USAGE:")
|
print("USAGE:")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue