mIRC Home    About    Download    Register    News    Help

Print Thread
#220562 18/04/10 07:16 AM
Joined: Jul 2008
Posts: 57
R
RiMaJoy Offline OP
Babel fish
OP Offline
Babel fish
R
Joined: Jul 2008
Posts: 57
I use this in my respond script:
Code:
var %nicknum = $nick($chan,0) 
    var %nick1 = 1 
    while (%nicknum >= %nick1) { 
      if ($nick($chan,%nick1) isin $strip($2-)) {  
        var %nicklijst = $+(%nicklijst,$chr(32),$nick($chan,%nick1))
      } 
      inc %nick1 
    } 


I can't get it so that if %nicklijst is more then 1 name those names are not sepperated by only a space but also with a &($chr38).
Some help would be nice.

another problem....
I'm not good at $regex so here is some code i use:
Code:
 if ($regex($1-,/(?<= |^)(?:i|me)(?= |$)/Si))

Somehow i need to use the name of the bot where the script is located in order to get it to work.
I want this to work too without use the bots name.

Greetings.......

Last edited by RiMaJoy; 18/04/10 08:12 AM.
RiMaJoy #220563 18/04/10 08:49 AM
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Do you want to use something like $addtok?

var %nicklijst = $addtok(%nicklijst,$+($chr(38),$nick($chan,%nick1)),32)

DJ_Sol #220602 19/04/10 06:55 PM
Joined: Jul 2008
Posts: 57
R
RiMaJoy Offline OP
Babel fish
OP Offline
Babel fish
R
Joined: Jul 2008
Posts: 57
not working it adds a & on the first name aswell

RiMaJoy #220603 19/04/10 09:50 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Why not replace the separating char $chr(32) with a "$chr(38)-and-space" after the loop
Code:
    while (%nicknum >= %nick1) { 
      if ($nick($chan,%nick1) isin $strip($2-)) {  
        var %nicklijst = $addtok(%nicklijst,$v1,32)
      } 
      inc %nick1 
    }
    var %nicklijst = $replace(%nicklijst,$chr(32),$+($chr(38),$chr(32)))

Quote:
Somehow i need to use the name of the bot where the script is located in order to get it to work.
I want this to work too without use the bots name.
I don't get this part. Can you please provide an example and show the piece of code that if-condition is a part of?

RiMaJoy #220606 19/04/10 10:33 PM
Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
using "isin" isnt a good idea
better to use $istok

bcz if your nick is bam and another is bamboo when u use isin that will confiuse the two nicks


WorldDMT
Horstl #220621 20/04/10 03:40 AM
Joined: Jul 2008
Posts: 57
R
RiMaJoy Offline OP
Babel fish
OP Offline
Babel fish
R
Joined: Jul 2008
Posts: 57
That does the job.
thanks

Horstl #220692 21/04/10 08:05 PM
Joined: Jul 2008
Posts: 57
R
RiMaJoy Offline OP
Babel fish
OP Offline
Babel fish
R
Joined: Jul 2008
Posts: 57
About the $regex Horstl:

I wanted the bot to respond different if i added me or I in the command like so:
Botname give nick1 and nick 2 a beer and one for me too.

At first I started the code like so because i wanted to be a barbot:
Code:
if (Botname == $strip($1)) { bla bla bla


Now i made it more like a respondbot aswell and so some of the code starts like this as well:
Code:
if (hello isin $strip($1-)) {  bla bla bla 


In the original code the botname was the trigger.
I dropped that part in the new code.
With the new code if i use this command:
Give nick1 and nick 2 a beer and one for me too.
It doesnt respond with the correct respond.
But if i change the command too:
Give nick1 and nick 2 a beer Botname and one for me too.
Then it responds correctly.
It doesn't matter where i put the botname.
My guess is the $regex is doing that.
Here is the code that i use original in full:
Code:
On 1:text:*beer*:#:{
  if (mIRCStats == $strip($1)) { 
    var %nicknum = $nick($chan,0) 
    var %nick1 = 1 
    while (%nicknum >= %nick1) { 
      if ($nick($chan,%nick1) isin $strip($2-)) {  
        var %nicklijst = $addtok(%nicklijst,$v1,32)
      } 
      inc %nick1 
    }
    var %nicklijst = $replace(%nicklijst,$chr(32),$+($chr(32),$chr(38),$chr(32)))
    if (%nicklijst) {
      if ($regex($1-,/(?<= |^)(?:i|me)(?= |$)/Si)) { 
        .timer 1 2 $read($scriptdir\drinken\beerme.txt,t) 
      }
      else {
        .timer 1 2 $read($scriptdir\drinken\beerlist.txt,t) 
      }
    }
    else { 
      .timer 1 1 $read($scriptdir\drinken\beer.txt,t) 
    }
  }
}


Here is the code changed a bit:
Code:
On 1:text:*:#:{
  if (Are you happy isin $strip($1-)) {   
    var %nicknum = $nick($chan,0) 
    var %nick1 = 1 
    while (%nicknum >= %nick1) { 
      if ($nick($chan,%nick1) isin $strip($1-)) {  
        var %nicklijst = var %nicklijst = $addtok(%nicklijst,$v1,32) 
      } 
      inc %nick1 
    }
    var %nicklijst = $replace(%nicklijst,$chr(32),$+($chr(32),$chr(38),$chr(32))) 
    if (%nicklijst) {
      if ($regex($1-,/(?<= |^)(?:i|me)(?= |$)/Si)) { 
        .timer 1 2 $read($scriptdir\acts\ruhappyme.txt,t) 
      }
        else {
          .timer 1 2 $read($scriptdir\acts\ruhappylist.txt,t) 
        }
      }
    else { 
      .timer 1 1 $read($scriptdir\acts\ruhappy.txt,t) 
    }
  }
}


Only thing changed is the first if.
It works in the original code because the botname is the trigger.

Hope this helps you help me.

RiMaJoy #220721 22/04/10 09:32 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Atm, the line of text has to contain any valid nickname (not necessarily the nick of the bot) because it checks for "if (%nicklijst)" first, and only if %nicklijst contains anything (any nicks) it does the me/I check and proceeds to "ruhappyme.txt" or "ruhappylist.txt" respectively.
Without at least one nickname, it will always read "ruhappy.txt". Do you want it to work for "Are you happy with me" as well (reading ruhappyme.txt)?

Horstl #220738 22/04/10 06:23 PM
Joined: Jul 2008
Posts: 57
R
RiMaJoy Offline OP
Babel fish
OP Offline
Babel fish
R
Joined: Jul 2008
Posts: 57
thanks Horstl

I'll move the me/i check part at the end as well.
That way it will check both ways.


Link Copied to Clipboard