Help with addon

Discussion about Perl, TCL or Python scripts and C/C++ plugins (using and writing them).

Help with addon

Postby err0r » 19 Aug 2009 02:01

My users are using a chat that has style tags in the messages. I would like to strip them out of the text completely

There are times when there are multiple instances of style tags in one message. Using regex this should be pretty simple to accomplish but I'm more fluent in mIRC scripting and am a bit n00b to xchat and it's snippets

a sample output would be

err0r: [style ff:Comic Sans MS;co:#4682B4;b;u;]Test would go here[/style]

The output needs to be

err0r: Test would go here

the ff co b and u will all be dynamic.

Any help would be greatly appreciated.
err0r
 
Posts: 2
Joined: 19 Aug 2009 01:55

Postby LifeIsPain » 19 Aug 2009 09:39

Save the following as stripstyle.pl in your xchat profile directory and load it. This may be a bit greedy, as it doesn't look specifically for some of the keywords you mentioned, cause there may be more.

Code: Select all
use Xchat qw(:all);
use strict;
use warnings;

register('Strip Style', '001', 'Strip [style][/style] tags');

hook_server('PRIVMSG', sub {
   my $instring = $_[1][0];
   my $edited = 0;
   # using a while loop instead of /g due to embedded styles
   while ($instring =~ s/\[style [^\]]*\](.*?)\[\/style\]/$1/i) {
      $edited = 1;
   }
   if ($edited) {
      command('recv '.$instring);
      return EAT_ALL;
   }
   else {
      return EAT_NONE;
   }
});
User avatar
LifeIsPain
 
Posts: 490
Joined: 25 Aug 2005 06:36

thanks

Postby err0r » 19 Aug 2009 20:31

thank you very much, i really appreciate the help.
err0r
 
Posts: 2
Joined: 19 Aug 2009 01:55


Return to Scripts and Plugins

Who is online

Users browsing this forum: No registered users and 2 guests