コード例 #1
0
ファイル: bot.py プロジェクト: TheSara/Control-Panel-Bot
 async def state(self):
     """Gets the server's current state"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     await self.bot.say("The server is **{}**".format(state))
コード例 #2
0
ファイル: bot.py プロジェクト: TheSara/Control-Panel-Bot
 async def list(self):
     """Gets the list of online players"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     if state == "offline":
         await self.bot.say("The server is offline")
         return
     await self.bot.say(amp.get_player_list())
コード例 #3
0
ファイル: bot.py プロジェクト: TheSara/Control-Panel-Bot
 async def kill(self):
     """Kills the server (useful if it isn't responding)"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     if state == "offline":
         await self.bot.say("The server is already stopped")
         return
     else:
         amp.control_power(amp.Power.KILL)
         await self.bot.say("Killing the server...")
コード例 #4
0
ファイル: bot.py プロジェクト: TheSara/Control-Panel-Bot
 async def restart(self):
     """Restarts the server"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     if state == "starting":
         await self.bot.say("The server is already starting")
         return
     elif state == "shutting down":
         await self.bot.say("The server is already shutting down")
         return
     else:
         amp.control_power(amp.Power.RESTART)
         await self.bot.say("Restarting the server...")
コード例 #5
0
ファイル: bot.py プロジェクト: TheSara/Control-Panel-Bot
 async def start(self):
     """Starts the server"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     if state == "online":
         await self.bot.say("The server is already running")
         return
     elif state == "starting":
         await self.bot.say("The server is already starting")
         return
     else:
         amp.control_power(amp.Power.START)
         await self.bot.say("Starting the server...")
コード例 #6
0
ファイル: bot.py プロジェクト: TheSara/Control-Panel-Bot
 async def sendcommand(self, ctx, *, command: str):
     """Send a console command"""
     try:
         state = amp.get_server_state()
     except KeyError:
         amp.get_session_id()
         state = amp.get_server_state()
     if state == "offline":
         await self.bot.say("The server is offline")
         return
     amp.send_console_command(command)
     console_logger.info("[Console Command] {}: {}".format(
         ctx.message.author,
         ctx.message.content.replace(
             "{}{} ".format(config.command_prefix, ctx.command), "")))
     await self.bot.say("Command sent!")
コード例 #7
0
ファイル: bot.py プロジェクト: TheSara/Control-Panel-Bot
async def on_ready():
    print("Connected! Logged in as {}/{}".format(bot.user, bot.user.id))
    amp.get_session_id()