Spaces:
Paused
Paused
File size: 9,839 Bytes
1fefee0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | import html
import itertools
import random
import string
def _text(ctx):
return (ctx.args or (ctx.reply.text if ctx.reply and ctx.reply.text else '') or (ctx.reply.caption if ctx.reply and ctx.reply.caption else '') or '').strip()
def _items(text: str):
return [x.strip() for x in text.replace('\n', ',').split(',') if x.strip()]
def setup(registry):
async def coin_cmd(ctx):
await ctx.respond(f'🪙 <b>Moneda</b>\n\n<b>{random.choice(["Cara 😄", "Cruz 😵"])}</b>')
async def dice_cmd(ctx):
sides = 6
if ctx.args.strip().isdigit():
sides = max(2, min(1000, int(ctx.args.strip())))
await ctx.respond(f'🎲 <b>Dado</b>\n\nSalió: <code>{random.randint(1, sides)}</code> de <code>{sides}</code>')
async def rand_cmd(ctx):
parts = ctx.args.split()
if len(parts) == 2 and all(p.lstrip('-').isdigit() for p in parts):
a, b = map(int, parts)
else:
a, b = 1, 100
if a > b:
a, b = b, a
await ctx.respond(f'🎰 <b>Número aleatorio</b>\n\n<code>{random.randint(a, b)}</code>')
async def choose_cmd(ctx):
text = _text(ctx)
items = _items(text)
if len(items) < 2:
await ctx.respond('⚠️ Pon varias opciones separadas por comas.')
return
await ctx.respond(f'🎯 <b>Elegido</b>\n\n<b>{html.escape(random.choice(items))}</b>')
async def pick_cmd(ctx):
await choose_cmd(ctx)
async def sample_cmd(ctx):
text = _text(ctx)
if not text:
await ctx.respond('⚠️ Usa <code>.samplex 2 | a,b,c,d</code>')
return
if ' | ' not in text:
await ctx.respond('⚠️ Usa <code>.samplex 2 | a,b,c,d</code>')
return
n_raw, items_raw = [p.strip() for p in text.split(' | ', 1)]
if not n_raw.isdigit():
await ctx.respond('⚠️ El primer valor debe ser un número.')
return
items = _items(items_raw)
n = max(1, min(len(items), int(n_raw)))
out = random.sample(items, n)
await ctx.respond('🧺 <b>Muestra aleatoria</b>\n\n' + '\n'.join(f'• {html.escape(x)}' for x in out))
async def shuffle_cmd(ctx):
items = _items(_text(ctx))
if len(items) < 2:
await ctx.respond('⚠️ Pon varias opciones separadas por comas.')
return
random.shuffle(items)
await ctx.respond('🔀 <b>Opciones mezcladas</b>\n\n' + '\n'.join(f'{i+1}. {html.escape(x)}' for i, x in enumerate(items)))
async def eightball_cmd(ctx):
answers = [
'Sí, totalmente 😎', 'No 😬', 'Tal vez 🤔', 'Tiene buena pinta ✨', 'Mejor espera ⏳',
'Hazlo 💥', 'No lo haría 🚫', 'Todo apunta a que sí ✅', 'Difícil saberlo 🌫️', 'Se viene algo bueno 🔥'
]
q = _text(ctx) or 'Pregunta misteriosa'
await ctx.respond(f'🎱 <b>8 Ball</b>\n\n❓ {html.escape(q)}\n💬 <b>{random.choice(answers)}</b>')
async def mock_cmd(ctx):
text = _text(ctx)
if not text:
await ctx.respond('⚠️ Pásame un texto.')
return
out = ''.join(ch.upper() if i % 2 else ch.lower() for i, ch in enumerate(text))
await ctx.respond(f'🫠 <b>Mock</b>\n\n<code>{html.escape(out)}</code>')
async def clapify_cmd(ctx):
text = _text(ctx)
if not text:
await ctx.respond('⚠️ Pásame un texto.')
return
await ctx.respond(f'👏 <b>Clapify</b>\n\n<code>{html.escape(" 👏 ".join(text.split()))}</code>')
async def spaceify_cmd(ctx):
text = _text(ctx)
if not text:
await ctx.respond('⚠️ Pásame un texto.')
return
await ctx.respond(f'🌌 <b>Spaceify</b>\n\n<code>{html.escape(" ".join(list(text)))}</code>')
async def reversewords_cmd(ctx):
text = _text(ctx)
if not text:
await ctx.respond('⚠️ Pásame un texto.')
return
out = ' '.join(reversed(text.split()))
await ctx.respond(f'🔁 <b>Palabras invertidas</b>\n\n<code>{html.escape(out)}</code>')
async def scramble_cmd(ctx):
text = _text(ctx)
if not text:
await ctx.respond('⚠️ Pásame un texto.')
return
chars = list(text)
random.shuffle(chars)
await ctx.respond(f'🧩 <b>Texto mezclado</b>\n\n<code>{html.escape("".join(chars))}</code>')
async def rcase_cmd(ctx):
text = _text(ctx)
if not text:
await ctx.respond('⚠️ Pásame un texto.')
return
out = ''.join(random.choice([c.lower(), c.upper()]) for c in text)
await ctx.respond(f'🎨 <b>Random case</b>\n\n<code>{html.escape(out)}</code>')
async def linepick_cmd(ctx):
text = _text(ctx)
lines = [x for x in text.splitlines() if x.strip()]
if len(lines) < 2:
await ctx.respond('⚠️ Necesito varias líneas.')
return
await ctx.respond(f'📌 <b>Línea elegida</b>\n\n<b>{html.escape(random.choice(lines))}</b>')
async def lorem_cmd(ctx):
words = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'nunc', 'vitae', 'urna', 'magna']
n = 20
if ctx.args.strip().isdigit():
n = max(5, min(200, int(ctx.args.strip())))
out = ' '.join(random.choice(words) for _ in range(n))
await ctx.respond(f'📝 <b>Lorem aleatorio</b>\n\n<code>{out}</code>')
async def nickname_cmd(ctx):
starts = ['Neo', 'Dark', 'Ultra', 'Mega', 'Ghost', 'Pixel', 'Crypto', 'Turbo', 'Luna', 'Solar']
ends = ['Fox', 'Byte', 'Storm', 'Nova', 'Wave', 'Wolf', 'Cat', 'Pulse', 'Code', 'Flame']
await ctx.respond(f'🪪 <b>Nick aleatorio</b>\n\n<code>{random.choice(starts)}{random.choice(ends)}{random.randint(1,99)}</code>')
async def teamup_cmd(ctx):
items = _items(_text(ctx))
if len(items) < 2:
await ctx.respond('⚠️ Pon varios nombres separados por comas.')
return
random.shuffle(items)
pairs = [items[i:i+2] for i in range(0, len(items), 2)]
out = []
for i, pair in enumerate(pairs, 1):
out.append(f'Equipo {i}: ' + ' + '.join(html.escape(x) for x in pair))
await ctx.respond('👥 <b>Equipos</b>\n\n' + '\n'.join(out))
async def pairs_cmd(ctx):
await teamup_cmd(ctx)
async def draw_cmd(ctx):
items = _items(_text(ctx))
if not items:
await ctx.respond('⚠️ Pon opciones separadas por comas.')
return
random.shuffle(items)
out = '\n'.join(f'{i+1}. {html.escape(x)}' for i, x in enumerate(items))
await ctx.respond('🏆 <b>Sorteo / ranking aleatorio</b>\n\n' + out)
async def decide_cmd(ctx):
await ctx.respond(f'🤖 <b>Decisión rápida</b>\n\n<b>{random.choice(["Sí", "No", "Hazlo", "Pasa", "Espera un poco", "Ve con todo"])} {random.choice(["🔥", "😅", "✨", "🚀", "🤝", "🧠"])} </b>')
async def yesno_cmd(ctx):
await ctx.respond(f'✅❌ <b>Respuesta</b>\n\n<b>{random.choice(["Sí", "No"])}</b>')
registry.add('coin', coin_cmd, 'Lanza una moneda.', usage='.coin', category='Aleatorio')
registry.add('dicex', dice_cmd, 'Lanza un dado de N caras.', usage='.dicex 20', category='Aleatorio')
registry.add('rand', rand_cmd, 'Número aleatorio entre A y B.', usage='.rand 1 100', category='Aleatorio')
registry.add('choose', choose_cmd, 'Elige una opción.', usage='.choose rojo, azul, verde', category='Aleatorio')
registry.add('pick', pick_cmd, 'Alias de choose.', usage='.pick pizza, sushi', category='Aleatorio')
registry.add('samplex', sample_cmd, 'Toma una muestra aleatoria.', usage='.samplex 2 | a,b,c,d', category='Aleatorio')
registry.add('shufflex', shuffle_cmd, 'Mezcla opciones.', usage='.shufflex a,b,c,d', category='Aleatorio')
registry.add('eightball', eightball_cmd, 'Responde como una bola mágica.', usage='.eightball me irá bien?', category='Aleatorio')
registry.add('mock', mock_cmd, 'Alterna mayúsculas y minúsculas.', usage='.mock hola', category='Aleatorio')
registry.add('clapify', clapify_cmd, 'Añade aplausos entre palabras.', usage='.clapify esto está duro', category='Aleatorio')
registry.add('spaceify', spaceify_cmd, 'Separa letras con espacios.', usage='.spaceify hola', category='Aleatorio')
registry.add('reversewords', reversewords_cmd, 'Invierte el orden de palabras.', usage='.reversewords hola mundo', category='Aleatorio')
registry.add('scramble', scramble_cmd, 'Mezcla caracteres del texto.', usage='.scramble hola', category='Aleatorio')
registry.add('rcase', rcase_cmd, 'Pone letras en may/min aleatorias.', usage='.rcase hola', category='Aleatorio')
registry.add('linepick', linepick_cmd, 'Elige una línea al azar.', usage='.linepick', category='Aleatorio')
registry.add('loremx', lorem_cmd, 'Genera lorem aleatorio.', usage='.loremx 30', category='Aleatorio')
registry.add('nickname', nickname_cmd, 'Genera un nick aleatorio.', usage='.nickname', category='Aleatorio')
registry.add('teamup', teamup_cmd, 'Forma equipos aleatorios.', usage='.teamup ana, luis, marta, pepe', category='Aleatorio')
registry.add('pairsx', pairs_cmd, 'Alias de teamup.', usage='.pairsx ana, luis, marta, pepe', category='Aleatorio')
registry.add('draw', draw_cmd, 'Hace un sorteo/orden aleatorio.', usage='.draw ana, luis, marta', category='Aleatorio')
registry.add('decide', decide_cmd, 'Te suelta una decisión rápida.', usage='.decide', category='Aleatorio')
registry.add('yesno', yesno_cmd, 'Responde sí o no.', usage='.yesno', category='Aleatorio')
|