This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Help with Server Notice binds

Old posts that have not been replied to for several years.
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Help with Server Notice binds

Post by Weirdo »

i am trying to create a nickserv script update, for aniverse, since they keep killing off nickserv, and when it reboots, it causes havok with my bots.

Problem is, when i try to bind to the nickserv notices, i come across the problem. the problem is, that i have no idea what to bind it with, as a notc bind, doesnt react to server notices, which is what the majority of all nickserv scripts listed on the tCL archive use this method
(7) NOTC (stackable)
bind notc <flags> <mask> <proc>
procname <nick> <user@host> <handle> <text> <dest>

Description: dest will be a nickname (the bot's nickname,
obviously) or a channel name. mask is matched against the entire
notice and can contain wildcards. It is considered a breach of
protocol to respond to a /notice on IRC, so this is intended for
internal use (logging, etc.) only. Note that server notices do not
trigger the NOTC bind.
Is there any way i can get past this?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

I think this is to do with the format of the actual incoming notice, though I couldn't be sure.

You can use "bind raw - NOTICE proc:name"

Be sure to force a "return 0" at every exit point with bind raw, as most commands return codes are interpreted as 1 (which means eggdrop ignores all notices).
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

Code: Select all

bind RAW - NOTICE nserv:reboot
proc nserv:reboot {nick uhost hand text dest} {
        global cserv nserv 
        putserv "Privmsg $nserv(nick) :Identify $nserv(pass)"
	putserv "Privmsg $cserv(nick) :Op $::channel"
	putcmdlog "Nickserv Rebooted, Re-identified"
	return 0
}
this is the code i am using for the little script, when nickserv comes back online, hopefully i can test it :P

Hint, Aniverse at the mo = unstable

This will then trigger on ALL notices from services?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Nope, this will trigger on all notices period.

On top, you need to see the RAW bind definition. You don't use the same parameters for the RAW bind.
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

i dont think i am following you exactly
(17) RAW (stackable)
bind raw <flags> <keyword-mask> <proc>
procname <from> <keyword> <text>
i realised i copied the wrong bit of code before posting, wanted

Code: Select all

proc nserv:reboot {from keywork text} {
Instead. Only way i see it being distinguished from that of services, and not just a general notice, is by using the from variable. In this though, how is the from formatted? And what does the Keyword variable do?

<Natsuki-Chan> [19:48] -NOTICE- Password accepted - you are now recognized

Unfortunately the bot doesnt say who the notice is from, so does this mean it can actually tell whether the notice is from services, or from the server?

(sorry for all this, just trying to understand)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

First off, putlog is your friend.

I strongly sugest using it to find out what each var contains when.

The key var is the same as the mask in the bind. In this case, NOTICE.
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

Well, i did a bit of playing. Found a few bugs that i have tried to correct

Code: Select all

proc nserv:reboot {from keyword text} {
        global cserv nserv 
	if {[string match -nocase $from $cserv(services)] != 1 && [string match -nocase $text $nserv(warning)] != 1} {return 0}
        putserv "Privmsg $nserv(nick) :Identify $nserv(pass)"
	set nserv(check) "1"
	utimer 20 [unset nserv(check)]
	putserv "Privmsg $cserv(nick) :Op $::channel"
	putcmdlog "Nickserv Rebooted, Re-identified"
	if {$nserv(check) == 1} {return 0}
	return 0
}
this is what i ended up with.

First of all, i wanted to check who the notice was from and what it contained. Our nickserv does ...

[20:46:39] -Services.Aniverse.Com- This nickname is owned by someone else

... when your nick is in violation, and ...

[20:46:40] -Services.Aniverse.Com- Password accepted - you are now recognized

... when you identified. So i tried to set the script to trigger , ONLY on the first one since it did, and still does react to everything at the moment.

Also, i wanted to try and prevent it from doing this, by placing a timer on it. When it was triggered, set a variable to 1, then set a timer which will unset that variable, and then when the identify is completed, check for the variable = 1, if it still is, then close the procedure.

Doesnt work though, any suggestions?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Now we are getting somwhere.

Lets take a look at what you are now trying to do.

1: You are trying to prevent it sending a message on the second command. Fine and dandy.

Remember though, Tcl processes through the code in order.

Notice you are checking the value of the check digit at the end, after the message was been sent.

2: Knowing whe to, and not to use brackets.

Code: Select all

utimer 20 [unset nserv(check)]
Using the [] brackets, runs/calls a command, and replaces the point in the code with the return value.

As such, here, you are telling the timer, you want to run the return value of the unset command, in adition to unsetting the variable on the spot.

You need to send the text unset, rather than call the command directly.

Code: Select all

utimer 20 [list unset nserv(check)]
Seeing as the correct way to use timers, is to list enclose things, use the list command, to keep things running smothly.

3: Use of $::channel

This is good use, to call global variables, and will work well. However, I strongly sugest suign a different name.

The name $channel, in a IRC bot is very common, and will likely conflict at some point. Try using nserv(channel) instead, where it will likely be more unique.

4: You can't check a non-existant variable.

In your timer, you use "unset". Again, good idea, just the use is wrong.

Code: Select all

if {$nserv(check) == 1}
When the variable is unset, this like will error, as $nserv(check) no longer exists.

You can use somthing like

Code: Select all

if {[info exists nserv(check)]}
This will check to see if the variable exists, regardless of the value.

5: Add some brackets to your IF statments.

If blocks can get very hard to read, when using more than one check in the same block. You can group them together with brackets, so you know exactly which part is belongs to which operator.

Code: Select all

if {[string match -nocase $from $cserv(services)] != 1 && [string match -nocase $text $nserv(warning)] != 1}
TO
if {([string match -nocase $from $cserv(services)] != 1) && ([string match -nocase $text $nserv(warning)] != 1)}
The script is coming along, though I am not too sure about the second "string match". It sounds liek ti calls it is checking for the wrong value, but I can't be sure.
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

Code: Select all

proc nserv:reboot {from keyword text} {
        global cserv nserv 
	if {([string match -nocase $from $cserv(services)] != 1) && ([string match -nocase $text $nserv(warning)] != 1)} {return 0}
	putserv "Privmsg $nserv(nick) :Identify $nserv(pass)"
	putserv "Privmsg $cserv(nick) :Op $::runchan"
	putcmdlog "Nickserv Rebooted, Re-identified"
	set nserv(check) "1"
	utimer 20 [list unset nserv(check)]	
	if {[info exists $nserv(check)] == 1} {return 0}
	return 0
}
It must be the late night, as my own logic in the lines 7 - 9, the set variable, set timer to undo it, and then close the procedure, just doesnt make sense. I have moved the actual msg bit above the checker now, and moved the set var below the msg bits. Cant test at the moment, aniverse seems to be under attack. Should work though, in theory

The 2nd Match checks for the text sent by the server. i did a couple of putlogs as you said, and checked the output, they are checkable against, so its worth a shot. I copied the actual words the nickserv bot says, and chucked as a variable above.

Update - Checked it. Looks like the anti flood thingy isnt working, she still reacts on every line, even though i have the match on it. Very peculiar.
[00:06] Nickserv Rebooted, Re-identified
[00:06] -NOTICE- This nickname is owned by someone else
[00:06] Nickserv Rebooted, Re-identified
[00:06] -NOTICE- If this is your nickname, type /msg NickServ IDENTIFY <password>
[00:06] Nickserv Rebooted, Re-identified
[00:06] -NOTICE- If you do not IDENTIFY within 60 seconds, you nickname will be changed
[00:06] Nickserv Rebooted, Re-identified
Getting these as well
[00:08] Tcl error in script for 'timer2':
[00:08] can't unset "nserv(check)": no such element in array
[00:08] Tcl error in script for 'timer3':
[00:08] can't unset "nserv(check)": no such element in array
The two variables for the Services name and the text to match with is:

set cserv(services) "Services.Aniverse.Com"
set nserv(warning) "*nickname is owned*"

First things first, what can i do to make sure that the procedure ONLY binds to the one message, the "This nickname is owned by someone else"? As it seems that the if statement just isnt hacking it, or its making the procedure work around it, the RAW bind?

I can probably guess the logic for the loop prevention is very flawed. Is there an easier way or doing this?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Remember, as I said, it is read in order.

You are checking to see if thwere is a flood, after performing all your commands. No point in doing that.

Code: Select all

proc nserv:reboot {from keyword text} { 
        global cserv nserv 
  if {[info exists $nserv(check)] == 1} {return 0}
   if {([string match -nocase $from $cserv(services)] != 1) && ([string match -nocase $text $nserv(warning)] != 1)} {return 0} 
   putserv "Privmsg $nserv(nick) :Identify $nserv(pass)" 
   putserv "Privmsg $cserv(nick) :Op $::runchan" 
   putcmdlog "Nickserv Rebooted, Re-identified" 
   set nserv(check) "1" 
   utimer 20 [list catch [list unset nserv(check)]]    
   return 0 
}
The above is sound, with the exception of one part.

Your IF checking, to see if the message is from nickserv is still flawed. If it reacts on every NOTICE, then it isn't returning 0 (AKA, string match is returning 0.

Using the putlog lines, acan you please paste the output, and the values of $cserv(services) and $nserv(warning)
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

[21:17] -NOTICE- Weirdo!Seb@public2-ward1-6-cust41.oldh.broadband.ntl.com ACCESS [#catgirls] LIST
[21:18] Notice From > Services.Aniverse.Com
[21:18] Notice Keywork > NOTICE
[21:18] notice Text > natsuki-chan :You have already identified
the first one uses the From variable, second, keyword, third text
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

And what is the one to ask you to identify?
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

[16:03:22] -Services.Aniverse.Com- This nickname is owned by someone else
-
[16:03:22] -Services.Aniverse.Com- If this is your nickname, type /msg NickServ IDENTIFY <password>
-
[16:03:22] -Services.Aniverse.Com- If you do not IDENTIFY within 60 seconds, you nickname will be changed
this is what aniverse gives you when you change nick to a registered one

I programmed the script to use the first notice, rather than the 2nd, to identify
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Code: Select all

proc nserv:reboot {from keyword text} { 
  global cserv nserv 
  if {[string equal -nocase $from "services.aniverse.com"]} { return 0 }
  if {[info exists $nserv(check)] == 1} {return 0} 
  if {[string equal -nocase $text $nserv(warning)]} {
    putserv "Privmsg $cserv(nick) :Op $::runchan"
  } else {
    putserv "Privmsg $nserv(nick) :Identify $nserv(pass)" 
    putcmdlog "Nickserv Rebooted, Re-identified" 
  }
  set nserv(check) "1" 
  utimer 20 [list catch [list unset nserv(check)]]    
  return 0 
}
Try that.
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

One or two queries

First, the Catch in the utimer statement. I thought that was for getting errors?

Second, the script fails to trigger, i inserted a putlog to make sure the bind was triggering, it was, but was returning 0

Changed the Warning variable to the full message nickserv gives, and i got the Array warning for the check variable
[00:54:44] <Natsuki-Chan> [00:54] Connected to irc-1.aniverse.com
[00:54:44] <Natsuki-Chan> [00:54] Trigger Successful
[00:54:44] <Natsuki-Chan> [00:54] Tcl error [nserv:reboot]: can't read "nserv(check)": no such element in array
[00:54:44] <Natsuki-Chan> [00:54] -NOTICE- *** Looking up your hostname...
[00:54:45] <Natsuki-Chan> [00:54] Trigger Successful
[00:54:45] <Natsuki-Chan> [00:54] Tcl error [nserv:reboot]: can't read "nserv(check)": no such element in array
[00:54:45] <Natsuki-Chan> [00:54] -NOTICE- *** Checking Ident
[00:54:45] <Natsuki-Chan> [00:54] Trigger Successful
[00:54:45] <Natsuki-Chan> [00:54] Tcl error [nserv:reboot]: can't read "nserv(check)": no such element in array
the Problem of it triggering on every notice, including those given when the bot is connecting to a server is confusing me a little. The array warning is give on this line

Code: Select all

  if {[info exists $nserv(check)] == 1} {return 0}
what confuses me is that i thought that "info exists" only looks for it. If that variable is unset, wouldnt its array entry remain? Perhaps a change of variable is needed?

Thirdly, the op command in the other if statement, not sure what thats was for?

Thanks for the patience again ppslim, these threads that i make tend to go on for quite a bit. :) thank you for the help
Locked