Skip to content

Commit ded5dde

Browse files
committed
Refactor system information into resources files
1 parent c371a63 commit ded5dde

5 files changed

Lines changed: 118 additions & 130 deletions

File tree

arthur/exts/systems/system_information.py

Lines changed: 14 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import random
77
import sys
88
from datetime import UTC, datetime
9+
from pathlib import Path
910
from typing import Literal, TYPE_CHECKING
1011
from urllib import parse
1112

@@ -27,25 +28,7 @@
2728
THRESHOLD = 0.01
2829
MIN_MINUTES = 30
2930
BLOG_ABOUT_IT_THRESHOLD = 1000
30-
CORPORATE_FRIENDLY_SMILEYS = (
31-
":smile:",
32-
":slight_smile:",
33-
":grin:",
34-
":blush:",
35-
)
36-
MANAGEMENT_ONE_TO_ONE_COMMENTS = (
37-
"Well Clarice, have the lambs stopped screaming?",
38-
"I do wish we could chat longer, but... I'm having an old friend for dinner. Bye.",
39-
"What is your father, dear? Is he a coal miner?",
40-
"Senator, just one more thing: love your suit!",
41-
"Memory, Agent Starling, is what I have instead of a view.",
42-
"You still wake up sometimes, don't you? You wake up in the dark and hear the screaming of the lambs.",
43-
"People will say we're in love.",
44-
"All good things to those who wait.",
45-
'"Plum Island Animal Disease Research Center." Sounds charming.',
46-
"Ready when you are, Sergeant Pembry.",
47-
"A census taker once tried to test me.",
48-
)
31+
RESOURCE_PATH = Path(__file__).parent.parent.parent / "resources" / "systems"
4932

5033

5134
class URLConverter(Converter):
@@ -65,119 +48,20 @@ async def convert(self, _ctx: Context, argument: str) -> str | None:
6548
class SystemInformation(Cog):
6649
"""Utilities for fetching system information from our 9front infrastructure."""
6750

68-
SUPPORTIVE_PYTHON_DISCORD_COMMENTS = """\
69-
{Lemon|Bella|Chris} would {seriously|really|honestly} love to {have a word|discuss this topic} \
70-
with you! There {seems to be|is|appears to be|is assumed to be} a {tiny|minor|major|large} \
71-
{misunderstanding|miscommunication} here!|
72-
{Python|Erlang|Chris' exhaust} is peace. \
73-
{The DevOps team|Decentralized version control|The 2024 presidential election} is replication. \
74-
Your {message|comment|idea|thought} is strength.|
75-
Who controls {King Arthur The Terrible|Kubernetes|Netcup|Joe's medication} controls the future. \
76-
Who controls {Bella's rations|the dennis.services mail server|`git push -f` access|edit rights to this message} controls the past.|
77-
The best {messages|comments|ideas|chats}... are those that tell you what you know already.|
78-
If you want to keep {a secret|PGP private keys|Lemoncluster access|access to Joe's secret vacation photo library}, you must also hide it from {yourself|the moderators team|the ethical advisory board|Chris}.|
79-
{:warning:|:information_source:|:no_entry_sign:} Detected a high amount of doublethink in this message. \
80-
The {moderators have|administrators have|DevOps team has|Python Discord ethical advisory board has} been informed.|
81-
Reading your message, I realize: Perhaps a lunatic was simply a minority of one.|
82-
It's a beautiful thing, the destruction of words.|
83-
I enjoy talking to you. Your mind appeals to me. It resembles my own mind except that you happen to be {clinically |absolutely |completely |}insane.
84-
"""
85-
GREATEST_WSGI_SERVER_EVER_LOGLINES = (
86-
"[DANGER] async queue is full !!!",
87-
"[uwsgi-stats-pusher] goodbye...",
88-
"uWSGI mule %d braying: my master died, i will follow him...",
89-
"created farm %d name: %s mules:%s",
90-
"*** BOOOOOOM ***",
91-
"unable to setup the time bomb, goodbye",
92-
"Fire in the hole !!! (%d seconds to detonation)",
93-
"!!! uWSGI process %d got Segmentation Fault !!!",
94-
"!!! uWSGI process %d got Floating Point Exception !!!",
95-
"thunder lock: enabled (with robust mutex watchdog)",
96-
"...you should enable the master process... really...",
97-
"your mercy for graceful operations on workers is %d seconds",
98-
"your loop engine died. R.I.P.",
99-
"--- unable to connect to zerg server %s ---",
100-
"unknown farm: %s",
101-
"[spooler] something horrible happened to the spooler. Better to kill it.",
102-
'[uwsgi-route] ERROR "goto" instruction can only jump forward (check your label !!!)',
103-
"emperor socket mapped to: %s",
104-
"announcing my loyalty to the Emperor...",
105-
"uwsgi zerg socket %d attached to UNIX address %s fd %d",
106-
"attaching zerg sockets...",
107-
"zerg sockets attached",
108-
# chris lovering when his offshore accounts ("nodes") are sanctioned
109-
"[%s pid %d] no more nodes available. Going cheap...",
110-
'gateway "%s %d" has been buried (pid: %d)',
111-
"waiting for Emperor death...",
112-
"The Emperor has been buried (pid: %d)",
113-
"cheaper hard rss memory limit exceeded, cheap one of %d workers",
114-
# waiter! waiter! more uwsgi cheap workers please!
115-
"worker %d should die...",
116-
"overloaded !!!",
117-
"*** HARAKIRI ON WORKER %d (pid: %d, try: %d, graceful: %s) ***",
118-
"going cheap...",
119-
"lost connection with mules",
120-
"goodbye to uWSGI.",
121-
"chain next victim is worker %d",
122-
"*** HARAKIRI ON MULE %d (pid: %d) ***",
123-
"OOOPS the spooler is no more...trying respawn...",
124-
"!!! Emperor died !!!",
125-
# the vet office wants a word
126-
"OOOPS mule %d (pid: %d) crippled...trying respawn...",
127-
# ploen.social when the private key drive is missing
128-
"mountpoint %s failed, triggering detonation...",
129-
"asking Emperor for reinforcements (overload: %llu)...",
130-
"*** PAUSE (press start to resume, if you do not have a joypad send SIGTSTP) ***",
131-
# american worker rights be like
132-
"worker %d (pid: %d) is taking too much time to die...NO MERCY !!!",
133-
# american animal rights be like
134-
"mule %d (pid: %d) is taking too much time to die...NO MERCY !!!",
135-
"[broodlord] instance not governed by an Emperor !!!",
136-
"something horrible happened...",
137-
"mule %d (pid: %d) annihilated",
138-
"DAMN ! worker %d (pid: %d) died, killed by signal %d :( trying respawn ...",
139-
# amazon warehouse-related lines:
140-
"DAMN ! worker %d (pid: %d) MYSTERIOUSLY killed by signal %d :( trying respawn ...",
141-
"worker respawning too fast !!! i have to sleep a bit (%d seconds)...",
142-
"[emperor] unloyal bad behaving vassal found: %s throttling it...",
143-
"[emperor] *** RAGNAROK ALREADY EVOKED (mercyless in %d seconds)***",
144-
"[emperor] *** RAGNAROK EVOKED ***",
145-
"[emperor] curse the uwsgi instance %s (pid: %d)",
146-
"[emperor-tyrant] dropping privileges to %d %d for instance %s",
147-
"*** your Emperor will not be able to correctly wait() on vassals ***",
148-
"[emperor] vassal %s is now loyal",
149-
"[emperor] going in broodlord mode: launching zergs for %s",
150-
"--- MUTINY DETECTED !!! IMPALING VASSALS... ---",
151-
"received message %d from emperor",
152-
"lost connection with my emperor !!!",
153-
"i am an edge triggered socket !!!",
154-
"the gevent Hub is no more :(",
155-
'uwsgi-daemons] legion "%s" daemon "%s" (pid: %d) annihilated',
156-
"[uwsgi-rados] callback %llu woke up too late",
157-
"[DANGER] you have configured a too much tiny buffer for the scrolls list !!! tune it with --legion-scroll-list-max-size",
158-
"[uwsgi-legion] --- WE HAVE QUORUM FOR LEGION %s !!! (valor: %llu uuid: %.*s checksum: %llu votes: %d) ---",
159-
"[uwsgi-legion] attempting to become the Lord of the Legion %s",
160-
'[uwsgi-legion] suspending myself from Legion "%s" for %d seconds',
161-
"[uwsgi-legion] i am now the Lord of the Legion %s",
162-
"[uwsgi-legion] a new Lord (valor: %llu uuid: %.*s) raised for Legion %s...",
163-
"*********** The New Lord Scroll ***********",
164-
"[uwsgi-legion] ERROR, unlord hook returned: %d",
165-
"[uwsgi-legion] i cannot be The Lord of The Legion %s without a quorum ...",
166-
"!!!! Loading both PyPy and CPython in the same process IS PURE EVIL AND IT IS NOT SUPPORTED !!!",
167-
"invalid Web3 response.",
168-
"timeout while piping from %d to %d !!!",
169-
"[BUG] current_wsgi_req NOT FOUND !!!",
170-
"something horrible happened !!! check your spooler ASAP !!!",
171-
"uWSGI %s %d screams: UAAAAAAH my master disconnected: I will kill myself!!!",
172-
"F*CK !!! i must kill myself (pid: %d app_id: %d)...",
173-
)
174-
17551
def __init__(self, bot: KingArthurTheTerrible) -> None:
17652
self.bot = bot
17753
self.cached_resources = {}
17854
self.cached_blogcom = None
17955
self.cached_bullshit = None
18056
self.last_sent = None
57+
58+
self.smileys = RESOURCE_PATH.joinpath("smileys.txt").read_text().splitlines()
59+
self.management_comments = (
60+
RESOURCE_PATH.joinpath("management_comments.txt").read_text().splitlines()
61+
)
62+
self.supportive_comments = RESOURCE_PATH.joinpath("supportive_comments.txt").read_text()
63+
self.uwsgi_loglines = RESOURCE_PATH.joinpath("uwsgi_loglines.txt").read_text().splitlines()
64+
18165
self.conduct_one_to_ones.start()
18266

18367
async def fetch_resource(self, name: str) -> str:
@@ -218,7 +102,7 @@ async def conduct_one_to_ones(self) -> None:
218102
sys.exit(1)
219103

220104
selected_member = random.choice(role.members + [mr_hemlock])
221-
selected_management_comment = random.choice(MANAGEMENT_ONE_TO_ONE_COMMENTS)
105+
selected_management_comment = random.choice(self.management_comments)
222106

223107
await selected_member.send(selected_management_comment)
224108
logger.info("Inspirational management tactic applied to {member}", member=selected_member)
@@ -258,14 +142,14 @@ async def on_message(self, msg: Message) -> None:
258142
if random.random() < 0.9:
259143
blogcom = await self.fetch_resource("lib/blogcom")
260144
else:
261-
blogcom = self.SUPPORTIVE_PYTHON_DISCORD_COMMENTS
145+
blogcom = self.supportive_comments
262146

263147
comment = lib9front.generate_blog_comment(blogcom).strip()
264148

265149
self.last_sent = datetime.now(tz=UTC)
266150
async with msg.channel.typing():
267151
await asyncio.sleep(3)
268-
await msg.reply(f"{comment} {random.choice(CORPORATE_FRIENDLY_SMILEYS)}")
152+
await msg.reply(f"{comment} {random.choice(self.smileys)}")
269153

270154
@command(name="software")
271155
async def software(self, ctx: Context) -> None:
@@ -349,7 +233,7 @@ async def motd(self, ctx: Context) -> None:
349233
@command(name="uwsgi")
350234
async def uwsgi(self, ctx: Context) -> None:
351235
"""Return a log line suitable for industry standard WSGI servers."""
352-
message = random.choice(self.GREATEST_WSGI_SERVER_EVER_LOGLINES)
236+
message = random.choice(self.uwsgi_loglines)
353237
await ctx.reply(f"``{message}``")
354238

355239

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Well Clarice, have the lambs stopped screaming?
2+
I do wish we could chat longer, but... I'm having an old friend for dinner. Bye.
3+
What is your father, dear? Is he a coal miner?
4+
Senator, just one more thing: love your suit!
5+
Memory, Agent Starling, is what I have instead of a view.
6+
You still wake up sometimes, don't you? You wake up in the dark and hear the screaming of the lambs.
7+
People will say we're in love.
8+
All good things to those who wait.
9+
"Plum Island Animal Disease Research Center." Sounds charming.
10+
Ready when you are, Sergeant Pembry.
11+
A census taker once tried to test me.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:smile:
2+
:slight_smile:
3+
:grin:
4+
:blush:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{Lemon|Bella|Chris} would {seriously|really|honestly} love to {have a word|discuss this topic} with you! There {seems to be|is|appears to be|is assumed to be} a {tiny|minor|major|large} {misunderstanding|miscommunication} here!|
2+
{Python|Erlang|Chris' exhaust} is peace. {The DevOps team|Decentralized version control|The 2024 presidential election} is replication. Your {message|comment|idea|thought} is strength.|
3+
Who controls {King Arthur The Terrible|Kubernetes|Netcup|Joe's medication} controls the future. Who controls {Bella's rations|the dennis.services mail server|`git push -f` access|edit rights to this message} controls the past.|
4+
The best {messages|comments|ideas|chats}... are those that tell you what you know already.|
5+
If you want to keep {a secret|PGP private keys|Lemoncluster access|access to Joe's secret vacation photo library}, you must also hide it from {yourself|the moderators team|the ethical advisory board|Chris}.|
6+
{:warning:|:information_source:|:no_entry_sign:} Detected a high amount of doublethink in this message. The {moderators have|administrators have|DevOps team has|Python Discord ethical advisory board has} been informed.|
7+
Reading your message, I realize: Perhaps a lunatic was simply a minority of one.|
8+
It's a beautiful thing, the destruction of words.|
9+
I enjoy talking to you. Your mind appeals to me. It resembles my own mind except that you happen to be {clinically |absolutely |completely |}insane.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[DANGER] async queue is full !!!
2+
[uwsgi-stats-pusher] goodbye...
3+
uWSGI mule %d braying: my master died, i will follow him...
4+
created farm %d name: %s mules:%s
5+
*** BOOOOOOM ***
6+
unable to setup the time bomb, goodbye
7+
Fire in the hole !!! (%d seconds to detonation)
8+
!!! uWSGI process %d got Segmentation Fault !!!
9+
!!! uWSGI process %d got Floating Point Exception !!!
10+
thunder lock: enabled (with robust mutex watchdog)
11+
...you should enable the master process... really...
12+
your mercy for graceful operations on workers is %d seconds
13+
your loop engine died. R.I.P.
14+
--- unable to connect to zerg server %s ---
15+
unknown farm: %s
16+
[spooler] something horrible happened to the spooler. Better to kill it.
17+
[uwsgi-route] ERROR "goto" instruction can only jump forward (check your label !!!)
18+
emperor socket mapped to: %s
19+
announcing my loyalty to the Emperor...
20+
uwsgi zerg socket %d attached to UNIX address %s fd %d
21+
attaching zerg sockets...
22+
zerg sockets attached
23+
[%s pid %d] no more nodes available. Going cheap...
24+
gateway "%s %d" has been buried (pid: %d)
25+
waiting for Emperor death...
26+
The Emperor has been buried (pid: %d)
27+
cheaper hard rss memory limit exceeded, cheap one of %d workers
28+
worker %d should die...
29+
overloaded !!!
30+
*** HARAKIRI ON WORKER %d (pid: %d, try: %d, graceful: %s) ***
31+
going cheap...
32+
lost connection with mules
33+
goodbye to uWSGI.
34+
chain next victim is worker %d
35+
*** HARAKIRI ON MULE %d (pid: %d) ***
36+
OOOPS the spooler is no more...trying respawn...
37+
!!! Emperor died !!!
38+
OOOPS mule %d (pid: %d) crippled...trying respawn...
39+
mountpoint %s failed, triggering detonation...
40+
asking Emperor for reinforcements (overload: %llu)...
41+
*** PAUSE (press start to resume, if you do not have a joypad send SIGTSTP) ***
42+
worker %d (pid: %d) is taking too much time to die...NO MERCY !!!
43+
mule %d (pid: %d) is taking too much time to die...NO MERCY !!!
44+
[broodlord] instance not governed by an Emperor !!!
45+
something horrible happened...
46+
mule %d (pid: %d) annihilated
47+
DAMN ! worker %d (pid: %d) died, killed by signal %d :( trying respawn ...
48+
DAMN ! worker %d (pid: %d) MYSTERIOUSLY killed by signal %d :( trying respawn ...
49+
worker respawning too fast !!! i have to sleep a bit (%d seconds)...
50+
[emperor] unloyal bad behaving vassal found: %s throttling it...
51+
[emperor] *** RAGNAROK ALREADY EVOKED (mercyless in %d seconds)***
52+
[emperor] *** RAGNAROK EVOKED ***
53+
[emperor] curse the uwsgi instance %s (pid: %d)
54+
[emperor-tyrant] dropping privileges to %d %d for instance %s
55+
*** your Emperor will not be able to correctly wait() on vassals ***
56+
[emperor] vassal %s is now loyal
57+
[emperor] going in broodlord mode: launching zergs for %s
58+
--- MUTINY DETECTED !!! IMPALING VASSALS... ---
59+
received message %d from emperor
60+
lost connection with my emperor !!!
61+
i am an edge triggered socket !!!
62+
the gevent Hub is no more :(
63+
uwsgi-daemons] legion "%s" daemon "%s" (pid: %d) annihilated
64+
[uwsgi-rados] callback %llu woke up too late
65+
[DANGER] you have configured a too much tiny buffer for the scrolls list !!! tune it with --legion-scroll-list-max-size
66+
[uwsgi-legion] --- WE HAVE QUORUM FOR LEGION %s !!! (valor: %llu uuid: %.*s checksum: %llu votes: %d) ---
67+
[uwsgi-legion] attempting to become the Lord of the Legion %s
68+
[uwsgi-legion] suspending myself from Legion "%s" for %d seconds
69+
[uwsgi-legion] i am now the Lord of the Legion %s
70+
[uwsgi-legion] a new Lord (valor: %llu uuid: %.*s) raised for Legion %s...
71+
*********** The New Lord Scroll ***********
72+
[uwsgi-legion] ERROR, unlord hook returned: %d
73+
[uwsgi-legion] i cannot be The Lord of The Legion %s without a quorum ...
74+
!!!! Loading both PyPy and CPython in the same process IS PURE EVIL AND IT IS NOT SUPPORTED !!!
75+
invalid Web3 response.
76+
timeout while piping from %d to %d !!!
77+
[BUG] current_wsgi_req NOT FOUND !!!
78+
something horrible happened !!! check your spooler ASAP !!!
79+
uWSGI %s %d screams: UAAAAAAH my master disconnected: I will kill myself!!!
80+
F*CK !!! i must kill myself (pid: %d app_id: %d)...

0 commit comments

Comments
 (0)