summaryrefslogtreecommitdiff
path: root/motd.py
blob: 611bb207d5f8cb7d1f93cc76fcb3cedc1b00377e (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
  plugHeader(sender, "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)
  else:
    noperm(sender)
  return True

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