-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
report channel counts and modes in status #1562
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,15 +76,53 @@ def status(self, irc, msg, args): | |
|
||
Returns the status of the bot. | ||
""" | ||
networks = {} | ||
# Initialize dictionaries | ||
nicks = {} | ||
channel_counts = {} | ||
op_counts = {} | ||
halfop_counts = {} | ||
voice_counts = {} | ||
normal_counts = {} | ||
|
||
# Iterate through each IRC network | ||
for Irc in world.ircs: | ||
networks.setdefault(Irc.network, []).append(Irc.nick) | ||
networks = sorted(networks.items()) | ||
networks = [format(_('%s as %L'), net, nicks) for (net,nicks) in networks] | ||
L = [format(_('I am connected to %L.'), networks)] | ||
network_name = Irc.network | ||
channels = Irc.state.channels | ||
|
||
# Initialize counts for this network | ||
channel_counts[network_name] = 0 | ||
op_counts[network_name] = 0 | ||
halfop_counts[network_name] = 0 | ||
voice_counts[network_name] = 0 | ||
normal_counts[network_name] = 0 | ||
nicks[network_name] = Irc.nick | ||
|
||
# Iterate through channels in this network | ||
for channel, channelinfo in channels.items(): | ||
# Increment the channel count for this network | ||
channel_counts[network_name] += 1 | ||
if Irc.nick in channelinfo.ops: | ||
op_counts[network_name] += 1 | ||
elif Irc.nick in channelinfo.halfops: | ||
halfop_counts[network_name] += 1 | ||
elif Irc.nick in channelinfo.voices: | ||
voice_counts[network_name] += 1 | ||
elif Irc.nick in channelinfo.users: | ||
normal_counts[network_name] += 1 | ||
|
||
# Prepare the response | ||
response_lines = [] | ||
for network_name in channel_counts: | ||
response_lines.append( | ||
f"I am connected to {network_name} as {nicks[network_name]}, Channels: {channel_counts[network_name]}, " | ||
f"Ops: {op_counts[network_name]}, Half-Ops: {halfop_counts[network_name]}, " | ||
f"Voiced: {voice_counts[network_name]}, Regular: {normal_counts[network_name]} " | ||
) | ||
|
||
irc.reply("".join(response_lines)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep |
||
|
||
if world.profiling: | ||
L.append(_('I am currently in code profiling mode.')) | ||
irc.reply(' '.join(L)) | ||
irc.reply(_('I am currently in code profiling mode.')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And keep this in the list, so it does not send it as an independent message |
||
status = wrap(status) | ||
|
||
@internationalizeDocstring | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the
_()
wrapper and%s
substitution so it's translatable.