mirc script "on text" to xchat help?

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

mirc script "on

Postby Pjevser » 25 Aug 2008 00:03

In xchat if you install xsys script you can use /netsteam eth0 to watch bandwidth.

i want to make this mirc script to work in xchat, can anyone help?

on 1:text:!bandwidth:*:{
if ($nick == MYNICK) {
msg $chan /netstream eth0
}
}

So, when i write !bandwidth on a channel, my box should reply back with /netstream eth0 and show my bandwidth.

So can anyone help make it? :)
Pjevser
 
Posts: 6
Joined: 24 Aug 2008 23:57

Postby Rebel_n00b » 26 Aug 2008 15:10

Hello, try using the following code.

Code: Select all
use strict;

Xchat::register('BandWidth','0.1','Displays current bandwidth on !bandwidth');

Xchat::hook_print('Your Message',\&BandWidth);

sub BandWidth {
   if ($_[1] =~ /^bandwidth$/i) {
      Xchat::command('netstream eth0');
   }
   return Xchat::EAT_NONE;
}


Untested but it should work.
Rebel_n00b
 
Posts: 2
Joined: 19 Aug 2008 05:03

Postby Pjevser » 27 Aug 2008 13:41

I have loaded the script on my box, but when i go to my home pc and type !bandwidth nothnig happens :cry:
Last edited by Pjevser on 27 Aug 2008 15:49, edited 1 time in total.
Pjevser
 
Posts: 6
Joined: 24 Aug 2008 23:57

Postby Khisanth » 27 Aug 2008 14:08

Pjevser wrote:I have loaded the script on my box, but when i go to my home pc and type !bancwidth nothnig happens :cry:


Add the ! to this line if ($_[1] =~ /^bandwidth$/i) {
Khisanth
 
Posts: 1724
Joined: 10 Jun 2004 05:23

Postby Pjevser » 27 Aug 2008 22:13

Khisanth wrote:
Pjevser wrote:I have loaded the script on my box, but when i go to my home pc and type !bancwidth nothnig happens :cry:


Add the ! to this line if ($_[1] =~ /^bandwidth$/i) {


if ($_[1] =~ /^!bandwidth$/i) {

Like this?? Because it wont work.
Pjevser
 
Posts: 6
Joined: 24 Aug 2008 23:57

Postby Khisanth » 27 Aug 2008 23:58

Oops should be if ($_[0][1] =~ /^bandwidth$/i) {
didn't notice the $_[1]

However this might not be what you want, if that turns out to be the case you probably want this
Code: Select all
use strict;

Xchat::register('BandWidth','0.1','Displays current bandwidth on !bandwidth');

Xchat::hook_print('Channel Message',\&BandWidth);

sub BandWidth {
   if ( $_[0][0] eq 'YOUR_NICK' && $_[0][1] =~ /^!bandwidth$/i) {
      Xchat::command('netstream eth0');
   }
   return Xchat::EAT_NONE;
}


This version assumes you are on two different computers and you type !bandwidth on the second computer while using the nick YOUR_NICK
Khisanth
 
Posts: 1724
Joined: 10 Jun 2004 05:23

Postby Pjevser » 28 Aug 2008 00:42

Khisanth wrote:Oops should be if ($_[0][1] =~ /^bandwidth$/i) {
didn't notice the $_[1]

However this might not be what you want, if that turns out to be the case you probably want this
Code: Select all
use strict;

Xchat::register('BandWidth','0.1','Displays current bandwidth on !bandwidth');

Xchat::hook_print('Channel Message',\&BandWidth);

sub BandWidth {
   if ( $_[0][0] eq 'YOUR_NICK' && $_[0][1] =~ /^!bandwidth$/i) {
      Xchat::command('netstream eth0');
   }
   return Xchat::EAT_NONE;
}


This version assumes you are on two different computers and you type !bandwidth on the second computer while using the nick YOUR_NICK


Are you sure it's working?

I changed YOUR_NICK to my nick, but nothing happens.
Pjevser
 
Posts: 6
Joined: 24 Aug 2008 23:57

Postby LifeIsPain » 28 Aug 2008 03:33

From my memory of mIRC script (it has been a while), you want to run the netstream command if you, and only you, type !bandwidth in a channel or query window. For that, the variation of the above would be:
Code: Select all
use strict;

Xchat::register('BandWidth','0.2','Displays current bandwidth on !bandwidth');

Xchat::hook_print('Your Message',\&BandWidth);

sub BandWidth {
   if ( $_[0][1] =~ /^!bandwidth$/i) {
      Xchat::command('netstream eth0');
   }
   return Xchat::EAT_NONE;
}


You would never show up in a "Channel Message" event (unless you are on a bouncer, and the other client on the bouncer types !bandwidth), so it should be Your Message. Not Tested, and I don't have have netstream, but should be it.
User avatar
LifeIsPain
 
Posts: 522
Joined: 25 Aug 2005 06:36

Postby Pjevser » 28 Aug 2008 09:33

LifeIsPain wrote:From my memory of mIRC script (it has been a while), you want to run the netstream command if you, and only you, type !bandwidth in a channel or query window. For that, the variation of the above would be:
Code: Select all
use strict;

Xchat::register('BandWidth','0.2','Displays current bandwidth on !bandwidth');

Xchat::hook_print('Your Message',\&BandWidth);

sub BandWidth {
   if ( $_[0][1] =~ /^!bandwidth$/i) {
      Xchat::command('netstream eth0');
   }
   return Xchat::EAT_NONE;
}


You would never show up in a "Channel Message" event (unless you are on a bouncer, and the other client on the bouncer types !bandwidth), so it should be Your Message. Not Tested, and I don't have have netstream, but should be it.


That wont work either.

nothing happens when i type !bandwidth.

EDIT: Just found out when i type !bandwidth from my box where the script is actually loaded it works. But that's not now it should work. :cry:

I want it to work so when i type !bandwidth from my OTHER pc and not my box, it should reply back from my box. So actually it should work with "Channel Message"?? But it wont. :-(
Pjevser
 
Posts: 6
Joined: 24 Aug 2008 23:57

Postby Khisanth » 28 Aug 2008 14:44

Pjevser wrote:
Khisanth wrote:Oops should be if ($_[0][1] =~ /^bandwidth$/i) {
didn't notice the $_[1]

However this might not be what you want, if that turns out to be the case you probably want this
Code: Select all
use strict;

Xchat::register('BandWidth','0.1','Displays current bandwidth on !bandwidth');

Xchat::hook_print('Channel Message',\&BandWidth);

sub BandWidth {
   if ( $_[0][0] eq 'YOUR_NICK' && $_[0][1] =~ /^!bandwidth$/i) {
      Xchat::command('netstream eth0');
   }
   return Xchat::EAT_NONE;
}


This version assumes you are on two different computers and you type !bandwidth on the second computer while using the nick YOUR_NICK


Are you sure it's working?

I changed YOUR_NICK to my nick, but nothing happens.


When you replaced YOUR_NICK did you replace it with the nick you are using on the second computer?
Khisanth
 
Posts: 1724
Joined: 10 Jun 2004 05:23

Postby Pjevser » 28 Aug 2008 15:10

I load the script on lets say NICK1, then i type NICK2 in YOUR_NICK.

And when NICK2 type !bandwidth nothing happens.
Pjevser
 
Posts: 6
Joined: 24 Aug 2008 23:57

Postby LifeIsPain » 28 Aug 2008 15:54

Khisanth's script (as it is) is case sensitive for the nick, and may have problems if your client has Colored Nicks turned on (Preferences -> Text Box -> Colored nick names). To avoid both of these issues, use the following line:
Code: Select all
if ( Xchat::nickcmp(Xchat::strip_code($_[0][0]), 'YOUR_NICK') == 0 && $_[0][1] =~ /^!bandwidth$/i) {
User avatar
LifeIsPain
 
Posts: 522
Joined: 25 Aug 2005 06:36


Return to Scripts and Plugins

Who is online

Users browsing this forum: No registered users and 0 guests