1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00
royalnet/royalpack/commands/ship.py

35 lines
1.2 KiB
Python
Raw Permalink Normal View History

2020-05-10 22:46:12 +00:00
from typing import *
2019-11-11 08:56:08 +00:00
import re
2020-05-10 22:46:12 +00:00
import royalnet.commands as rc
2019-11-11 08:56:08 +00:00
2020-05-10 22:46:12 +00:00
class ShipCommand(rc.Command):
2019-11-11 08:56:08 +00:00
name: str = "ship"
description: str = "Crea una ship tra due nomi."
syntax = "{nomeuno} {nomedue}"
2020-05-10 22:46:12 +00:00
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
2019-11-11 08:56:08 +00:00
name_one = args[0]
name_two = args[1]
if name_two == "+":
name_two = args[2]
name_one = name_one.lower()
name_two = name_two.lower()
# Get all letters until the first vowel, included
match_one = re.search(r"^[A-Za-z][^aeiouAEIOU]*[aeiouAEIOU]?", name_one)
if match_one is None:
part_one = name_one[:int(len(name_one) / 2)]
else:
part_one = match_one.group(0)
# Get all letters from the second to last vowel, excluded
match_two = re.search(r"[^aeiouAEIOU]*[aeiouAEIOU]?[A-Za-z]$", name_two)
if match_two is None:
part_two = name_two[int(len(name_two) / 2):]
else:
part_two = match_two.group(0)
# Combine the two name parts
mixed = part_one + part_two
2019-11-29 14:55:52 +00:00
await data.reply(f"💕 {part_one.capitalize()} + {part_two.capitalize()} = [b]{mixed.capitalize()}[/b]")