Development > Coding and development discussion

<pre>help will only show commands you can use

(1/1)

MatHack:
Since I don't like having commands listed which a member can't use anyway, I decided to find out how to 'fix' that. (good way to get better known with the bot structure too).

Please note that it will just not show the commands, but if you ask direct help for it (<pre>help <pre>command), it will still show the help (this is intended).

Changes are done in core/BotHelp.php


--- Code: ---<?php
function main_help($name)
{
$help = "<font color=CCInfoHeadline>::::: HELP :::::</font>\n\n";



$help .= "<font color=CCInfoHeader>Commands usable in Tells:</font>\n";
if (!empty($this -> bot -> commands["tell"]))
{
ksort($this -> bot -> commands["tell"]);
foreach ($this -> bot -> commands["tell"] as $key => $val)
{
if ($this -> bot -> rightsmanagement -> check_rights($name, $key, "tell"))
$help .= "<a href='chatcmd:///tell <botname> <pre>help <pre>" .
$key . "'><pre>" . $key . "</a> ";
}
}
$help .= "\n\n";


$help .= "<font color=CCInfoHeader>Commands usable in Privategroup:</font>\n";
if (!empty($this -> bot -> commands["pgmsg"]))
{
ksort($this -> bot -> commands["pgmsg"]);
foreach ($this -> bot -> commands["pgmsg"] as $key => $val)
{
if ($this -> bot -> rightsmanagement -> check_rights($name, $key, "pgmsg"))
$help .= "<a href='chatcmd:///tell <botname> <pre>help <pre>" .
$key . "'><pre>" . $key . "</a> ";
}
}
$help .= "\n\n";

if ($this -> bot -> guildbot)
{
$help .= "<font color=CCInfoHeader>Commands usable in Guild Chat:</font>\n";
if (!empty($this -> bot -> commands["gc"]))
{
ksort($this -> bot -> commands["gc"]);
foreach ($this -> bot -> commands["gc"] as $key => $val)
{
if ($this -> bot -> rightsmanagement -> check_rights($name, $key, "gc"))
$help .= "<a href='chatcmd:///tell <botname> <pre>help <pre>" .
$key . "'><pre>" . $key . "</a> ";
}
}
$help .= "\n\n";
}

$this -> bot -> send_tell($name, $this -> bot -> make_blob("Help", $help));
}
?>
--- End code ---

Alreadythere:
Nice idea!

Should remove some testing around by nosy people :)

Navigation

[0] Message Index

Go to full version