1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 11:34:18 +00:00
royalnet/royalpack/commands/rage.py

46 lines
1.1 KiB
Python
Raw Normal View History

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-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, **__):
"""
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-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-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, **__):
"""
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-14 02:12:54 +00:00
count = _session.execute(
s.select(s.func.count()).select_from(s.select(Rage).subquery())
).scalar()
2021-04-14 02:12:54 +00:00
await _msg.reply(text=f"😡 G{'R' * count}!")
__all__ = (
"rage_show",
"rage_add",
)