• 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

[0.x & <1.0-beta3] Random quotes

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

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

Post a reply
10 posts • Page 1 of 1

Postby HeroicLife » Sat Mar 04, 2006 8:38 am

How about a subforum just for custom commands?

I wrote my first command for random quotes on my chat:

Code: Select all
// create the customized command
require_once "src/pfccommand.class.php";
class pfcCommand_quote extends pfcCommand
{
  function run(&$xml_reponse, $clientid, $msg)
  {
    $c =& $this->c;

    $nick      = $c->nick;
    $container =& $c->getContainerInstance();
    $para      = trim($msg);
    $para = explode(" ",$para);
    $URL = 'http://www.rationalmind.net/random.php?format=txt&';
   
   if ($para[0] == '') {
$quote = explode("~~", trim(@file_get_contents($URL)));
} elseif ($para[0] =='topic') {
$quote = explode("~~", trim(@file_get_contents($URL.'topic='.$para[1])));
} elseif ($para[0] =='author') {
$quote = explode("~~", trim(@file_get_contents($URL.'author='.$para[1])));
} elseif ($para[0] =='mises') {
$quote = explode("~~", trim(@file_get_contents("http://www.mises.org/quote.aspx?format=txt")));
} elseif ($para[0] =='random') {
$quote = explode("~~", trim(@file_get_contents("http://www.timelessquotes.com/randq.php")));

}


$result = '"'.$quote[0].'" - '.$quote[1];
if (!$quote[0]) { $result = 'Not found!'; }

 if (!$quote[0])
    {
      $cmd =& pfcCommand::Factory("error", $c);
      $cmd->run($xml_reponse, $clientid, "Quote failed: " . $result);
    }
    else
    {
      $container->writeMsg($quote[1], $result);
    }
    if ($c->debug) pxlog("Cmd_quote[".$c->sessionid."]: msg=".$result, "chat", $c->getId());
 }
}
Last edited by HeroicLife on Sat Mar 04, 2006 9:58 am, edited 1 time in total.
HeroicLife
Member
 
Posts: 17
Joined: Tue Feb 21, 2006 8:55 pm
Top

Postby phpfreechat » Sat Mar 04, 2006 10:40 am

This demonstrate how to create a original command using the new interface.
This is really nice!

Good work. :)
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby HeroicLife » Wed Jun 21, 2006 3:56 pm

Here is the 1.0 version - place it in /src/commands/quote.class.php

Code: Select all
<?php

require_once(dirname(__FILE__)."/../pfccommand.class.php");
class pfcCommand_quote extends pfcCommand
{
  function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid)
  {
    $c =& $this->c;

    $nick      = $c->nick;
    $para      = trim($param);
    $para = explode(" ",$para);
    $URL = 'http://www.rationalmind.net/random.php?format=txt&';
   
   if ($para[0] == '') {
$quote = explode("~~", trim(@file_get_contents($URL)));
} elseif ($para[0] =='topic') {
$quote = explode("~~", trim(@file_get_contents($URL.'topic='.$para[1])));
} elseif ($para[0] =='author') {
$quote = explode("~~", trim(@file_get_contents($URL.'author='.$para[1])));
} elseif ($para[0] =='mises') {
$quote = explode("~~", trim(@file_get_contents("http://www.mises.org/quote.aspx?format=txt")));
} elseif ($para[0] =='random') {
$quote = explode("~~", trim(@file_get_contents("http://www.timelessquotes.com/randq.php")));

}


$quotetext = $quote[0];
$author = $quote[1];
if (!$quote[0]) { $quotetext = 'Not found!'; }

 if (!$quote[0])
    {
      $cmd =& pfcCommand::Factory("error", $c);
      $cmd->run($xml_reponse, $clientid, "Quote failed: " . $quotetext);
    }
    else
    {
    $container =& $c->getContainerInstance();
    $container->write($recipient, $author, "send", $quotetext);

    }
    if ($c->debug) pxlog("Cmd_quote[".$c->sessionid."]: msg=".$quotetext, "chat", $c->getId());
 }
}
?>
Last edited by HeroicLife on Wed Jun 21, 2006 3:57 pm, edited 1 time in total.
HeroicLife
Member
 
Posts: 17
Joined: Tue Feb 21, 2006 8:55 pm
Top

Postby eretard » Tue Sep 19, 2006 9:11 am

Ok, I copy and paste all the code, and placed it in the src/command directory under the filename of quote.class.php, and I can not get the command to run. I am using 1.0 beta 5.

I did rehash and all that.

Tom
eretard
Member
 
Posts: 21
Joined: Sat Sep 09, 2006 12:46 pm
Top

Postby eretard » Tue Sep 19, 2006 9:26 am

When I type in the command. I get nothing at all. No error, and no quote

Tom
eretard
Member
 
Posts: 21
Joined: Sat Sep 09, 2006 12:46 pm
Top

Postby phpfreechat » Tue Sep 19, 2006 10:45 pm

this command is for 1.0-beta4 or less... it's not compatible with new interfaces
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby eretard » Wed Sep 20, 2006 4:22 am

Awww...Rats....this would be kewl in beta 5 too....I am not good at coding...would there have to be major changes to make it work with beta 5 and/or higher?

Tom
eretard
Member
 
Posts: 21
Joined: Sat Sep 09, 2006 12:46 pm
Top

Postby eretard » Wed Sep 20, 2006 8:22 am

kerphi wrote:this command is for 1.0-beta4 or less... it's not compatible with new interfaces

I tried it in beta 4 and it still did not work. rehashed and all....Hmmmmmm

Tom
eretard
Member
 
Posts: 21
Joined: Sat Sep 09, 2006 12:46 pm
Top

Postby phpfreechat » Wed Sep 20, 2006 10:32 am

Sorry I made a mistake it's not for < 1.0-beta5 but for < 1.0-beta3, so try with beta2.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby Plaka » Tue Nov 14, 2006 9:29 pm

What would the command syntax be please?
/quote
/quote DeGaulle
/quote recipient [nick]

I have something similar on mIRC / Invision called with the command /quot

Random Quit Messages
Code: Select all
/quot {
  //if (%Conta == $null) //set %Conta 0
  /inc %Conta
  if (%Conta > $lines(Quotations.txt)) set %Conta 1
  //quit $read -l [ $+ [ %conta ] ] Quotations.txt
}

Instead of //quit it could be displayed in the chat window ...

Sample - Quotations.txt
Cannot find REALITY.SYS. Universe halted.
COFFEE.EXE Missing - Insert Cup and Press Any Key
Buy a Pentium 586/90 so you can reboot faster.
2 + 2 = 5 for extremely large values of 2.
Computers make very fast, very accurate mistakes.
Computers are not intelligent. They only think they are.
My software never has bugs. It just develops random features.
C:WINDOWS C:WINDOWSGO C:PCCRAWL C:DOS C:DOSRUN RUNDOSRUN
<-------- The information went data way -------->
Best file compression around: "DEL *.*" = 100% compression
The Definition of an Upgrade: Take old bugs out, put new ones in.
BREAKFAST.COM Halted...Cereal Port Not Responding
The name is Baud......, James Baud.
BUFFERS=20 FILES=15 2nd down, 4th quarter, 5 yards to go!
Access denied--nah nah na nah nah!
C:> Bad command or file name! Go stand in the corner. Bad, bad command!
Why doesn't DOS ever say "EXCELLENT command or filename!"
As a computer, I find your faith in technology amusing.
Southern DOS: Y'all reckon? (Yep/Nope)?
Backups? We don' *NEED* no steenking backups.
File not found. Should I fake it? (Y/N)?
Ethernet (n): something used to catch the etherbunny
A mainframe: The biggest PC peripheral available.
An error? Impossible! My modem is error correcting.
CONGRESS.SYS Corrupted: Re-boot Washington D.C (Y/N)?
Does fuzzy logic tickle?
A computer's attention span is as long as it's power cord.
11th commandment - Covet not thy neighbor's Pentium.
24 hours in a day...24 beers in a case...coincidence?
Disinformation is not as good as datinformation.
Windows: Just another pane in the glass.
SENILE.COM found . . . Out Of Memory . . .
Who's General Failure & why's he reading my disk?
Ultimate office automation: networked coffee.
All computers wait at the same speed.
DEFINITION: Computer - A device designed to speed and automate errors.
Smash forehead on keyboard to continue.....
Enter any 11-digit prime number to continue...
ASCII stupid question, get a stupid ANSI!
E-mail returned to sender -- insufficient voltage.
DOS Tip #17: Add DEVICE=FNGRCROS.SYS to CONFIG.SYS
Hidden DOS secret: add BUGS=OFF to your CONFIG.SYS
Press any key... no, no, no, NOT THAT ONE!
Press any key to continue or any other key to quit...
Excuse me for butting in, but I'm interrupt-driven.
REALITY.SYS corrupted: Reboot universe? (Y/N/Q)?
Error reading FAT record: Try the SKINNY one? (Y/N)?
Read my chips: No new upgrades!
Hit any user to continue.
I hit the CTRL key but I'm still not in control!
Will the information superhighway have any rest stops?
Disk Full - Press F1 to belch.
Backup not found: (A)bort (R)etry (T)hrowup
Backup not found: (A)bort (R)etry (P)anic
(A)bort, (R)etry, (T)ake down entire network?
(A)bort, (R)etry, (G)et a beer?
If debugging is the process of removing bugs, then programming must be the process of putting them in.
Last edited by Plaka on Tue Nov 14, 2006 9:38 pm, edited 1 time in total.
Plaka
New member
 
Posts: 6
Joined: Tue Nov 14, 2006 6:05 am
Location: Greece
Top


Post a reply
10 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 9 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