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 trapping notices from chanserv

Old posts that have not been replied to for several years.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Help trapping notices from chanserv

Post by arfer »

I am writing a public commands script (for DalNet) to include such things as .Addaop (add an AOp to the channel access list). I would like to trap responses from Chanserv.

For example the bind & command:-

set vChannelServices "chanserv@services.dal.net"

bind o|o .addaop pToolsAddaop

proc pToolsAddaop {nick uhost hand chan arg} {
global vChannelServices
putserv "PRIVMSG $vChannelServices :AOP $chan ADD $arg"
}

The above code works fine. Say, for example, the target nick is already an AOp then chanserv responds as follows :-

-ChanServ (service@dal.net)- nick already exists on the AOp list of #channel

I can see this response in the partyline. I want to trap it programmatically.

I have tried as follows :-

bind NOTC -|- "*already exists on the AOp list*" pToolsAopExists

proc pToolsAopExists {nick uhost hand arg {dest ""}} {
global botnick
if {$dest == ""} {set dest $botnick}
putserv "PRIVMSG #channel :response trapped successfully"
}

This does not work. Not sure if it's because it is syntactically incorrect or because it is a server response and NOTC does not bind to server responses.

Could somebody give me usefull hints on how I can acheive this please.

I have looked briefly at RAW binds but there does not seem to be specific numerics for the responses as typified by the above.

Thanks
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

best you check raw server incoming traffic and look for the the keyword/number for the respond and bind it to RAW (remember to return 1 only if it was the message your wanted to trap!).
another possiblilty is that the string contains some false whitespaces or contraol codes (I once had a problem on another network, that nickserv put 2 spaces between and . and the next word, which wasnt been seen in mIRC of course, but for matching the string the bot will matter :D.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Thanks De Kus ... sounds good

However, would you expand on your answer a little

How/where do I look at raw server responses

Thanks
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

arfer wrote:How/where do I look at raw server responses
read to manual to enable raw logging in partyline (.help console) or log file.
I personally have an extra file for raw log, because this is best see what the server really writes, because the Texteditors don't phrase any (ANSI, IRC, ...) control codes.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

As far as I know bind notc will definately trigger private notices. Basically you have to check the destination if it is a channel or the bot's nick and if nick is ChanServ, then go ahead and do as you like.

Code: Select all

bind notc - * pToolsAopExists

.......................
..........................
 if {[isbotnick $dest] && [string equal "ChanServ" $nick]} {
For matching:

Code: Select all

 if {[string match "*already exists on the * list*" $arg]} {
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Thanks awyeah

I have now tried to trap all private notices in order to see what $nick, $dest and $arg are, using code as follows :-

# ---------- ADDAOP ---------- #

set vChannelServices "chanserv@services.dal.net"

proc pToolsAddaop {nick uhost hand chan arg} {
global vChannelServices
putserv "PRIVMSG $vChannelServices :AOP $chan ADD $arg"
}

bind NOTC - * pToolsServiceResponse

proc pToolsServiceResponse {nick uhost hand arg dest} {
putserv "PRIVMSG #channel :test succeeded, nick is $nick, destination is $dest, text is $arg"
}

Even this does not work. Can you see what is wrong with it?

Thanks
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Try this and see the reply in DCC:

Code: Select all

bind notc - "*" test:notice

proc test:notice {nick uhost hand text {dest ""}} {
 putlog "CATCHED NOTICE: From: $nick - To: $dest - Message: $text"
}
You code looks fine to me, don't know why it doesn't work. :roll:

Try typing .tcl set errorInfo in DCC after you execute it maybe it generates a error, which I think not.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Thanks again Awyeah

Got it working

Differences between what you suggest and my code are :-

mask "*" instead of just *

{dest ""} instead of just dest

I will work backwards to see what breaks it

Thanks again
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Heh, okay.

Rememeber that this code will execute on all type of notices. Private notices sent to the bot, notices sent to channels where the bot is on, and also even on server notices if I am correct.

So you have to check and decide through 'if' statements which type of notices you want and who should be sending these notices, in this case it would be private notices and being sent by ChanServ.

See my 'if' code above and use that one for your script.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

arfer wrote:Thanks De Kus ... sounds good

However, would you expand on your answer a little

How/where do I look at raw server responses

Thanks
if i recall right

Code: Select all

proc raw_server_notice {from key arg} {
  #your stuff here
  return 0;#required
}

bind raw - NOTICE raw_server_notice 
XplaiN but think of me as stupid
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

You could cut off stuff like that by using things like,

Code: Select all

if {[string equal -nocase "chanserv" $nick]} {
EDIT:

Here is a piece of code i made for a script of mine which records the chanlev from Q/L on Quakenet and saves them into an array.

Code: Select all

proc cflags::recordchanlev {nickname hostname handle arguments ****} {
  variable flags
  set from "${nickname}!${hostname}"
  if {[regexp -nocase -- {^(Q!TheQBot@CServe.quakenet.org)$} $from]} { 
  # do stuff here
  }
}
You could ofcourse just modify it, replace the Q!TheQBot@CServe.quakenet.org with Chanserv!<whatever>
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Regexp is slow, don't know why you would use it, when you can string match easily. When a network has ChanServ services, even if they are offline those nicks are sqlined, so no one can use them. So we don't bother to use the ident and hostname after the nick, just for security.

If you really want, you can use this, simple:

Code: Select all

if {[string equal "ChanServ!service@dal.net" "$nick!$uhost"]} {
Obviously, replace service@dal.net by your networks services' mask. Also do an exact match 'string equal', no need for the -nocase switch or string match.

Plus in the end you can use:
putserv "PRIVMSG ChanServ@services.dal.net :#your stuff"

Just to be more secure, if you are a security geek.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

I highly doubt anyone cares for the fact that regexp is about 13 ms or something like that slower than string match/equal etc.

For getting responses, It fast enough.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

But I don't see the use for regexp here. I mean basically its used for complex matching and here you are just using it to match 2 plain strings combined into one.

{^(Q!TheQBot@CServe.quakenet.org)$} $from]}

If you were to use a complex match for the string ChanServ!service@my.network.net then I would understand, but using this for what it is basically not designed to do, but yet it still can do for it has greater ability and yet it is used for simple tasks, which can be done with simple string manipulation commands is not worth it.

As obviously little red riding hood has 2 ways to grandma's house. One is very long and tiring and one is very short. Obviously why would she walk a far distance just togo to the same place? Why not take the shorter route. The shorter route will make it easier togo, require less energry and she will reach in less time.

My point here is, use something simple to solve something simple. If the problem cannot be solved using simple techniques, then go ahead and use something which can the solve the problem.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

No need to discredit regexp just because you don't understand it :lol:
Locked