summaryrefslogtreecommitdiff
path: root/motd.py
blob: 42e4c36af34fd107977e28b4263acdd9af1b7caa (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
#pylint: disable=F0401
from helpers import *

motd = server.getMotd()

@hook.command("getmotd")
def onGetMotdCommand(sender, args):
  plugHeader(sender, "MOTD")
  msg(sender, motd, usecolor=False)


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

    motd = colorify(" ".join(args).replace("\\n", "\n"))
    broadcast("", plugHeader(name="MOTD"))
    broadcast("", "&aNew MOTD:&r\n%s" % motd)
    broadcast(" ")
  else:
    noperm(sender)
  return True

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