brenbot create custom messages [message #466239] |
Mon, 16 April 2012 12:04 |
robbyke
Messages: 348 Registered: September 2010 Location: Belgium
Karma: 0
|
Recruit |
|
|
id like to have my server report stuff to irc with the help of a brenbot plugin but i have not even slightest clue how id do that.
i can do the code messages in c++ but how can i make brenbot react to those.
id like to make it like the ssgm logging
Owner of kambot TT server
kambot.freeforums.org
|
|
|
|
Re: brenbot create custom messages [message #466243 is a reply to message #466239] |
Mon, 16 April 2012 14:10 |
robbyke
Messages: 348 Registered: September 2010 Location: Belgium
Karma: 0
|
Recruit |
|
|
thanks exactly what i need to get started
i dont get this $1 and $2 stuff what does they mean how do i know what they can contain?
sub iranstuff
{
my ( $kernel, $session, $heap, $args ) = @_[ KERNEL, SESSION, HEAP, ARG0 ];
my %args = %{$args};
my $line = $args->{'line'};
if ($line =~ m/^\[IRANSTUFF\](.+)$/)
{
my $msg;
my $prefix;
if ( $1 =~ m/^\[(.+)\](.+)/ ) {$prefix = $1; $msg = $2;}
$prefix = "09[04$prefix09]09 ";
plugin::ircmsg ( $prefix . $msg , "A" );
}
}
ah i got something thats good enough for me thanks alot
Owner of kambot TT server
kambot.freeforums.org
[Updated on: Tue, 17 April 2012 08:48] Report message to a moderator
|
|
|
|
Re: brenbot create custom messages [message #466304 is a reply to message #466272] |
Tue, 17 April 2012 15:27 |
robbyke
Messages: 348 Registered: September 2010 Location: Belgium
Karma: 0
|
Recruit |
|
|
danpaul88 wrote on Tue, 17 April 2012 21:38 | $1, $2, ..., $n are populated with capture groups from the preceding regular expression in the current scope.
|
thats literaly chinese to me XD
what i think you mean :
that the $1,$2.... are "variables" filled with date from this line:
if ($line =~ m/^\[IRANSTUFF\](.+)$/)
so if im correct this divided the text into multiple pieces??
Owner of kambot TT server
kambot.freeforums.org
|
|
|
Re: brenbot create custom messages [message #466354 is a reply to message #466239] |
Thu, 19 April 2012 00:29 |
|
danpaul88
Messages: 5795 Registered: June 2004 Location: England
Karma: 0
|
General (5 Stars) |
|
|
In that specific example, yes. Each set of () in the regex is a capture group, allowing you to extract the part of the match that occurred within them. They can also be nested, which can be confusing when it comes to working out the number to use for $n to get the value you wanted in very complicated regexes.
Also the example shown is inefficient, it would be more efficiently written as follows;
sub iranstuff
{
my %args = %{$_[ ARG0 ]};
if ( $args{'line'} =~ m/^\[IRANSTUFF\]\[(.+)\](.+)$/ )
{
my $prefix = "09[04$109]09 ";
plugin::ircmsg ( $prefix . $2 , "A" );
}
}
(NB: off the top of my head so it might need tweaking to compile but you get the idea One regex to do the lot.)
[Updated on: Thu, 19 April 2012 00:41] Report message to a moderator
|
|
|
Re: brenbot create custom messages [message #466356 is a reply to message #466239] |
Thu, 19 April 2012 03:34 |
robbyke
Messages: 348 Registered: September 2010 Location: Belgium
Karma: 0
|
Recruit |
|
|
this language is really complicated im happy with what i achieved. I wont be doing alot with brenbot atm
maybe later but ill ask questions when i do that ^^
Owner of kambot TT server
kambot.freeforums.org
|
|
|
|
|
|