Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » brenbot create custom messages
brenbot create custom messages [message #466239] Mon, 16 April 2012 12:04 Go to next message
robbyke is currently offline  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 #466240 is a reply to message #466239] Mon, 16 April 2012 13:07 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
pretty simple take a look at:

http://www.renegadeforums.com/index.php?t=msg&th=39118&start=0&rid=2 5967

shows how to do it


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: brenbot create custom messages [message #466243 is a reply to message #466239] Mon, 16 April 2012 14:10 Go to previous messageGo to next message
robbyke is currently offline  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 #466272 is a reply to message #466239] Tue, 17 April 2012 12:38 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
$1, $2, ..., $n are populated with capture groups from the preceding regular expression in the current scope.

http://steamsignature.com/card/1/76561197975867233.png
Re: brenbot create custom messages [message #466304 is a reply to message #466272] Tue, 17 April 2012 15:27 Go to previous messageGo to next message
robbyke is currently offline  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 Go to previous messageGo to next message
danpaul88 is currently offline  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 Smile One regex to do the lot.)


http://steamsignature.com/card/1/76561197975867233.png

[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 Go to previous messageGo to next message
robbyke is currently offline  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
Re: brenbot create custom messages [message #466367 is a reply to message #466239] Thu, 19 April 2012 08:18 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Perl is quite straightforward compared to some programming languages Razz

http://steamsignature.com/card/1/76561197975867233.png
Re: brenbot create custom messages [message #466375 is a reply to message #466239] Thu, 19 April 2012 08:51 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
perl is a pile of shit

Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: brenbot create custom messages [message #466377 is a reply to message #466239] Thu, 19 April 2012 08:56 Go to previous message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Yes, it is that too, but it's a straightforward pile of shit Rocked Over


To be fair, it does do an extremely good job of regular expressions and other textual manipulation, which is a lot of what Renegade bots do. Still, it wouldn't have been my first choice for a server regulator bot.


http://steamsignature.com/card/1/76561197975867233.png
Previous Topic: Mapping Textures + Trees.
Next Topic: timers little question
Goto Forum:
  


Current Time: Sat Dec 21 09:40:02 MST 2024

Total time taken to generate the page: 0.00817 seconds