[REPO REFACTOR]: changed to a better git repository structure with branches
This commit is contained in:
0
commands/admin.py
Normal file
0
commands/admin.py
Normal file
41
commands/help.py
Normal file
41
commands/help.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.ext import ContextTypes, Application, CommandHandler, CallbackQueryHandler
|
||||
from settings import VARIOS, INTERACCION, MATEMATICAS
|
||||
from util.messages import delete_user_message
|
||||
|
||||
PAGES = [VARIOS, INTERACCION, MATEMATICAS]
|
||||
ITEMS_PER_PAGE = 1
|
||||
|
||||
class Help:
|
||||
def __init__(self, app: Application):
|
||||
self.app = app
|
||||
app.add_handler(CommandHandler("help", self.help))
|
||||
app.add_handler(CallbackQueryHandler(self.callback, pattern="^help_"))
|
||||
|
||||
@delete_user_message
|
||||
async def help(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
await self.send_help(update, page=0)
|
||||
|
||||
async def send_help(self, update: Update, page: int):
|
||||
start_idx = page * ITEMS_PER_PAGE
|
||||
end_idx = start_idx + ITEMS_PER_PAGE
|
||||
text = "\n".join(PAGES[start_idx:end_idx])
|
||||
|
||||
keyboard = []
|
||||
if page > 0:
|
||||
keyboard.append(InlineKeyboardButton("⬅️ Anterior", callback_data=f"help_{page-1}"))
|
||||
if end_idx < len(PAGES):
|
||||
keyboard.append(InlineKeyboardButton("➡️ Siguiente", callback_data=f"help_{page+1}"))
|
||||
|
||||
reply_markup = InlineKeyboardMarkup([keyboard]) if keyboard else None
|
||||
|
||||
if update.message:
|
||||
await update.message.reply_text(f"**Ayuda {page+1}/{(len(PAGES)-1)//ITEMS_PER_PAGE + 1}**\n\n{text}", parse_mode="Markdown", reply_markup=reply_markup)
|
||||
elif update.callback_query:
|
||||
await update.callback_query.edit_message_text(f"**Ayuda {page+1}/{(len(PAGES)-1)//ITEMS_PER_PAGE + 1}**\n\n{text}", parse_mode="Markdown", reply_markup=reply_markup)
|
||||
await update.callback_query.answer()
|
||||
|
||||
async def callback(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
query = update.callback_query
|
||||
page = int(query.data.split("_")[1])
|
||||
await self.send_help(update, page=page)
|
||||
553
commands/interaction.py
Normal file
553
commands/interaction.py
Normal file
@@ -0,0 +1,553 @@
|
||||
from telegram import Update
|
||||
from telegram.ext import ContextTypes, Application, CommandHandler
|
||||
from time import time
|
||||
from settings import BOT_OWNER, BOT_NAME, BOT_VERSION, BOT_LANG, BOT_TYPE, BOT_OWNER_ID
|
||||
from random import randint, choice
|
||||
from util.messages import delete_user_message
|
||||
from util.anime import Anime
|
||||
|
||||
class Interaction:
|
||||
def __init__(self, app: Application):
|
||||
self.app = app
|
||||
self.anime = Anime()
|
||||
|
||||
app.add_handler(CommandHandler("waifu", self.waifu))
|
||||
app.add_handler(CommandHandler("neko", self.neko))
|
||||
app.add_handler(CommandHandler("shinobu", self.shinobu))
|
||||
app.add_handler(CommandHandler("megumin", self.megumin))
|
||||
app.add_handler(CommandHandler("bully", self.bully))
|
||||
app.add_handler(CommandHandler("cuddle", self.cuddle))
|
||||
app.add_handler(CommandHandler("cry", self.cry))
|
||||
app.add_handler(CommandHandler("hug", self.hug))
|
||||
app.add_handler(CommandHandler("awoo", self.awoo))
|
||||
app.add_handler(CommandHandler("kiss", self.kiss))
|
||||
app.add_handler(CommandHandler("lick", self.lick))
|
||||
app.add_handler(CommandHandler("pat", self.pat))
|
||||
app.add_handler(CommandHandler("smug", self.smug))
|
||||
app.add_handler(CommandHandler("bonk", self.bonk))
|
||||
app.add_handler(CommandHandler("yeet", self.yeet))
|
||||
app.add_handler(CommandHandler("blush", self.blush))
|
||||
app.add_handler(CommandHandler("smile", self.smile))
|
||||
app.add_handler(CommandHandler("wave", self.wave))
|
||||
app.add_handler(CommandHandler("highfive", self.highfive))
|
||||
app.add_handler(CommandHandler("handhold", self.handhold))
|
||||
app.add_handler(CommandHandler("nom", self.nom))
|
||||
app.add_handler(CommandHandler("bite", self.bite))
|
||||
app.add_handler(CommandHandler("glomp", self.glomp))
|
||||
app.add_handler(CommandHandler("slap", self.slap))
|
||||
app.add_handler(CommandHandler("kill", self.kill))
|
||||
app.add_handler(CommandHandler("kick", self.kick))
|
||||
app.add_handler(CommandHandler("happy", self.happy))
|
||||
app.add_handler(CommandHandler("wink", self.wink))
|
||||
app.add_handler(CommandHandler("poke", self.poke))
|
||||
app.add_handler(CommandHandler("dance", self.dance))
|
||||
app.add_handler(CommandHandler("cringe", self.cringe))
|
||||
app.add_handler(CommandHandler("run", self.run))
|
||||
app.add_handler(CommandHandler("fbi", self.fbi))
|
||||
app.add_handler(CommandHandler("spank", self.spank))
|
||||
app.add_handler(CommandHandler("ship", self.ship))
|
||||
app.add_handler(CommandHandler("moan", self.moan))
|
||||
app.add_handler(CommandHandler("femboize", self.femboize))
|
||||
|
||||
@delete_user_message
|
||||
async def waifu(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("waifu")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha pedido una waifu"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def neko(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("neko")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha pedido un neko"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def shinobu(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("shinobu")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha pedido una shinobu"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def megumin(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("megumin")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha pedido una megumin"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def bully(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("bully")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} le ha hecho bullying a {user}"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def cuddle(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("cuddle")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} se ha acurrucado con {user} uwu"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def cry(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("cry")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} se ha puesto a llorar :("
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def hug(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("hug")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha abrazado a {user}"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def awoo(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("awoo")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} es un puto furro y ha pedido una foto de un furro"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def kiss(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("kiss")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha besado a {user} >///<"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def lick(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("lick")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha lamido a {user} OwO"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def pat(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("pat")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha acariciado a {user} >.<"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def smug(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("smug")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} se ha chuleado de {user}"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def bonk(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("bonk")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} le ha hecho bonk a {user}"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def yeet(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("yeet")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha lanzado a {user} a chuparla XD"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def blush(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("blush")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} se ha sonrojado >///<"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def smile(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("smile")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha sonreido"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def wave(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("wave")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha saludado a {user}"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def highfive(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("highfive")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} a chocado a {user} ;D"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def handhold(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("handhold")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} le ha cogido la manita a {user} u.u"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def nom(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("nom")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} se ha puesto a comer algo rico"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def bite(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("bite")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha mordido a {user} ùwú"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def glomp(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("glomp")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} se ha abalanzado sobre {user}"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def slap(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("slap")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} le ha dado una bofetada a {user}"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def kill(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("kill")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} ha matado a {user} 💀"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def kick(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("kick")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} le ha pegado una patada a {user}"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def happy(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("happy")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} está feliz :D"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def wink(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("wink")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} le ha guiñado el ojo a {user} ;)"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def poke(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
url = self.anime.sfw("poke")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} está molestando a {user} ù.ú"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def dance(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
url = self.anime.sfw("dance")
|
||||
await update.effective_chat.send_animation(
|
||||
animation=url,
|
||||
caption=f"{update.effective_sender.first_name} se ha puesto a bailar"
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def cringe(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
caption=f"{update.effective_sender.first_name} le ha dado cringe lo que ha dicho {user}"
|
||||
with open("data/images/interaction/cringe.gif", "rb") as gif:
|
||||
await update.effective_chat.send_animation(
|
||||
animation=gif,
|
||||
caption=caption,
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
|
||||
@delete_user_message
|
||||
async def run(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
caption = f"{update.effective_sender.first_name} ha huido"
|
||||
with open("data/images/interaction/run.gif", "rb") as gif:
|
||||
await update.effective_chat.send_animation(
|
||||
animation=gif,
|
||||
caption=caption,
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def fbi(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
caption = f"{update.effective_sender.first_name} ha llamado al FBI! Corre {user}!!!!"
|
||||
with open("data/images/interaction/fbi.gif", "rb") as gif:
|
||||
await update.effective_chat.send_animation(
|
||||
animation=gif,
|
||||
caption=caption,
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def spank(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
caption = f"{update.effective_sender.first_name} le ha dado una nalgada a {user}"
|
||||
with open("data/images/interaction/spank.gif", "rb") as gif:
|
||||
await update.effective_chat.send_animation(
|
||||
animation=gif,
|
||||
caption=caption,
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def ship(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar dos usuarios"
|
||||
)
|
||||
return
|
||||
|
||||
user1 = context.args[0]
|
||||
user2 = context.args[1]
|
||||
caption = f"{user1} x {user2} tienen una compatibilidad del {randint(0,100)}%"
|
||||
with open("data/images/interaction/ship.gif", "rb") as gif:
|
||||
await update.effective_chat.send_animation(
|
||||
animation=gif,
|
||||
caption=caption,
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def moan(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
caption = f"{update.effective_sender.first_name} ha gemido como una perra"
|
||||
with open("data/images/interaction/moan.gif", "rb") as gif:
|
||||
await update.effective_chat.send_animation(
|
||||
animation=gif,
|
||||
caption=caption,
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def femboize(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Debes especificar un usuario"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
user = context.args[0]
|
||||
caption = f"{update.effective_sender.first_name} ha convertido en femboy a {user}"
|
||||
with open("data/images/interaction/femboy.png", "rb") as png:
|
||||
await update.effective_chat.send_photo(
|
||||
photo=png,
|
||||
caption=caption,
|
||||
disable_notification=True
|
||||
)
|
||||
175
commands/math.py
Normal file
175
commands/math.py
Normal file
@@ -0,0 +1,175 @@
|
||||
from telegram import Update
|
||||
from telegram.ext import ContextTypes, Application, CommandHandler
|
||||
from random import randint, choice
|
||||
from util.messages import delete_user_message
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from util.numbers import is_even, is_prime
|
||||
from settings import GRAPH_PATH
|
||||
from matplotlib.patches import Circle
|
||||
|
||||
class Math:
|
||||
def __init__(self, app: Application):
|
||||
self.app = app
|
||||
app.add_handler(CommandHandler("calcular", self.calculate))
|
||||
app.add_handler(CommandHandler("par", self.even))
|
||||
app.add_handler(CommandHandler("primo", self.prime))
|
||||
app.add_handler(CommandHandler("seno", self.sine))
|
||||
app.add_handler(CommandHandler("coseno", self.cosine))
|
||||
app.add_handler(CommandHandler("recta", self.rect))
|
||||
app.add_handler(CommandHandler("parabola", self.parable))
|
||||
app.add_handler(CommandHandler("circunferencia", self.circle))
|
||||
app.add_handler(CommandHandler("log", self.log))
|
||||
app.add_handler(CommandHandler("exp", self.exp))
|
||||
|
||||
@delete_user_message
|
||||
async def calculate(self, update:Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text="Debes especificar una expresión matemática",
|
||||
disable_notification=True
|
||||
)
|
||||
return
|
||||
|
||||
expression = " ".join(context.args)
|
||||
try:
|
||||
result = eval(expression)
|
||||
await update.effective_chat.send_message(
|
||||
text=f"El resultado de {expression} es {result}",
|
||||
disable_notification=True
|
||||
)
|
||||
except Exception as e:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"Error al calcular la expresión: {e}",
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def even(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text="Debes especificar un número",
|
||||
disable_notification=True
|
||||
)
|
||||
return
|
||||
|
||||
number = int(context.args[0])
|
||||
await update.effective_chat.send_message(
|
||||
text=f"{number} es un número par." if is_even(number) else f"{number} es un número impar.",
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def prime(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text="Debes especificar un número",
|
||||
disable_notification=True
|
||||
)
|
||||
return
|
||||
|
||||
number = int(context.args[0])
|
||||
await update.effective_chat.send_message(
|
||||
text=f"{number} es un número primo." if is_prime(number) else f"{number} es un número compuesto.",
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
async def send_graph(self, update: Update):
|
||||
await update.effective_chat.send_photo(open(GRAPH_PATH, "rb"))
|
||||
plt.clf()
|
||||
|
||||
@delete_user_message
|
||||
async def sine(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
if len(context.args) < 2:
|
||||
await update.effective_chat.send_message("Debes dar a y k: /grafseno a k")
|
||||
return
|
||||
a, k = map(int, context.args[:2])
|
||||
x = np.linspace(0, 2*np.pi, 400)
|
||||
y = a * np.sin(k*x)
|
||||
plt.axhline(0, color="black")
|
||||
plt.plot(x, y, color="#b2122f")
|
||||
plt.savefig(GRAPH_PATH)
|
||||
await self.send_graph(update)
|
||||
|
||||
@delete_user_message
|
||||
async def cosine(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
if len(context.args) < 2:
|
||||
await update.effective_chat.send_message("Debes dar a y k: /grafcoseno a k")
|
||||
return
|
||||
a, k = map(int, context.args[:2])
|
||||
x = np.linspace(0, 2*np.pi, 400)
|
||||
y = a * np.cos(k*x)
|
||||
plt.axhline(0, color="black")
|
||||
plt.plot(x, y, color="#b2122f")
|
||||
plt.savefig(GRAPH_PATH)
|
||||
await self.send_graph(update)
|
||||
|
||||
@delete_user_message
|
||||
async def rect(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
if len(context.args) < 2:
|
||||
await update.effective_chat.send_message("Debes dar m y n: /grafrecta m n")
|
||||
return
|
||||
m, n = map(int, context.args[:2])
|
||||
x = np.linspace(-10, 10, 400)
|
||||
y = m*x + n
|
||||
plt.axhline(0, color="black")
|
||||
plt.axvline(0, color="black")
|
||||
plt.plot(x, y, color="#b2122f")
|
||||
plt.savefig(GRAPH_PATH)
|
||||
await self.send_graph(update)
|
||||
|
||||
@delete_user_message
|
||||
async def parable(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
if len(context.args) < 3:
|
||||
await update.effective_chat.send_message("Debes dar a, b, c: /grafparabola a b c")
|
||||
return
|
||||
a, b, c = map(int, context.args[:3])
|
||||
x = np.linspace(-10, 10, 400)
|
||||
y = a*x**2 + b*x + c
|
||||
plt.axhline(0, color="black")
|
||||
plt.axvline(0, color="black")
|
||||
plt.plot(x, y, color="#b2122f")
|
||||
plt.savefig(GRAPH_PATH)
|
||||
await self.send_graph(update)
|
||||
|
||||
@delete_user_message
|
||||
async def circle(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message("Debes dar el radio: /grafcircunferencia r")
|
||||
return
|
||||
r = int(context.args[0])
|
||||
fig, ax = plt.subplots()
|
||||
ax.set_aspect('equal')
|
||||
ax.add_artist(Circle((0, 0), r, color='r'))
|
||||
plt.xlim(-10, 10)
|
||||
plt.ylim(-10, 10)
|
||||
plt.savefig(GRAPH_PATH)
|
||||
await self.send_graph(update)
|
||||
|
||||
@delete_user_message
|
||||
async def log(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
if len(context.args) < 2:
|
||||
await update.effective_chat.send_message("Debes dar a y b: /graflog a b")
|
||||
return
|
||||
a, b = map(int, context.args[:2])
|
||||
x = np.linspace(0.01, 10, 400)
|
||||
y = a*np.log(x) + b
|
||||
plt.axhline(0, color="black")
|
||||
plt.axvline(0, color="black")
|
||||
plt.plot(x, y, color="#b2122f")
|
||||
plt.savefig(GRAPH_PATH)
|
||||
await self.send_graph(update)
|
||||
|
||||
@delete_user_message
|
||||
async def exp(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
if len(context.args) < 2:
|
||||
await update.effective_chat.send_message("Debes dar a y b: /grafexp a b")
|
||||
return
|
||||
a, b = map(int, context.args[:2])
|
||||
x = np.linspace(-10, 10, 400)
|
||||
y = a*np.exp(b*x)
|
||||
plt.axhline(0, color="black")
|
||||
plt.axvline(0, color="black")
|
||||
plt.plot(x, y, color="#b2122f")
|
||||
plt.savefig(GRAPH_PATH)
|
||||
await self.send_graph(update)
|
||||
162
commands/misc.py
Normal file
162
commands/misc.py
Normal file
@@ -0,0 +1,162 @@
|
||||
from telegram import Update
|
||||
from telegram.ext import ContextTypes, Application, CommandHandler
|
||||
from time import time
|
||||
from settings import BOT_OWNER, BOT_NAME, BOT_VERSION, BOT_LANG, BOT_TYPE, BOT_OWNER_ID
|
||||
from random import randint, choice
|
||||
from util.messages import delete_user_message
|
||||
|
||||
class Misc:
|
||||
def __init__(self, app: Application):
|
||||
self.app = app
|
||||
app.add_handler(CommandHandler("ping", self.ping))
|
||||
app.add_handler(CommandHandler("info", self.info))
|
||||
app.add_handler(CommandHandler("say", self.say))
|
||||
app.add_handler(CommandHandler("banana", self.banana))
|
||||
app.add_handler(CommandHandler("dado", self.dice))
|
||||
app.add_handler(CommandHandler("moneda", self.coin))
|
||||
app.add_handler(CommandHandler("paredes", self.walls))
|
||||
app.add_handler(CommandHandler("oooh", self.oooh))
|
||||
app.add_handler(CommandHandler("beber", self.drink))
|
||||
app.add_handler(CommandHandler("bombardeen", self.bomb))
|
||||
|
||||
@delete_user_message
|
||||
async def ping(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
before = update.message.date.timestamp()
|
||||
now = time()
|
||||
await update.effective_chat.send_message(
|
||||
text=f"<b>🏓 Pong!</b> Latency is <i>{round((now - before) * 1000, 2)} ms</i>",
|
||||
parse_mode="HTML",
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def info(self, update:Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
group = update.effective_chat.title
|
||||
chat_id = update.effective_chat.id
|
||||
member_count = await context.bot.get_chat_member_count(chat_id)
|
||||
command_count = sum(1 for c in context.application.handlers[0] if isinstance(c, CommandHandler))
|
||||
info_text = f"""
|
||||
<b>Grupo: {group}</b>
|
||||
Miembros: {member_count}
|
||||
Creador: {BOT_OWNER}
|
||||
Nº Comandos: {command_count}
|
||||
|
||||
<b>Info técnica:</b>
|
||||
Nombre: {BOT_NAME}
|
||||
Lenguaje: {BOT_LANG}
|
||||
Tipo: {BOT_TYPE}
|
||||
Versión: {BOT_VERSION}
|
||||
"""
|
||||
|
||||
await update.effective_chat.send_message(
|
||||
text=info_text,
|
||||
parse_mode="HTML",
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def say(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text="Pero dime lo que tengo que decir puta",
|
||||
disable_notification=True
|
||||
)
|
||||
return
|
||||
await update.effective_chat.send_message(
|
||||
text=" ".join(arg for arg in context.args),
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def banana(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if update.effective_sender.id == BOT_OWNER_ID:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"La banana de {update.effective_user.first_name} mide 21 cm 😳",
|
||||
disable_notification=True
|
||||
)
|
||||
else:
|
||||
await update.effective_chat.send_message(
|
||||
text=f"La banana de {update.effective_user.first_name} mide {randint(-5, 21)} cm 😳",
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def dice(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
await update.effective_chat.send_dice(
|
||||
emoji='🎲',
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def coin(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
html =f"""
|
||||
<b>🪙 Se ha lanzado la moneda</b>
|
||||
Resultado: {choice(("Cara 😀", "Cruz ❌"))}
|
||||
"""
|
||||
await update.effective_chat.send_message(
|
||||
text=html,
|
||||
parse_mode="HTML",
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def walls(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text="Debes especificar un usuario",
|
||||
disable_notification=True
|
||||
)
|
||||
return
|
||||
|
||||
if not context.args[0].startswith("@"):
|
||||
await update.effective_chat.send_message(
|
||||
text="Debes mencionar a un usuario",
|
||||
disable_notification=True
|
||||
)
|
||||
return
|
||||
|
||||
user = context.args[0]
|
||||
caption = f"{user} está por las paredes"
|
||||
|
||||
with open("data/images/interaction/paredes.gif", "rb") as gif:
|
||||
await update.effective_chat.send_animation(
|
||||
animation=gif,
|
||||
caption=caption,
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def oooh(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
with open("data/images/interaction/oooh.gif", "rb") as gif:
|
||||
await update.effective_chat.send_animation(
|
||||
animation=gif,
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def drink(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
drinks = ["cerveza", "vino", "whisky", "ron", "vodka", "tequila", "ginebra", "sidra", "champán", "cava", "sake", "absenta", "brandy", "licor", "vermut", "mezcal", "pacharán", "anís", "aguardiente", "coñac", "cóctel", "cubata", "cóctel", "cubalibre"]
|
||||
with open("data/images/interaction/beber.gif", "rb") as gif:
|
||||
await update.effective_chat.send_animation(
|
||||
animation=gif,
|
||||
caption=f"@{update.effective_sender.username} ha bebido {choice(drinks)}",
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
@delete_user_message
|
||||
async def bomb(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if not context.args:
|
||||
await update.effective_chat.send_message(
|
||||
text="Debes especificar algo que bombardear",
|
||||
disable_notification=True
|
||||
)
|
||||
return
|
||||
|
||||
with open("data/images/interaction/bombardeen.gif") as gif:
|
||||
await update.effective_chat.send_animation(
|
||||
animation=gif,
|
||||
caption=f"Bombardeen {context.args[0]}",
|
||||
disable_notification=True
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user