Add support for server MOTDs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from piston.handler import AnonymousBaseHandler
|
||||
from profiles.models import MinecraftProfile
|
||||
from profiles.models import MinecraftProfile, Quote
|
||||
from minecraft.models import MOTD
|
||||
from django.http import HttpResponse
|
||||
|
||||
class WhitelistHandler(AnonymousBaseHandler):
|
||||
@@ -14,3 +15,16 @@ class WhitelistHandler(AnonymousBaseHandler):
|
||||
if profile.user.is_active:
|
||||
return HttpResponse(status=204)
|
||||
return HttpResponse(status=404)
|
||||
|
||||
class MOTDHandler(AnonymousBaseHandler):
|
||||
allowed_methods = ('GET',)
|
||||
|
||||
def read(self, request, username):
|
||||
motd = "No MOTD configured!"
|
||||
motdList = MOTD.objects.all()
|
||||
if len(motdList) > 0:
|
||||
motd = motdList[0].text
|
||||
quote = Quote.objects.order_by('?')
|
||||
if len(quote) > 0:
|
||||
motd += "\n"+quote.text
|
||||
return {"motd":motd.split('\n')}
|
||||
|
Reference in New Issue
Block a user