Skip to content

Commit 86f8b9d

Browse files
committed
feat(admin): add /joder command for ROZEN to send messages to main group
1 parent cfbc267 commit 86f8b9d

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

bot_logic.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
from utils.orga2Utils import noitip, asm
22
from handlers.basic import start, help_command, estasvivo, colaborar
33
from handlers.info import campusvivo, flan, flanviejo, aulas, cuandovence, listarlabos
4-
from handlers.admin import checodepers, checodeppers, sugerirNoticia, get_logs
4+
from handlers.admin import checodepers, checodeppers, sugerirNoticia, get_logs, joder
55
from handlers.groups import listar, listaroptativa, listareci, listarotro, cubawiki, agregargrupo, agregaroptativa, agregarotros, agregareci, sugerirgrupo, sugeriroptativa, sugerireci, sugerirotro, actualizar_grupos, _update_groups
66
from handlers.callbacks import button
77
from handlers.crons import felizdia, actualizarRiver
88

99
COMMANDS = {
10+
'joder': {
11+
'handler': joder,
12+
'description': '(Admin) Enviar un mensaje al grupo general'
13+
},
1014
'logs': {
1115
'handler': get_logs,
1216
'description': '(Admin) Revisa los últimos 10 errores en GCP.'

handlers/admin.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,31 @@
33
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
44
from telegram.ext import ContextTypes
55
from telegram.constants import ParseMode
6-
from tg_ids import CODEPERS_CHATID, ROZEN_CHATID, DGARRO_CHATID
6+
from tg_ids import CODEPERS_CHATID, ROZEN_CHATID, DGARRO_CHATID, DC_GROUP_CHATID
77
from models import Noticia
88
from handlers.db import get_session
99

1010
logger = logging.getLogger("DCUBABOT")
1111
admin_ids = [ROZEN_CHATID, DGARRO_CHATID]
1212

13+
async def joder(update: Update, context: ContextTypes.DEFAULT_TYPE):
14+
user_id = update.effective_user.id
15+
if user_id != ROZEN_CHATID and str(user_id) != str(ROZEN_CHATID):
16+
logger.warning(f"Unauthorized user {user_id} tried to access /joder")
17+
return
18+
19+
if not context.args:
20+
await update.message.reply_text("Uso: /joder <mensaje>")
21+
return
22+
23+
message = " ".join(context.args)
24+
try:
25+
await context.bot.send_message(chat_id=DC_GROUP_CHATID, text=message)
26+
await update.message.reply_text("Mensaje enviado exitosamente al grupo general.")
27+
except Exception as e:
28+
logger.error(f"Failed to send joder message: {e}")
29+
await update.message.reply_text(f"Error al enviar el mensaje: {e}")
30+
1331
async def checodepers(update: Update, context: ContextTypes.DEFAULT_TYPE):
1432
if not context.args:
1533
ejemplo = """ Ejemplo de uso:

0 commit comments

Comments
 (0)