BeBot - An Anarchy Online and Age Of Conan chat automaton

Development => Generic custom modules => Topic started by: screwy on July 23, 2009, 06:33:32 pm

Title: Colorize Text
Post by: screwy on July 23, 2009, 06:33:32 pm
Hey,

This is a basic module that will echo text into the org chat colorized. "Useful" for things like "Gratz", "Happy Birthday" etc.

Screwy.

Code: [Select]
<?
/*
 * Colorize
 * Copyright (C) 2009 Screwy (RK1)
 */

$colorize= new colorize($bot);

class colorize Extends BaseActiveModule
{
function __construct (&$bot)
{
parent::__construct(&$bot, get_class($this));

$this -> register_command('all', 'colorize', 'GUEST');
$this -> help['description'] = 'Randomly colorizes some text, written by Screwy (Rk1)';
$this -> help['command']['colorize']="Colorizes the text and prints it out.";
$this -> help['notes'] = "This module has no settings.";

}

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_colorize($name, substr($msg, 9));
}

  function get_colorize($who, $name)
  {

for ($i=0; $i <= strlen($name); $i++){

$RI=dechex(rand(0,255));
$GI=dechex(rand(0,255));
$BI=dechex(rand(0,255));
$COLOR="#".$RI.$GI.$BI;

    $COLORIZED .= "<font color=\"".$COLOR."\">".mb_substr($name, $i, 1)."</font>";

    }
    $this -> bot -> send_gc("($who) " .$COLORIZED);
}
}
?>
Title: Re: Colorize Text
Post by: fowlskins on March 05, 2010, 09:17:41 pm
for some reason this module crashes my bot and logs me out of the game on using !colorize
is there any other mod similar to this about or can anyone see if its outdated code or contains errors or whatever ?
Title: Re: Colorize Text
Post by: Kyr on March 06, 2010, 01:43:00 am
Been using this for awhile now and having no problems.  I use it in conjunction with the comalias command and have a whole list of shortcuts to colorized messages people can use.
 
Code: [Select]
grats is an alias of colorize GRATZ!. [DELETE]
brc is an alias of scripts howtogetkeyedforBRC. [DELETE]
gratz is an alias of colorize GRATZ!. [DELETE]
wb is an alias of colorize Welcome Back!. [DELETE]
lol is an alias of colorize Laughing Out Loud. [DELETE]
woot is an alias of colorize w00t!!!!111111eleven. [DELETE]
hi is an alias of colorize HELLO. [DELETE]
yw is an alias of colorize You're Welcome!. [DELETE]
dead is an alias of colorize I SEE DEAD PEOPLE. [DELETE]
bye is an alias of colorize Good Bye. [DELETE]
ty is an alias of colorize Thank You!!!. [DELETE]
bbl is an alias of colorize Be Back Later!!!. [DELETE]
crafting is an alias of scripts Crafting/crafting. [DELETE]
kyr is an alias of colorize Kyr is a n00b!. [DELETE]
tyree is an alias of colorize Tyree is a nerd!. [DELETE]
attr is an alias of attribute. [DELETE]
nerd is an alias of colorize Nerds are HAWT!!!. [DELETE]
brains is an alias of colorize BRAIIIIINNZZZZ!!!!!!!1111111eleveneleven. [DELETE]
noob is an alias of colorize YOU r a n00b!!!!. [DELETE]
vn is an alias of colorize Very Nice!!!!. [DELETE]
wtg is an alias of colorize Way to go!. [DELETE]
hh is an alias of colorize Happy Holidays!. [DELETE]
mc is an alias of colorize Merry Christmas!. [DELETE]
hq is an alias of colorize Happy Quanza!. [DELETE]
kaige is an alias of colorize It's all Kaige's fault!!!. [DELETE]
x is an alias of colorize Invite to me the raid already you muther fukin' ho Kaige.. [DELETE]
y is an alias of colorize [Guild] [Kaige]: ACCEPT MY DAMN IVVITES. [DELETE]
z is an alias of colorize [Guild] [Kaige]: AM I MISSING ANYONE FOR THE RAID?????????????????. [DELETE]
spitty is an alias of colorize If it isn't Kaige's fault, its Spitty's fault.. [DELETE]
level is an alias of colorize It's a Levelpalooza!!!. [DELETE]
r is an alias of colorize I'm ready already, start this thing!. [DELETE]
hb is an alias of colorize Happy Birthday!!!!!!!!! w0w you are awesome....... [DELETE]
invite is an alias of colorize INVITE MEH DAMMIT!!!. [DELETE]
welcome is an alias of colorize Welcome to Unforgiven (please sign up on the website asap -- http://unforgivenknights.guildlaunch.com/). [DELETE]
nm is an alias of colorize nevermind. [DELETE]
Title: Re: Colorize Text
Post by: fowlskins on March 07, 2010, 08:34:17 pm
thought id give it another go with others in guild using the command
as soon as !colorize is typed by anyone it crashes my bot and consiquently logs me out of game as well when it trys to reconect
Title: Re: Colorize Text
Post by: Khalem on March 07, 2010, 10:59:42 pm
The actual error recieved would be useful to determine what the issue is.
Title: Re: Colorize Text
Post by: fowlskins on March 08, 2010, 05:25:45 pm
yeah that probaly would help wouldnt it  :D

ill reinstall it and see what the error message actualy is
Title: Re: Colorize Text
Post by: fowlskins on March 08, 2010, 08:06:19 pm
Fatal error: Call to undefined function mb_substr() in C:\bebot\custom\modules\c
olorize.php on line 38
 
ok thats the error message i get
Title: Re: Colorize Text
Post by: Kyr on March 09, 2010, 12:13:35 am
Change line 38 to:
Code: [Select]
$COLORIZED .= "<font color=\"".$COLOR."\">".substr($name, $i, 1)."</font>";
and change line 25 to:
Code: [Select]
return $this -> get_colorize($name, substr($msg, 9));
Title: Re: Colorize Text
Post by: fowlskins on March 09, 2010, 07:07:20 pm
thankyou kyr thats got it working   ;D
does it always randomly color each letter of the word ??
in my head it would randomly do a whole sentance one color
but thats just me being picky its not a big deal

cheers for your help
Title: Re: Colorize Text
Post by: Kaitoujeanne on April 18, 2010, 10:31:40 pm
I copied the code into new a php document and called it colorize.php and added into the \custom\modules and restarted the bot and it shows it loaded and it does show up in the !help and !commands list but when I type !colorize test into the game-chat it doesn't color it or do anything, it just says exactly what I type.
Am i missing something? I did change lines 25 + 38 so it doesn't crash the bot since it did at first but now it doesn't want to do anything.
Title: Re: Colorize Text
Post by: Kyr on April 19, 2010, 12:56:06 am
My guess is that you changed it wrong, can you give a screen shot of the output and/or a listing of your code?

~Kyr
Title: Re: Colorize Text
Post by: Kaitoujeanne on April 19, 2010, 02:45:10 am
Code: [Select]
<?
/*
 * Colorize
 * Copyright (C) 2009 Screwy (RK1)
 */

$colorize= new colorize($bot);

class colorize Extends BaseActiveModule
{
   function __construct (&$bot)
   {
      parent::__construct(&$bot, get_class($this));

      $this -> register_command('all', 'colorize', 'GUEST');
      $this -> help['description'] = 'Randomly colorizes some text, written by Screwy (Rk1)';
      $this -> help['command']['colorize']="Colorizes the text and prints it out.";
      $this -> help['notes'] = "This module has no settings.";

   }
   
   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_colorize($name, substr($msg, 9));
   }

  function get_colorize($who, $name)
  {
   
      for ($i=0; $i <= strlen($name); $i++){

      $RI=dechex(rand(0,255));
      $GI=dechex(rand(0,255));
      $BI=dechex(rand(0,255));
      $COLOR="#".$RI.$GI.$BI;

    $COLORIZED .= "<font color=\"".$COLOR."\">".substr($name, $i, 1)."</font>";
   
    }
    $this -> bot -> send_gc("($who) " .$COLORIZED);
}
}
?>

This is a Copy and Paste of the Module. When i type !colorize Test in the gamechat it gives no error or no messages, it just comes back as regular text.
Title: Re: Colorize Text
Post by: Kaitoujeanne on April 22, 2010, 01:35:00 am
Got problem fixed by Khal !
Title: Re: Colorize Text
Post by: Kyr on April 22, 2010, 02:03:13 am
Could you post the solution so that others with the same problem can solve it quicker?
Title: Re: Colorize Text
Post by: Kaitoujeanne on April 22, 2010, 06:33:59 am
This line towards bottom

    $this -> bot -> send_gc("($who) " .$COLORIZED);

I had to change it to send_pgroup since we use it as a Raid bot where you join the channel, not as a Guildchat bot so it wasn't coming through correctly. So only a solution if you're using it as a private chat instead of Guildchat.
SimplePortal 2.3.7 © 2008-2024, SimplePortal