mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-16 15:39:21 +01:00
report channel counts and modes in status (#1562)
This commit is contained in:
parent
58287207d7
commit
5ccc035021
@ -76,17 +76,53 @@ class Status(callbacks.Plugin):
|
|||||||
|
|
||||||
Returns the status of the bot.
|
Returns the status of the bot.
|
||||||
"""
|
"""
|
||||||
|
# Initialize dictionaries
|
||||||
|
nicks = {}
|
||||||
networks = {}
|
networks = {}
|
||||||
|
# Iterate through each IRC network
|
||||||
for Irc in world.ircs:
|
for Irc in world.ircs:
|
||||||
networks.setdefault(Irc.network, []).append(Irc.nick)
|
network_name = Irc.network
|
||||||
networks = sorted(networks.items())
|
channels = Irc.state.channels
|
||||||
networks = [format(_('%s as %L'), net, nicks) for (net,nicks) in networks]
|
|
||||||
L = [format(_('I am connected to %L.'), networks)]
|
# Initialize counts for this network
|
||||||
|
channel_counts = len(channels)
|
||||||
|
op_counts = sum(1 for channel in channels.values() if Irc.nick in channel.ops)
|
||||||
|
halfop_counts = sum(1 for channel in channels.values() if Irc.nick in channel.halfops)
|
||||||
|
voice_counts = sum(1 for channel in channels.values() if Irc.nick in channel.voices)
|
||||||
|
normal_counts = sum(1 for channel in channels.values() if Irc.nick in channel.users)
|
||||||
|
|
||||||
|
# Store the counts in dictionaries
|
||||||
|
nicks[network_name] = Irc.nick
|
||||||
|
networks[network_name] = {
|
||||||
|
'Channels': channel_counts,
|
||||||
|
'Ops': op_counts,
|
||||||
|
'Half-Ops': halfop_counts,
|
||||||
|
'Voiced': voice_counts,
|
||||||
|
'Regular': normal_counts
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prepare the response
|
||||||
|
response_lines = []
|
||||||
|
for network_name, counts in networks.items():
|
||||||
|
response_lines.append(
|
||||||
|
format(
|
||||||
|
_('I am connected to %s as %s: Channels: %s, Ops: %s, Half-Ops: %s, Voiced: %s, Regular: %s'),
|
||||||
|
network_name,
|
||||||
|
nicks[network_name],
|
||||||
|
counts['Channels'],
|
||||||
|
counts['Ops'],
|
||||||
|
counts['Half-Ops'],
|
||||||
|
counts['Voiced'],
|
||||||
|
counts['Regular']
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if world.profiling:
|
if world.profiling:
|
||||||
L.append(_('I am currently in code profiling mode.'))
|
response_lines.append(_('I am currently in code profiling mode.'))
|
||||||
irc.reply(' '.join(L))
|
response = format(_("%L"), response_lines)
|
||||||
|
irc.reply(response)
|
||||||
status = wrap(status)
|
status = wrap(status)
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def threads(self, irc, msg, args):
|
def threads(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
|
Loading…
Reference in New Issue
Block a user