mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Change /ship behaviour
This commit is contained in:
parent
b3318e54e2
commit
bf6e46cc4f
1 changed files with 14 additions and 7 deletions
|
@ -528,18 +528,25 @@ def cmd_eat(bot: telegram.Bot, update: telegram.Update):
|
||||||
@command
|
@command
|
||||||
def cmd_ship(bot: telegram.Bot, update: telegram.Update):
|
def cmd_ship(bot: telegram.Bot, update: telegram.Update):
|
||||||
try:
|
try:
|
||||||
_, name_one, name_two = update.message.text.split(" ", 2)
|
names = update.message.text.split(" ")
|
||||||
|
name_one = names[1]
|
||||||
|
name_two = names[2]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
reply(bot, update, strings.SHIP.ERRORS.INVALID_SYNTAX)
|
reply(bot, update, strings.SHIP.ERRORS.INVALID_SYNTAX)
|
||||||
return
|
return
|
||||||
name_one = name_one.lower()
|
name_one = name_one.lower()
|
||||||
name_two = name_two.lower()
|
name_two = name_two.lower()
|
||||||
part_one = re.search(r"^[A-Za-z][^aeiouAEIOU]*[aeiouAEIOU]?", name_one)
|
match_one = re.search(r"^[A-Za-z][^aeiouAEIOU]*[aeiouAEIOU]?", name_one)
|
||||||
part_two = re.search(r"[^aeiouAEIOU]*[aeiouAEIOU]?[A-Za-z]$", name_two)
|
if match_one is None:
|
||||||
if part_one is None or part_two is None:
|
part_one = name_one[:int(len(name_one) / 2)]
|
||||||
reply(bot, update, strings.SHIP.ERRORS.INVALID_NAMES)
|
else:
|
||||||
return
|
part_one = match_one.group(0)
|
||||||
mixed = part_one.group(0) + part_two.group(0) # TODO: find out what exceptions this could possibly raise
|
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)
|
||||||
|
mixed = part_one + part_two # TODO: find out what exceptions this could possibly raise
|
||||||
reply(bot, update, strings.SHIP.RESULT,
|
reply(bot, update, strings.SHIP.RESULT,
|
||||||
one=name_one.capitalize(),
|
one=name_one.capitalize(),
|
||||||
two=name_two.capitalize(),
|
two=name_two.capitalize(),
|
||||||
|
|
Loading…
Reference in a new issue