commandhelper

10 posts Page 1 of 1
learn_more
Coder
Coder
Posts: 890
Joined: Sun Mar 24, 2013 9:59 pm


shows all commands available to you (can search with wildcards)
all commands:
Code: Select all
/commands
all commands with 'map' in em:
Code: Select all
/commands *map*
all commands starting with 'map':
Code: Select all
/commands map*

https://github.com/learn-more/pysnip/bl ... andhelp.py

[code"""
Command helper.
Copyright (c) 2013 learn_more
See the file license.txt or http://opensource.org/licenses/MIT for copying permission.

Lists all commands available to you (permission based).
"""

from commands import add, admin, commands as cmdlist, aliases as aliaslist
import fnmatch

def commands(connection, value = None):
names = []
for command in cmdlist:
command_func = cmdlist[command]
if (hasattr(command_func, 'user_types') and command not in connection.rights):
continue
include = False
if (value is None or fnmatch.fnmatch(command, value)):
include = True
aliases = []
for a in aliaslist:
if aliaslist[a] == command:
if (value is None or fnmatch.fnmatch(a, value)):
include = True
aliases.append(a)
cmd = command if len(aliases) == 0 else ('%s (%s)' % (command, ', '.join(aliases)))
if include:
names.append(cmd)
return 'Commands: %s' % (', '.join(names))

add(commands)

def apply_script(protocol, connection, config):
return protocol, connection
[/code]
Last edited by learn_more on Sun Nov 24, 2013 3:47 pm, edited 3 times in total.
[HPC]sajt
Deuced Up
Posts: 63
Joined: Thu Jan 31, 2013 8:18 pm


xDD bad.
[HPC]sajt
Deuced Up
Posts: 63
Joined: Thu Jan 31, 2013 8:18 pm


You don't know what the /help command?
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


wow amazing, this is a 10 times better then your demolition man script. (In terms of practical usage)
[HPC]sajt wrote:
You don't know what the /help command?
Sajt, Help command gives you a bunch of pre entered text, this will give the list of all commands available to you. And why did you double post?
learn_more
Coder
Coder
Posts: 890
Joined: Sun Mar 24, 2013 9:59 pm


[HPC]sajt wrote:
You don't know what the /help command?
clearly you don't know that help command works only half for admins (it only shows commands that are predefined in the server), and for non admins it will just show a dumb text.

this one works for everyone with every level (guard, builder, admin) and show them all commands and aliases available to them.
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


This is awesome. Overwriting the default help command for this
gamemaster77
Deuce
Posts: 3
Joined: Fri Feb 22, 2013 9:33 pm


I was actually just thinking about something like this when you made this. Very useful
izzy
Head Admin / Co-founder
Head Admin / Co-founder
Posts: 473
Joined: Tue Oct 09, 2012 8:16 pm


Helpful! Now usable on all aloha.pk servers.
Dare
3 Years of Ace of Spades
3 Years of Ace of Spades
Posts: 1187
Joined: Wed Sep 11, 2013 5:50 pm


If I want to use this cool command map on my server, I'll just need to add this script
https://github.com/learn-more/pysnip/bl ... andhelp.py in the config file?
learn_more
Coder
Coder
Posts: 890
Joined: Sun Mar 24, 2013 9:59 pm


add the script and enable it in the config, yes.
10 posts Page 1 of 1
Return to “Features & Enhancements”

Who is online

Users browsing this forum: No registered users and 1 guest