collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: !Beer Module as a CRON  (Read 16316 times)

0 Members and 1 Guest are viewing this topic.

Offline TSF000

  • BeBot Rookie
  • *
  • Posts: 6
  • Karma: +0/-0
!Beer Module as a CRON
« on: January 10, 2015, 07:32:49 pm »
Good day,

I am trying to run the beer module as a cron function by combining these two scripts of possible:

The cron module:

Code: [Select]
<?php
/*
* cron.php - Module template.
* Cron module - <module description>
* <Copyright notice for your module>
*
* BeBot - An Anarchy Online & Age of Conan Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Copyright (C) 2005-2007 Thomas Juberg StensÃ¥s, ShadowRealm Creations and the BeBot development team.
*
* Developed by:
* - Alreadythere (RK2)
* - Blondengy (RK1)
* - Blueeagl3 (RK1)
* - Glarawyn (RK1)
* - Khalem (RK1)
* - Naturalistic (RK1)
* - Temar (RK1)
*
* See Credits file for all aknowledgements.
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; version 2 of the License only.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*  USA
*
* File last changed at $LastChangedDate: 2008-11-30 23:09:06 +0100 (Sun, 30 Nov 2008) $
* Revision: $Id: _ExampleModule.php 1833 2008-11-30 22:09:06Z alreadythere $
*/

/*
Add a "_" at the beginning of the file (_ClassName.php) if you do not want it to be loaded.
*/

$thisClass = new cron($bot);

/*
The Class itself...
*/
class cron extends BaseActiveModule
{

   function 
__construct (&$bot)
   {
      
//Initialize the base module
      
parent::__construct(&$botget_class($this));


      
$this->register_event('cron''20min');


   }


   
/*
   Unified message handler
   $source: The originating player
   $msg: The actual message, including command prefix and all
   $type: The channel the message arrived from. This can be either "tell", "pgmsg" or "gc"
   */
   
function command_handler($source$msg$origin)
   {
      
//ALWAYS reset the error handler before parsing the commands to prevent stale errors from giving false reports
      
$this->error->reset();

      
//The default is to split the command to com, sub and args. If you want to split it some other way change the pattern for it
      //parse_com() returns an array where the pattern is the keys and the values are split out from $msg
      
$com $this->parse_com($msg, array('com''sub''args'));

      
$command $vars[0];

      switch(
$com['com'])
      {
         case 
'command1':
            return(
$this -> somefunction($name$com));
            break;
         case 
'command2':
            return(
$this -> someotherfunction($name$com));
         default:
            
// Just a safety net to allow you to catch errors where a module has registered  a command, but fails to actually do anything about it
            
$this -> error -> set("Broken plugin, recieved unhandled command: $command");
            return(
$this->error->message());
      }
   }

   
/*
   This gets called on cron  if you previously registered the event 'cron, interval'
   $interval is the string name for the time delay between two cron jobs.
   */
   
function cron($interval)
   {
$this -> bot -> send_gc ("Whats up guildies?");
   }


}
?>



And the beer module:

Code: [Select]
<?
/*
 * Beer - A Social Module
 * For BeBot - An Anarchy Online/Age of Conan Chat Automaton Developed by Blondengy (RK1) (beer.php)
 * Copyright (C) 2004 Jonas Jax
 * Rewrite and quote gathering by Wood of Exalted (Aquilonia EU)
 * Memory handling Improved Code by Temar
 *
 *
 * As usual place this file in ./modules
 */

/*
Add a "_" at the beginning of the file (_beer.php) if you do not want it to be loaded.
*/

$beer = new beer($bot);

/*
The Class itself...
*/
class beer Extends BaseActiveModule
{
/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function __construct (&$bot)
{
parent::__construct(&$bot, get_class($this));

$this -> register_command('all', 'beer', 'GUEST');

$help['description'] = "Quotes about beer.";
}

/*
This function handles all the inputs and returns output
sutible for send_tell, send_pgroup, and send_gc.
*/
function command_handler($name, $msg, $origin)
{
$this->error->reset(); //Reset the error message so we don't trigger the handler by old error messages.

return $this -> get_beers($name);
}

    /*
      Constructor:
        Hands over a referance to the "Bot" class.
    */
/*
Build response
*/
    function get_beers($name)
    {
        $beer_quotes[] = "I am a firm believer in the people. If given the truth, they can be depended upon to meet any national crisis. The great point is to bring them the real facts, and beer. - Abraham Lincoln";
        $beer_quotes[] = "24 hours in a day, 24 beers in a case. Coincidence? - Stephen Wright";
        $beer_quotes[] = "One of the hallmarks of the baby boomer generation is that it doesn't live like the previous generation. It hasn't yet given up jeans and T-shirts or beer. - Ron Klugman, SVP, Coors Brewing";
        $beer_quotes[] = "Beer is proof that God loves us and wants us to be happy. - Benjamin Franklin";
        $beer_quotes[] = "The roots and herbs beaten and put into new ale or beer and daily drunk, cleareth, strengthen and quicken the sight of the eyes. - Nicholas Culpeper";
        $beer_quotes[] = "Without question, the greatest invention in the history of mankind is beer. Oh, I grant you the wheel was also a fine invention, but the wheel does not go nearly as well with pizza. - Dave Barry";
        $beer_quotes[] = "[I recommend]...bread, meat, vegetables and beer. - Sophocles' philosophy of a moderate diet";
        $beer_quotes[] = "Alright brain, I don't like you and you don't like me, so just get me through this exam so I can go back to killing you slowly with beer. - Homer Simpson";
        $beer_quotes[] = "Oh, lager beer! It makes good cheer, And proves the poor man's worth; It cools the body through and through, and regulates the health. - Anonymous";
        $beer_quotes[] = "Sometimes when I reflect back on all the beer I drink I feel ashamed. Then I look into the glass and think about the workers in the brewery and all of their hopes and dreams. If I didn't drink this beer, they might be out of work and their dreams would be shattered. Then I say to myself, 'It is better that I drink this beer and let their dreams come true than be selfish and worry about my liver.' - Jack Handy";
        $beer_quotes[] = "Not all chemicals are bad. Without chemicals such as hydrogen and oxygen, for example, there would be no way to make water, a vital ingredient in beer. - Dave Barry";
        $beer_quotes[] = "I would give all my fame for a pot of ale and safety. - Shakespeare, Henry V";
        $beer_quotes[] = "Make sure that the beer - four pints a week - goes to the troops under fire before any of the parties in the rear get a drop. - Winston Churchill to his Secretary of War, 1944";
        $beer_quotes[] = "We old folks have to find our cushions and pillows in our tankards. Strong beer is the milk of the old. - Martin Luther";
        $beer_quotes[] = "Beer will always have a definite role in the diet of an individual and can be considered a cog in the wheel of nutritional foods. - Bruce Carlton";
        $beer_quotes[] = "No soldier can fight unless he is properly fed on beef and beer. - John Churchill, First Duke of Marlborough";
        $beer_quotes[] = "An oppressive government is more to be feared than a tiger, or a beer. - Confucius";
        $beer_quotes[] = "If God had intended us to drink beer, He would have given us stomachs. - David Daye";
        $beer_quotes[] = "He was a wise man who invented beer. - Plato";
        $beer_quotes[] = "This is grain, which any fool can eat, but for which the Lord intended a more divine means of consumption... Beer! - Robin Hood, Prince of Thieves, Friar Tuck";
        $beer_quotes[] = "Beer: So much more than just a breakfast drink. - Whitstran Brewery sign";
        $beer_quotes[] = "I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day. - Frank Sinatra";
        $beer_quotes[] = "When I read about the evils of drinking, I gave up reading. - Henny Youngman";
        $beer_quotes[] = "When we drink, we get drunk. When we get drunk, we fall asleep. When we fall asleep, we commit no sin. When we commit no sin, we go to heaven. Sooooo, let's all get drunk and go to heaven! - Brian O'Rourke";
        $beer_quotes[] = "BEER: HELPING UGLY PEOPLE HAVE SEX SINCE 3000 B.C.! - Unknown";
        $beer_quotes[] = "To some it's a six-pack, to me it's a Support Group. Salvation in a can!";
        $beer_quotes[] = "The problem with the world is that everyone is a few drinks behind. - Humphrey Bogart";
        $beer_quotes[] = "Everybody has to believe in something.....I believe I'll have another drink. - W.C. Fields";
        $beer_quotes[] = "You're not drunk if you can lie on the floor without holding on. - Dean Martin";
        $beer_quotes[] = "God made pot. Man made beer. Who do you trust? - Restroom in The Irish Times, Washington DC";
        $beer_quotes[] = "You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer. - Frank Zappa";
        $beer_quotes[] = "24 hours in a day, 24 beers in a case. Coincidence? - Stephen Wright";
        $beer_quotes[] = "One of the hallmarks of the baby boomer generation is that it doesn't live like the previous generation. It hasn't yet given up jeans and T-shirts or beer. - Ron Klugman, SVP, Coors Brewing";
        $beer_quotes[] = "Beer is proof that God loves us and wants us to be happy. - Benjamin Franklin";
        $beer_quotes[] = "The roots and herbs beaten and put into new ale or beer and daily drunk, cleareth, strengthen and quicken the sight of the eyes. - Nicholas Culpeper";
        $beer_quotes[] = "Without question, the greatest invention in the history of mankind is beer. Oh, I grant you the wheel was also a fine invention, but the wheel does not go nearly as well with pizza. - Dave Barry";
        $beer_quotes[] = "[I recommend]...bread, meat, vegetables and beer. - Sophocles' philosophy of a moderate diet";
        $beer_quotes[] = "Alright brain, I don't like you and you don't like me, so just get me through this exam so I can go back to killing you slowly with beer. - Homer Simpson";
        $beer_quotes[] = "Oh, lager beer! It makes good cheer, And proves the poor man's worth; It cools the body through and through, and regulates the health. - Anonymous";
        $beer_quotes[] = "Sometimes when I reflect back on all the beer I drink I feel ashamed. Then I look into the glass and think about the workers in the brewery and all of their hopes and dreams. If I didn't drink this beer, they might be out of work and their dreams would be shattered. Then I say to myself, 'It is better that I drink this beer and let their dreams come true than be selfish and worry about my liver.' - Jack Handy";
        $beer_quotes[] = "Not all chemicals are bad. Without chemicals such as hydrogen and oxygen, for example, there would be no way to make water, a vital ingredient in beer. - Dave Barry";
        $beer_quotes[] = "I would give all my fame for a pot of ale and safety. - Shakespeare, Henry V";
        $beer_quotes[] = "Make sure that the beer - four pints a week - goes to the troops under fire before any of the parties in the rear get a drop. - Winston Churchill to his Secretary of War, 1944";
$beer_quotes[] = "I am a firm believer in the people. If given the truth, they can be depended upon to meet any national crisis. The great point is to bring them the real facts, and beer. - Abraham Lincoln";
        $beer_quotes[] = "24 hours in a day, 24 beers in a case. Coincidence? - Stephen Wright";
        $beer_quotes[] = "One of the hallmarks of the baby boomer generation is that it doesn't live like the previous generation. It hasn't yet given up jeans and T-shirts or beer. - Ron Klugman, SVP, Coors Brewing";
return $beer_quotes[rand(0,sizeof($beer_quotes)-1)];
    }
}
?>


Any ideas?

Note: I take no credit for the scripts, they all belongs to their respected authers.

Thanks,


 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 262
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal