add motd.py

This commit is contained in:
jomo
2014-07-04 01:50:36 +02:00
parent 39a9644a1f
commit 340e09777e
4 changed files with 38 additions and 3 deletions

View File

@@ -125,6 +125,10 @@ If you want the server to load a file (*module*) on startup, add it to the `modu
> Adds `/cycler`, swaps the hotbar with inventory when player changes slot from right->left or left->right > Adds `/cycler`, swaps the hotbar with inventory when player changes slot from right->left or left->right
* `motd.py`
> Adds `/getmotd` & `/setmotd` to update the motd on the fly (no reboot).
# Code styleguide & tips # Code styleguide & tips

View File

@@ -41,8 +41,10 @@ def safetp(player, world, x, y, z, yaw = 0, pitch = 0):
else: else:
safetp(player, world, x, y+1, z, yaw, pitch) safetp(player, world, x, y+1, z, yaw, pitch)
def plugHeader(sender, name): def plugHeader(sender=None, name="Redstoner Utils"):
msg(sender, "\n&2--=[ %s ]=--" % name) head = "\n&2--=[ %s ]=--" % name
msg(sender, head)
return head
def noperm(player): def noperm(player):
msg(player, "&cno permission") msg(player, "&cno permission")

View File

@@ -31,7 +31,7 @@ def onDisable():
log("Loading RedstonerUtils...") log("Loading RedstonerUtils...")
# Import all modules # Import all modules
modules = ["misc", "adminchat", "lagchunks", "reports", "chatgroups", "webtoken", "saylol", "skullclick", "mentio", "cycle"] modules = ["misc", "adminchat", "lagchunks", "reports", "chatgroups", "webtoken", "saylol", "skullclick", "mentio", "cycle", "motd"]
mod = {} mod = {}
for module in modules: for module in modules:
try: try:

29
motd.py Normal file
View File

@@ -0,0 +1,29 @@
#pylint: disable=F0401
from helpers import *
motd = server.getMotd()
@hook.command("getmotd")
def onGetMotdCommand(sender, args):
plugHeader("MOTD")
msg(sender, motd, usecolor=False)
@hook.command("setmotd")
def onSetMotdCommand(sender, args):
global motd
plugHeader("MOTD")
if sender.hasPermission("utils.setmotd"):
if not checkargs(sender, args, 1, -1):
return True
motd = colorify(" ".join(args))
broadcast(plugHeader(name="MOTD"))
broadcast("&aNew MOTD:&r\n%s" % motd)
else:
noperm(sender)
return True
@hook.event("server.ServerListPingEvent")
def onServerPing(event):
event.setMotd(motd)