Skip to content

Commit

Permalink
Add fun command /muffin to the funcommand app. (#1274)
Browse files Browse the repository at this point in the history
* Add fun command /muffin to the funcommand app.

* Improve muffin message (add shadow)

* Improve matching nickname in tm2020 for muffin commandf

* Improve the representation of the destination nickname in the muffin command
  • Loading branch information
tomvlk committed Aug 30, 2023
1 parent a0f07f6 commit 18fa540
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 2 deletions.
11 changes: 11 additions & 0 deletions docs/source/apps/contrib/funcmd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ By default, also the Emoji Toolbar is enabled, you can disable this in //setting
Commands
--------

Muffin
~~~~~~
Command:
``/muffin [login]``
Parameters:
* Login - Login or nickname of destination player.
Functionality:
Gives a muffin virtually to another player.
Required permission:
None.

Boot Me
~~~~~~~
Command:
Expand Down
76 changes: 74 additions & 2 deletions pyplanet/apps/contrib/funcmd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,68 @@
import random

from pyplanet.apps.config import AppConfig
from pyplanet.apps.contrib.funcmd.view import EmojiToolbarView
from pyplanet.contrib.command import Command

from pyplanet.apps.core.maniaplanet import callbacks as mp_signals

from pyplanet.contrib.command import Command
from pyplanet.contrib.setting import Setting

from pyplanet.utils.style import style_strip


class FunCmd(AppConfig):
app_dependencies = ['core.maniaplanet']

muffins = [
'Muffin',
'Apple Cinnamon Muffin',
'Cornbread Muffin',
'Blueberry Cream Cheese Muffin',
'Sweet Potato Muffin',
'Chocolate Muffin',
'Coffee Cake Muffin',
'Snickerdoodle Mini Muffin',
'Oatmeal Muffin',
'Cinnamon Streusel Muffin',
'Apple Cider Muffin',
'Toffe-ee Muffin ;-)',
'Insert-Developer-Joke-Here Muffin',
'Orange Marmalade Muffin',
'Pumpkin Spice Muffin',
'Cranberry Oatmeal Muffin',
'Pineapple & Sour Cream Muffin',
'Lemon Yogurt Muffin',
'Zucchini Muffin',
'Slice of Apple Pie',
'Baklava',
'Bowl of Gelato',
'Picarones',
'Syrniki',
'Lamingtons',
'Cup of Skyr',
'Om Ali',
'Bread Pudding',
'Loukoumades',
'Slice of Spekkoek',
'Slice of Slagroomtaart',
'Appelflappen',
'Banana Muffin',
'No Muffin',
'Blueberry Muffin',
'Two Muffins',
'Muffin with Cream',
'Choc-Chip Muffin',
'Double Chocolate Muffin',
'Lemmon & Poppyseed Muffin',
'Apple Crunch Muffin',
'Raspberry Muffin',
'Pink Cupcake',
'Pumpkin Pie',
'Slice of Cheesecake',
'Cinnamon Doghnut',
'Carrot Cake',
]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand All @@ -32,6 +86,7 @@ async def on_start(self):
Command(command='gg', target=self.command_gg, admin=False, description='Send Good Game to everyone'),
Command(command='n1', target=self.command_n1, admin=False, description='Send Nice One to everyone'),
Command(command='nt', target=self.command_nt, admin=False, description='Send Nice Try/Nice Time to everyone'),
Command(command='muffin', target=self.command_muffin, admin=False, description='Give muffin to another player').add_param(name='login', required=True),
)

if self.instance.game.game == 'sm':
Expand Down Expand Up @@ -62,6 +117,23 @@ async def command_afk(self, player, data, **kwargs):
self.instance.chat('$fff {}$z$s$fff is now away from keyboard.'.format(player.nickname))
)

async def command_muffin(self, player, data, **kwargs):
if self.instance.game.game == 'tmnext':
nickname_input = style_strip(data.login).lower()
dest_player = [p for p in self.instance.player_manager.online if style_strip(p.nickname.lower()) == nickname_input]
else:
dest_player = [p for p in self.instance.player_manager.online if p.login == data.login]

if not dest_player:
message = '$i$f00Unknown player!'
return await self.instance.chat(message, player)

message = '$z$s{}$z$s$m$f90 gave {} to $z$s{}'.format(
player.nickname, random.choice(self.muffins), dest_player[0].nickname
)

await self.instance.chat(message)

async def command_bootme(self, player, data, **kwargs):
if 'admin' in self.instance.apps.apps and self.instance.apps.apps['admin'].server.chat_redirection:
return
Expand Down

0 comments on commit 18fa540

Please sign in to comment.