Skip to content
This repository was archived by the owner on Apr 27, 2019. It is now read-only.

Commit 0cdc0c8

Browse files
committed
Added mute and unmute commands along with an associated DB column. Fixed errant command in plugin_manager_plugin.
1 parent b2797eb commit 0cdc0c8

5 files changed

Lines changed: 44 additions & 5 deletions

File tree

core_plugins/player_manager/manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class Player(Base):
4747
plugin_storage = Column(String)
4848
planet = Column(String)
4949
on_ship = Column(Boolean)
50+
muted = Column(Boolean)
5051

5152
ips = relationship("IPAddress", order_by="IPAddress.id", backref="players")
5253

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from admin_command_plugin import UserCommandPlugin
1+
from admin_command_plugin import UserCommandPlugin, MuteManager

plugins/admin_commands_plugin/admin_command_plugin.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from base_plugin import SimpleCommandPlugin
1+
from base_plugin import SimpleCommandPlugin, BasePlugin
22
from core_plugins.player_manager import permissions, UserLevels
3+
from packets import chat_sent
34
from utility_functions import give_item_to_player
45

56

@@ -9,7 +10,7 @@ class UserCommandPlugin(SimpleCommandPlugin):
910
"""
1011
name = "user_management_commands"
1112
depends = ['command_dispatcher', 'player_manager']
12-
commands = ["who", "whois", "promote", "kick", "ban", "give_item", "planet"]
13+
commands = ["who", "whois", "promote", "kick", "ban", "give_item", "planet", "mute", "unmute"]
1314
auto_activate = True
1415

1516
def activate(self):
@@ -190,3 +191,40 @@ def give_item(self, data):
190191
self.protocol.send_chat_message("Couldn't find name: %s" % name)
191192
return False
192193

194+
@permissions(UserLevels.ADMIN)
195+
def mute(self, data):
196+
"""Mute a player. Syntax: /mute [player name]"""
197+
name = " ".join(data)
198+
player = self.player_manager.get_logged_in_by_name(name)
199+
target_protocol = self.protocol.factory.protocols[player.protocol]
200+
if player is None:
201+
self.protocol.send_chat_message("Couldn't find name: %s" % name)
202+
return
203+
player.muted = True
204+
target_protocol.send_chat_message("You have been muted.")
205+
self.protocol.send_chat_message("%s has been muted." % name)
206+
207+
@permissions(UserLevels.ADMIN)
208+
def unmute(self, data):
209+
"""Unmute a currently muted player. Syntax: /unmute [player name]"""
210+
name = " ".join(data)
211+
player = self.player_manager.get_logged_in_by_name(name)
212+
target_protocol = self.protocol.factory.protocols[player.protocol]
213+
if player is None:
214+
self.protocol.send_chat_message("Couldn't find name: %s" % name)
215+
return
216+
player.muted = False
217+
target_protocol.send_chat_message("You have been unmuted.")
218+
self.protocol.send_chat_message("%s has been unmuted." % name)
219+
220+
221+
class MuteManager(BasePlugin):
222+
name = "mute_manager"
223+
def on_chat_sent(self, data):
224+
data = chat_sent().parse(data.data)
225+
if self.protocol.player.muted and data.message[0] != self.config.command_prefix and data.message[:2] != "##":
226+
self.protocol.send_chat_message("You are currently muted and cannot speak. You are limited to commands and admin chat (prefix your lines with ## for admin chat.")
227+
return False
228+
return True
229+
230+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😒😓😔😖😘😚😜😝😞😠😡😢😣😥😨😩😪😫😭😰😱😲😳😵😶😷
1+
Welcome to the server! Here are some starter items to get you off to a good start.

plugins/plugin_manager_plugin/plugin_manager_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class PluginManagerPlugin(SimpleCommandPlugin):
77
""" Provides a simple chat interface to the PluginManager"""
88
name = "plugin_manager"
9-
commands = ["list_plugins", "enable_plugin", "disable_plugin", "help", "reload_plugins"]
9+
commands = ["list_plugins", "enable_plugin", "disable_plugin", "help"]
1010
auto_activate = True
1111

1212
@property

0 commit comments

Comments
 (0)