2023-04-24 08:48:59 +00:00
|
|
|
from nio.events.room_events import RoomMessageText
|
|
|
|
from nio.rooms import MatrixRoom
|
|
|
|
|
|
|
|
|
2023-04-25 11:25:53 +00:00
|
|
|
async def command_systemmessage(room: MatrixRoom, event: RoomMessageText, bot):
|
2023-04-24 08:48:59 +00:00
|
|
|
system_message = " ".join(event.body.split()[2:])
|
|
|
|
|
|
|
|
if system_message:
|
2023-04-25 11:25:53 +00:00
|
|
|
bot.logger.log("Adding system message...")
|
2023-04-24 08:48:59 +00:00
|
|
|
|
2023-04-25 11:25:53 +00:00
|
|
|
with bot.database.cursor() as cur:
|
2023-04-24 08:48:59 +00:00
|
|
|
cur.execute(
|
|
|
|
"INSERT INTO system_messages (room_id, message_id, user_id, body, timestamp) VALUES (?, ?, ?, ?, ?)",
|
|
|
|
(room.room_id, event.event_id, event.sender,
|
|
|
|
system_message, event.server_timestamp)
|
|
|
|
)
|
|
|
|
|
2023-05-01 06:11:43 +00:00
|
|
|
await bot.send_message(room, f"Alright, I've stored the system message: '{system_message}'.", True)
|
2023-04-25 11:25:53 +00:00
|
|
|
return
|
2023-04-24 08:48:59 +00:00
|
|
|
|
2023-04-25 11:25:53 +00:00
|
|
|
bot.logger.log("Retrieving system message...")
|
2023-04-24 08:48:59 +00:00
|
|
|
|
2023-04-25 11:25:53 +00:00
|
|
|
system_message = bot.get_system_message(room)
|
2023-04-24 08:48:59 +00:00
|
|
|
|
2023-04-25 11:25:53 +00:00
|
|
|
bot.send_message(room, f"The current system message is: '{system_message}'.", True)
|