• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

Help command

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
3 posts • Page 1 of 1

Postby $c@r » Sat Jun 03, 2006 10:24 pm

When I started Phpfreechat, I was chocked by the fact that there were no /help command. That's why I wrote this script, 'pfccommand_help.class.php' :
Code: Select all
<?php
// create the customized command
require_once "pfccommand.class.php";
class pfcCommand_help extends pfcCommand
{

  function run(&$xml_reponse, $clientid, $msg)
  {
        // Initialisation
      $c =& $this->c;
      $container =& $c->getContainerInstance();
   // Ignored commands list
      $this->ign[] = 'init';
               
      $return = 'Voici la liste des commandes disponible :<br /> ';
        // open commands directory
      if ($dh = opendir(dirname(__FILE__))) {
         while (($file = readdir($dh)) !== false) {
        // Test the file name, if its a command class
            if(substr($file, 0, 11) == 'pfccommand_' && substr($file, strlen($file)-10, strlen($file)) == '.class.php'){
               $cmd = substr($file, 11, (strlen($file)-21));
       // If command isn't in ignored list, show it
                                        if (!in_array($cmd, $this->ign)){
                                                $return .= ' - '.$cmd.'<br /> ';                                       
                                        }
            }
         }
         closedir($dh);
      }
      // Send commands list
      $container->writeMsg("*notice*", $return);
  }
 
}
?>

PS : sorry for my english, I'm french :)
$c@r
Member
 
Posts: 13
Joined: Sat Jun 03, 2006 9:06 pm
Location: France
  • Website
Top

Postby $c@r » Sun Jun 04, 2006 9:54 am

TODO : add a description and syntax by command, eg :
/help me

will return :
/me [do anithing]
This command permit to ...

But for this I have to modify each command class, and add a method like this :
Code: Select all
public function getHelpMsg(){return "Help message";}
$c@r
Member
 
Posts: 13
Joined: Sat Jun 03, 2006 9:06 pm
Location: France
  • Website
Top

Postby $c@r » Sun Jun 04, 2006 11:52 pm

Well, I just get the last version of phpfreechat, I will upgrade my class in consequence.
$c@r
Member
 
Posts: 13
Joined: Sat Jun 03, 2006 9:06 pm
Location: France
  • Website
Top


Post a reply
3 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 13 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub