malware/main.py
2026-04-05 02:07:36 +02:00

77 lines
2.3 KiB
Python

from datetime import datetime
import simplematrixbotlib as matrix
from dotenv import dotenv_values
import dice
import misc
DOTENV = dotenv_values(".env")
PREFIX = "!"
config = matrix.Config()
config.encryption_enabled = True
config.emoji_verify = True
config.ignore_unverified_devices = True
creds = matrix.Creds(
DOTENV["MATRIX_SERVER"], DOTENV["BOT_USERNAME"], DOTENV["BOT_PASSWORD"]
)
bot = matrix.bot.Bot(creds, config)
bot.start_time = datetime.now()
@bot.listener.on_message_event
async def ping(room, message):
mtch = matrix.match.MessageMatch(room, message, bot, PREFIX)
if mtch.is_not_from_this_bot and mtch.prefix and mtch.command("ping"):
try:
await misc.ping(bot, mtch, room, message)
except Exception as e:
await bot.api.send_text_message(
room.room_id, f"Unexpected error: {e}", reply_to=message.event_id
)
@bot.listener.on_message_event
async def echo(room, message):
mtch = matrix.match.MessageMatch(room, message, bot, PREFIX)
if mtch.is_not_from_this_bot and mtch.prefix and mtch.command("echo"):
try:
await misc.echo(bot, mtch, room, message)
except Exception as e:
await bot.api.send_text_message(
room.room_id, f"Unexpected error: {e}", reply_to=message.event_id
)
@bot.listener.on_message_event
async def uptime(room, message):
mtch = matrix.match.MessageMatch(room, message, bot, PREFIX)
if mtch.is_not_from_this_bot and mtch.prefix and mtch.command("uptime"):
try:
await misc.uptime(bot, mtch, room, message)
except Exception as e:
await bot.api.send_text_message(
room.room_id, f"Unexpected error: {e}", reply_to=message.event_id
)
@bot.listener.on_message_event
async def roll(room, message):
mtch = matrix.match.MessageMatch(room, message, bot, PREFIX)
if (
mtch.is_not_from_this_bot
and mtch.prefix
and (mtch.command("roll") or mtch.command("r"))
):
try:
await dice.roll(bot, mtch, room, message)
except Exception as e:
await bot.api.send_text_message(
room.room_id, f"Unexpected error: {e}", reply_to=message.event_id
)
bot.run()