summaryrefslogtreecommitdiff
path: root/motd.py
blob: 9c8b349fa6969ed954746bb1e7fff7c832a55fc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pylint: disable = F0401
from helpers import *

default_motd = colorify(server.getMotd())
motd         = default_motd

@hook.command("getmotd")
def on_getmotd_command(sender, command, label, args):
    plugin_header(sender, "MOTD")
    msg(sender, motd, usecolor = False)


@hook.command("setmotd")
def on_setmotd_command(sender, command, label, args):
    global motd
    if sender.hasPermission("utils.setmotd"):
        if not checkargs(sender, args, 1, -1):
            return True

        motd = colorify(" ".join(args).replace("\\n", "\n"))

        if motd == "--reset":
            motd = default_motd

        broadcast(None, plugin_header(name="MOTD"))
        broadcast(None, "&aNew MOTD:&r\n%s" % motd)
        broadcast(None, " ")
    else:
        noperm(sender)
    return True


@hook.event("server.ServerListPingEvent")
def on_server_ping(event):
    event.setMotd(motd)