2021-04-06 01:58:55 +00:00
|
|
|
import royalnet.engineer as engi
|
|
|
|
from ..database.tables import Rage
|
|
|
|
import sqlalchemy as s
|
2021-04-14 02:12:54 +00:00
|
|
|
import sqlalchemy.orm as so
|
2021-04-06 01:58:55 +00:00
|
|
|
|
|
|
|
|
2021-04-17 02:19:11 +00:00
|
|
|
@engi.TeleportingConversation
|
2021-04-14 02:12:54 +00:00
|
|
|
async def rage_show(*, _sentry: engi.Sentry, _msg: engi.Message, _session: so.Session, **__):
|
2021-04-06 01:58:55 +00:00
|
|
|
"""
|
|
|
|
A-N-G-E-R-Y!
|
|
|
|
Invia in chat qualcosa che ha fatto arrabbiare un membro anonimo della RYG.
|
|
|
|
"""
|
|
|
|
|
2021-04-14 02:12:54 +00:00
|
|
|
rage = _session.execute(
|
|
|
|
s.select(Rage).order_by(s.func.random())
|
|
|
|
).scalar()
|
2021-04-06 01:58:55 +00:00
|
|
|
|
2021-04-14 02:12:54 +00:00
|
|
|
if rage is None:
|
|
|
|
await _msg.reply(text=f"😐 Alla fine, non è che sei così arrabbiato...")
|
|
|
|
else:
|
|
|
|
await _msg.reply(text=f"😡 {rage.reason}")
|
2021-04-06 01:58:55 +00:00
|
|
|
|
|
|
|
|
2021-04-17 02:19:11 +00:00
|
|
|
@engi.TeleportingConversation
|
2021-04-14 02:12:54 +00:00
|
|
|
async def rage_add(*, _sentry: engi.Sentry, _msg: engi.Message, _session: so.Session, reason: str, **__):
|
2021-04-06 01:58:55 +00:00
|
|
|
"""
|
|
|
|
A-N-G-E-R-Y!
|
|
|
|
Aggiungi al database qualcosa che ti ha fatto arrabbiare tantissimo.
|
|
|
|
"""
|
|
|
|
|
2021-04-14 02:12:54 +00:00
|
|
|
rage = Rage(reason=reason)
|
|
|
|
_session.add(rage)
|
|
|
|
_session.commit()
|
2021-04-06 01:58:55 +00:00
|
|
|
|
2021-04-14 02:12:54 +00:00
|
|
|
count = _session.execute(
|
|
|
|
s.select(s.func.count()).select_from(s.select(Rage).subquery())
|
|
|
|
).scalar()
|
2021-04-06 01:58:55 +00:00
|
|
|
|
2021-04-14 02:12:54 +00:00
|
|
|
await _msg.reply(text=f"😡 G{'R' * count}!")
|
2021-04-06 01:58:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
__all__ = (
|
|
|
|
"rage_show",
|
|
|
|
"rage_add",
|
|
|
|
)
|