Add !help command
This commit is contained in:
		
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							@@ -36,7 +36,11 @@ Use prefix (in this case, "1") to call to attention before giving command.  (EX.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### Public Commands
 | 
					### Public Commands
 | 
				
			||||||
 | 
					
 | 
				
			||||||
These can be ran by anyone, all bots will reply
 | 
					These can be ran by anyone, all bots will reply.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`!help` - prints this whole help message to console
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`!help [command]` - replies in-game explaining command
 | 
				
			||||||
 | 
					
 | 
				
			||||||
`!ping` - replies with "pong"
 | 
					`!ping` - replies with "pong"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -86,7 +90,7 @@ These can be ran by anyone, all bots will reply
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### Bot-specific Commands
 | 
					### Bot-specific Commands
 | 
				
			||||||
 | 
					
 | 
				
			||||||
These will only run for the bot they are addressed to
 | 
					These will only run for the bot they are addressed to.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
`1respawn` - respawns the bot if it's dead
 | 
					`1respawn` - respawns the bot if it's dead
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -132,7 +136,7 @@ These will only run for the bot they are addressed to
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### Authorized Commands
 | 
					### Authorized Commands
 | 
				
			||||||
 | 
					
 | 
				
			||||||
These dangerous commands can only be ran by the bot owner
 | 
					These dangerous commands can only be ran by the bot owner.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
`1print [expression]` - replies with Python eval(expression)
 | 
					`1print [expression]` - replies with Python eval(expression)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								game.py
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								game.py
									
									
									
									
									
								
							@@ -25,6 +25,7 @@ from protocol.packets import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from protocol.types import Slot
 | 
					from protocol.types import Slot
 | 
				
			||||||
 | 
					import print_help
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import utils
 | 
					import utils
 | 
				
			||||||
importlib.reload(utils)
 | 
					importlib.reload(utils)
 | 
				
			||||||
@@ -492,7 +493,23 @@ class Game:
 | 
				
			|||||||
        try:
 | 
					        try:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ## ### Public Commands
 | 
					            ## ### Public Commands
 | 
				
			||||||
            ## These can be ran by anyone, all bots will reply
 | 
					            ## These can be ran by anyone, all bots will reply.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ## !help - prints this whole help message to console
 | 
				
			||||||
 | 
					            ## !help [command] - replies in-game explaining command
 | 
				
			||||||
 | 
					            if command == 'help':
 | 
				
			||||||
 | 
					                if data:
 | 
				
			||||||
 | 
					                    for line in print_help.HELP_LINES:
 | 
				
			||||||
 | 
					                        if line[1:].startswith(data) or line[1:].startswith(data[1:]):
 | 
				
			||||||
 | 
					                            reply = 'command ' + line
 | 
				
			||||||
 | 
					                            break
 | 
				
			||||||
 | 
					                    else:  # for
 | 
				
			||||||
 | 
					                        reply = 'command not found'
 | 
				
			||||||
 | 
					                else:
 | 
				
			||||||
 | 
					                    for line in print_help.HELP_LINES:
 | 
				
			||||||
 | 
					                        print(line)
 | 
				
			||||||
 | 
					                    reply = 'check console'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ## !ping - replies with "pong"
 | 
					            ## !ping - replies with "pong"
 | 
				
			||||||
            if command == 'ping':
 | 
					            if command == 'ping':
 | 
				
			||||||
@@ -653,7 +670,7 @@ class Game:
 | 
				
			|||||||
            ################# Specific commands ##########################
 | 
					            ################# Specific commands ##########################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ## ### Bot-specific Commands
 | 
					            ## ### Bot-specific Commands
 | 
				
			||||||
            ## These will only run for the bot they are addressed to
 | 
					            ## These will only run for the bot they are addressed to.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if for_me:
 | 
					            if for_me:
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
@@ -897,7 +914,7 @@ class Game:
 | 
				
			|||||||
            ################# Authorized commands ##########################
 | 
					            ################# Authorized commands ##########################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ## ### Authorized Commands
 | 
					            ## ### Authorized Commands
 | 
				
			||||||
            ## These dangerous commands can only be ran by the bot owner
 | 
					            ## These dangerous commands can only be ran by the bot owner.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if authed:
 | 
					            if authed:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,11 +6,11 @@ with open('game.py', 'r') as f:
 | 
				
			|||||||
            HELP_LINES.append(line.strip()[3:])
 | 
					            HELP_LINES.append(line.strip()[3:])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for line in HELP_LINES:
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    for line in HELP_LINES:
 | 
				
			||||||
        if ' - ' in line:
 | 
					        if ' - ' in line:
 | 
				
			||||||
            command, doc = line.split(' - ')
 | 
					            command, doc = line.split(' - ')
 | 
				
			||||||
            print('`{}` - {}\n'.format(command, doc))
 | 
					            print('`{}` - {}\n'.format(command, doc))
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print(line)
 | 
					            print(line)
 | 
				
			||||||
            print()
 | 
					            print()
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user