-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# plugins | ||
|
||
To port things from ircbot... | ||
|
||
- replace `msg.match` with `trigger` | ||
- replace `msg.respond` with `bot.reply` | ||
- if `ping=False` in the `msg.respond` replace it with `bot.say` | ||
- add any extra python packages needed to the dockerfile (`pipx inject`) | ||
- add the plugin to `.transpire.py` along with the others |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Get information about the lab.""" | ||
|
||
from ocflib.lab.stats import staff_in_lab | ||
from ocflib.lab.stats import users_in_lab_count | ||
|
||
from sopel import plugin | ||
|
||
|
||
@plugin.rule(r"is ([a-z]+) in the lab") | ||
def in_lab(bot, trigger): | ||
"""Check if a staffer is in the lab.""" | ||
username = trigger.group(1).strip() | ||
for session in staff_in_lab(): | ||
if username == session.user: | ||
bot.reply(f"{username} is in the lab") | ||
break | ||
else: | ||
bot.reply(f"{username} is not in the lab") | ||
|
||
|
||
def _prevent_ping(staffer): | ||
"""Hack to prevent pinging the person by inserting a zero-width no-break space in their name.""" | ||
return staffer[0] + "\u2060" + staffer[1:] | ||
|
||
|
||
@plugin.rule(r"(who is|who's) in the lab", r"(?i)w+i+t+l+") | ||
def who_is_in_lab(bot, trigger): | ||
"""Report on who is currently in the lab.""" | ||
staff = {session.user for session in staff_in_lab()} | ||
total = users_in_lab_count() | ||
|
||
if total != 1: | ||
are_number_people = f"are {total} people" | ||
else: | ||
are_number_people = "is 1 person" | ||
|
||
if staff: | ||
staff_list = ": {}".format( | ||
", ".join(sorted(_prevent_ping(staffer) for staffer in staff)) | ||
) | ||
else: | ||
staff_list = "" | ||
|
||
bot.reply( | ||
"there {} in the lab, including {} staff{}".format( | ||
are_number_people, | ||
len(staff), | ||
staff_list, | ||
), | ||
) |