Skip to content

Commit

Permalink
Add load_map command
Browse files Browse the repository at this point in the history
  • Loading branch information
th3-z committed Apr 11, 2018
1 parent b3f426b commit d747c0b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions magicked_admin/chatbot/commands/command_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def generate_map(self):
't_open': trader_event_manager,
'say': CommandSay(self.server),
'restart': CommandRestart(self.server),
'load_map': CommandLoadMap(self.server),
'toggle_pass': CommandTogglePassword(self.server),
'silent': CommandSilent(self.server, self.chatbot),
'length': CommandLength(self.server),
Expand Down
15 changes: 15 additions & 0 deletions magicked_admin/chatbot/commands/server_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ def execute(self, username, args, admin):
return "Restarting map."


class CommandLoadMap(Command):
def __init__(self, server, admin_only=True):
Command.__init__(self, server, admin_only)

def execute(self, username, args, admin):
if not self.authorise(admin):
return self.not_auth_message

if len(args) < 2:
return "Missing argument (map name)"

self.server.change_map(args[1])
return "Changing map."


class CommandTogglePassword(Command):
def __init__(self, server, admin_only=True):
Command.__init__(self, server, admin_only)
Expand Down
3 changes: 3 additions & 0 deletions magicked_admin/server/chat/chat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import threading
import requests
import time
from lxml import html
from colorama import init
from termcolor import colored
Expand Down Expand Up @@ -63,6 +64,8 @@ def run(self):
message = message_tree.xpath('//span[@class="message"]/text()')[0]
self.handle_message(username, message, admin)

time.sleep(self.time_interval)

def handle_message(self, username, message, admin):

command = True if message[0] == '!' else False
Expand Down
3 changes: 3 additions & 0 deletions magicked_admin/server/managers/motd_updater.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from os import path
import threading
import requests
import time

from lxml import html
from utils.text import millify
Expand Down Expand Up @@ -34,6 +35,8 @@ def run(self):
except requests.exceptions.RequestException:
continue

time.sleep(self.time_interval)

def submit_motd(self, payload):
motd_url = "http://" + self.server.address + \
"/ServerAdmin/settings/welcome"
Expand Down
1 change: 1 addition & 0 deletions magicked_admin/server/managers/server_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,4 @@ def run(self):
player.total_dosh_spent += player.dosh - new_dosh
player.dosh = new_dosh

time.sleep(self.time_interval)

0 comments on commit d747c0b

Please sign in to comment.