Skip to content

Commit

Permalink
Merge pull request #275 from JessicaTegner/master
Browse files Browse the repository at this point in the history
We now have localhost commands
  • Loading branch information
tspivey committed Apr 1, 2023
2 parents 23b9e97 + 4036cec commit 6f7174e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ygo/parsers/login_parser.py
Expand Up @@ -32,6 +32,12 @@ def handle_nickname(self, caller):
caller.connection.notify("Please enter a nickname. Your nickname is what you will be known by while playing.")
caller.connection.login_state = ("new", "Enter desired nickname:")
return self.prompt(caller)

# here we are checking for special commands
# that can only be executed from localhost
if caller.connection.transport.getPeer().host == "127.0.0.1":
if globals.server.handle_localhost_commands(caller):
return
nickname = caller.text.capitalize()
account = self.find_account(caller.connection.session, nickname)
if not account:
Expand Down
17 changes: 17 additions & 0 deletions ygo/server.py
Expand Up @@ -146,6 +146,23 @@ def reboot(self):
pl.notify(pl._("Rebooting."))
reactor.callLater(0.2, reactor.stop)

def handle_localhost_commands(self, caller):
# shutdown
if caller.text == 'shutdown':
globals.rebooting = not globals.rebooting
if globals.rebooting:
for pl in self.get_all_players():
if pl.is_admin:
pl.notify("Reboot started.")
caller.connection.notify("Reboot started.")
self.check_reboot()
else:
for pl in self.get_all_players():
if pl.is_admin:
pl.notify("Reboot canceled.")
caller.connection.notify("Reboot canceled.")
return True

@property
def all_cards(self):
return globals.language_handler.all_primary_cards

0 comments on commit 6f7174e

Please sign in to comment.