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.

NICK/CHAN INFO script (SOLVED)

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
masheen
Voice
Posts: 28
Joined: Sat Apr 28, 2007 1:14 pm

NICK/CHAN INFO script (SOLVED)

Post by masheen »

have tried search on the archives and i havent found one so i am requesting this if this possible. Can any of u guys share a TCl script that will do this:

> first a user publicly types !nickinfo <targetnick>
> the bot then does a /ns info <nick> and outputs the result to the nick that requested the info?
> same logic goes to the public trigger !chaninfo <#chan> which makes the bot do a /cs info #chan and outputs the result to the requestor.

i would appreciate any help that anyone can spare. or at least guide me to a script that i can add or modify to do this. i am not entirely a noob on TCl... this is just way way out of my leaque right now. thanks to you guys in advance.
Last edited by masheen on Wed May 02, 2007 3:38 am, edited 1 time in total.
let he who is without stone cast the first sin
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Show us the reply from NS and CS when you perfom such commands
User avatar
masheen
Voice
Posts: 28
Joined: Sat Apr 28, 2007 1:14 pm

Post by masheen »

ok first if i query the bot with !nickinfo <somenick> the bot would then do a /nickserv info <somenick> and the output thru query message from the bot would have been:
<botname> -NickServ- Info for LordAshe:
<botname> -NickServ- (Currently on IRC) For extra info: /whois LordAshe
<botname> -NickServ- Last seen address : Ashe@apocrypha.jirehnet.net
<botname> -NickServ- Last seen time : Sun 29-Apr-2007 17:52:16 UTC
<botname> -NickServ- Time registered : Tue 13-Feb-2007 12:14:14 UTC
<botname> -NickServ- Time now : Mon 30-Apr-2007 00:12:15 UTC
<botname> -NickServ- Options: Enforced
<botname> -NickServ- *** End of Info ***
the same if i query the bot with !chaninfo <somechan> after which the bot performs a /chanserv info #somechan and queries me with this info:
<botname> -ChanServ- Info for #icon:
<botname> -ChanServ- Founder : LordAshe (enforcer@microsoft.net-ph.com)
<botname> -ChanServ- Mode Lock : +nt-ispklmc
<botname> -ChanServ- Last Topic : 'This is the channel Topic' (LordAshe)
<botname> -ChanServ- Description: PrivateChannel
<botname> -ChanServ- Options : SecuredOps, Ident, Verbose, Topic Lock(S)
<botname> -ChanServ- Memo Level : AOP
<botname> -ChanServ- Registered : Wed 17-Jan-2007 02:39:31 UTC
<botname> -ChanServ- Last opping: Sun 29-Apr-2007 16:33:07 UTC
<botname> -ChanServ- *** End of Info ***
i hope m clear with this. thanks again for the help. :) i hope sum1 can come up with this nifty and very usable script. :) (my server is DALNET by the way in case if the servers are an issue)
let he who is without stone cast the first sin
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Code: Select all

## Give your channel name here.
set scriptchannel "#channel"

bind pub -|- !nickinfo script:text1
bind pub -|- !chaninfo script:text2
bind notc -|- "*Info for *" script:notices1
bind notc -|- "*For extra info*" script:notices1
bind notc -|- "*Last seen address*" script:notices1
bind notc -|- "*Last seen time*" script:notices1
bind notc -|- "*Time registered*" script:notices1 
bind notc -|- "*Time now*" script:notices1
bind notc -|- "*URL*" script:notices1
bind notc -|- "*Options*" script:notices1
bind notc -|- "*Founder*" script:notices1
bind notc -|- "*Mode Lock*" script:notices1
bind notc -|- "*Last Topic*" script:notices1
bind notc -|- "*Description:*" script:notices1
bind notc -|- "*Memo Level*" script:notices1
bind notc -|- "*Registered*" script:notices1
bind notc -|- "*Last opping*" script:notices1
bind notc -|- "*End of Info*" script:notices1


proc script:text1 { nick host handle chan text } {
global scriptchannel user
set text [split $text]
set user [lindex $text 0]
if {$user == ""} {puthelp "NOTICE $nick :You need to supply a nickname."; return}
putserv "PRIVMSG nickserv@services.dal.net :info $user"
}

proc script:text2 { nick host handle chan text } {
global scriptchannel
set text [split $text]
set text [lindex $text 0]
if {$text == ""} {puthelp "NOTICE $nick :You need to supply a channel name."; return}
putserv "PRIVMSG chanserv@services.dal.net :info $text"
}

proc script:notices1 {nick uhost hand text dest} {
global scriptchannel
putquick "PRIVMSG $scriptchannel :$text"
}

putlog "!nickinfo and !chaninfo script loaded by iamdeath."
Enjoy.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

You really want it to trigger in any channel, but write to a preset channel (regardless of the channel it was triggered in)?

@iamdeath: there's no point in making the variable "user" access globalspace within script:text1, and neither "scriptchannel" in both script:text1 and script:text2
NML_375
User avatar
masheen
Voice
Posts: 28
Joined: Sat Apr 28, 2007 1:14 pm

Post by masheen »

yes its working! i think i can manage the rest of the changes and some alterations. you are good iamdeath :) it is people like u that inspire us begginers. thanks for the help...lastly can you add a !whois <nick> trigger for that? the bot after doing a /whois <nick> will have an output like this:
<botnick> LordAshe is enforce@oper.c0ntrol.com * root|fix
<botnick> LordAshe on @#adzu +#icon #tclhelp
<botnick> LordAshe using punch.va.us.dal.net Spelling is a lossed art.
<botnick> LordAshe has identified for this nick
<botnick> LordAshe has been idle 4mins 54secs, signed on Mon Apr 30 03:36:19
<botnick> LordAshe End of /WHOIS list.
pls bear with the request.. if its too much just say so... the help u gave is actually enuf already... but will appreciate it if u can add this one up. thanks dude.
let he who is without stone cast the first sin
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

@masheen: See arfer on DALnet he has written the two scripts you requested and believe me, far more elegant than what has been offered. arfer may share.

Just tell him I suggested you see him.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

nml375 wrote:You really want it to trigger in any channel, but write to a preset channel (regardless of the channel it was triggered in)?

@iamdeath: there's no point in making the variable "user" access globalspace within script:text1, and neither "scriptchannel" in both script:text1 and script:text2
Thanks alot for pointing that out nml, actually yes I don't need to make $user global at that time I was doing some experiences so I used that it in Global then I forgot to remove it.
User avatar
masheen
Voice
Posts: 28
Joined: Sat Apr 28, 2007 1:14 pm

Post by masheen »

um guys...its working and all but the problem is that it tends to become annoying when 2 or more people are trying to use the service... maybe change it to PRIVMSG $nick insted?

Code: Select all

proc script:notices1 {nick uhost hand text dest} {
global scriptchannel
putquick "PRIVMSG $scriptchannel :$text"
}
the only problem is is that when i change $scriptchannel to $nick, the bot no longer responds... can u guys shed light on this one? oh n dont wori bout the global trigger... the bot sits in just a channel so no worries. and if possible, can u guys add up a !whois <nick> trigger? i understand u will nid to capture raw replys from the server for this one... thanks thanks thanks a lot for anyone who offers help on this one.
let he who is without stone cast the first sin
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

you can find "!whois" scripts in the tcl archive.
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

bind pub -|- !nickinfo script:text1
bind pub -|- !chaninfo script:text2
bind notc -|- "*Info for *" script:notices1
bind notc -|- "*For extra info*" script:notices1
bind notc -|- "*Last seen address*" script:notices1
bind notc -|- "*Last seen time*" script:notices1
bind notc -|- "*Time registered*" script:notices1
bind notc -|- "*Time now*" script:notices1
bind notc -|- "*URL*" script:notices1
bind notc -|- "*Options*" script:notices1
bind notc -|- "*Founder*" script:notices1
bind notc -|- "*Mode Lock*" script:notices1
bind notc -|- "*Last Topic*" script:notices1
bind notc -|- "*Description:*" script:notices1
bind notc -|- "*Memo Level*" script:notices1
bind notc -|- "*Registered*" script:notices1
bind notc -|- "*Last opping*" script:notices1
bind notc -|- "*End of Info*" script:notices1


proc script:text1 { nick host handle chan text } {
global towhom
set text [split $text]
set text [lindex $text 0]
set towhom "$nick"
if {$text == ""} {puthelp "NOTICE $nick :You need to supply a nickname."; return}
putserv "PRIVMSG nickserv@services.dal.net :info $text"
}

proc script:text2 { nick host handle chan text } {
global towhom
set text [split $text]
set text [lindex $text 0]
set towhom "$nick"
if {$text == ""} {puthelp "NOTICE $nick :You need to supply a channel name."; return}
putserv "PRIVMSG chanserv@services.dal.net :info $text"
}

proc script:notices1 {nick uhost hand text dest} {
global towhom
putquick "PRIVMSG $towhom :$text"
}

putlog "!nickinfo and !chaninfo script loaded by iamdeath."

I think it should now msg nickname, try it out and let me know. As far as /whois I don't know about it I will read it understand it and then if I get it I will write on it :D
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The problem here, is that $nick would be NS (since NS is the one triggering this binding), rather than the nick originally requesting this information. This would require that you keep track of the original requester for the duration of the request.

I believe this code should do the trick, while also using proper queues, and not breaking the rfc that much (yes, we do respond to NOTICE's, but atleast we don't respond with PRIVMSG's). List of bindings taken from previous post by iamdeath.

Code has not been tested, but feel free to dig for bugs, flaws, etc :p

Code: Select all

proc get_ns {nick host hand text {dest ""}} {
 global get_ns
 if {![info exists get_ns(target)] || [string equal $get_ns(target) ""]} {return 0}
 puthelp "NOTICE $get_ns(target) :$text"
 if {[string match "*End of Info*" $text]} {
  unset get_ns(target)
  if {[info exists get_ns(queue)] && [llength $get_ns(queue)] > 0} {
   set next [lindex $get_ns(queue) 0]
   set get_ns(queue) [lreplace $get_ns(queue) 1 end]
   set get_ns(target) [lindex $next 0]
   putserv "PRIVMSG [lindex $next 1] :info [lindex $next 2]"
  }
 }
}

proc request_ns {nick host hand chan text} {
 global get_ns
 if {[string lenght $text] <= 0} {
  puthelp "NOTICE $nick :You must supply a nickname."
  return 1
 }
 if {[info exists get_ns(target)] && ![string equal $get_ns(target) ""]} {
  puthelp "NOTICE $nick :There is already a request in progress. Your request has been queued."
  lappend get_ns(queue) [list $nick "nickserv@services.dal.net" [lindex [split $text] 0]"]
 } else {
  set get_ns(target) $nick
  putserv "PRIVMSG nickserv@services.dal.net :info [lindex [split $text] 0]"
  puthelp "NOTICE $nick :Request sent."
 }
}

proc request_cs {nick host hand chan text} {
 global get_ns
 if {[string lenght $text] <= 0} {
  puthelp "NOTICE $nick :You must supply a nickname."
  return 1
 }
 if {[info exists get_ns(target)] && [string equal $get_ns(target) ""]} {
  puthelp "NOTICE $nick :There is already a request in progress. Your request has been queued."
  lappend get_ns(queue) [list $nick "chanserv@services.dal.net" [lindex [split $text] 0]"]
 } else {
  set get_ns(target) $nick
  putserv "PRIVMSG chanserv@services.dal.net :info [lindex [split $text] 0]"
  puthelp "NOTICE $nick :Request sent."
 }
}

bind pub -|- !nickinfo request_ns
bind pub -|- !chaninfo request_cs
bind notc -|- "*Info for *" get_ns
bind notc -|- "*For extra info*" get_ns
bind notc -|- "*Last seen address*" get_ns
bind notc -|- "*Last seen time*" get_ns
bind notc -|- "*Time registered*" get_ns
bind notc -|- "*Time now*" get_ns
bind notc -|- "*URL*" get_ns
bind notc -|- "*Options*" get_ns
bind notc -|- "*Founder*" get_ns
bind notc -|- "*Mode Lock*" get_ns
bind notc -|- "*Last Topic*" get_ns
bind notc -|- "*Description:*" get_ns
bind notc -|- "*Memo Level*" get_ns
bind notc -|- "*Registered*" get_ns
bind notc -|- "*Last opping*" get_ns
bind notc -|- "*End of Info*" get_ns 
Edit: Slight logical error fixed, that would render the script actionless (would only enqueue new request without actually processing the queue)
Last edited by nml375 on Mon Apr 30, 2007 1:31 pm, edited 1 time in total.
NML_375
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

A slightly updated version reducing repeated code:

Code: Select all

proc get_ns {nick host hand text {dest ""}} {
 global get_ns
 if {[info exists get_ns(target)] && ![string equal $get_ns(target) ""]} {return 0}
 puthelp "NOTICE $get_ns(target) :$text"
 if {[string match "*End of Info*" $text]} {
  unset get_ns(target)
  if {[info exists get_ns(queue)] && [llength $get_ns(queue)] > 0} {
   set next [lindex $get_ns(queue) 0]
   set get_ns(queue) [lreplace $get_ns(queue) 1 end]
   set get_ns(target) [lindex $next 0]
   putserv "PRIVMSG [lindex $next 1] :info [lindex $next 2]"
  }
 }
}

proc request_ns {nick host hand chan text} {
 global get_ns lastbind
 if {[string lenght $text] <= 0} {
  puthelp "NOTICE $nick :You must supply a nickname."
  return 1
 }
 switch -- $lastbind {
  "!nickinfo" {set target nickserv@services.dal.net}
  "!chaninfo" {set target chanserv@services.dal.net}
  default {return}
 }
 if {![info exists get_ns(target)] || [string equal $get_ns(target) ""]} {
  puthelp "NOTICE $nick :There is already a request in progress. Your request has been queued."
  lappend get_ns(queue) [list $nick $target [lindex [split $text] 0]"]
 } else {
  set get_ns(target) $nick
  putserv "PRIVMSG $target :info [lindex [split $text] 0]"
  puthelp "NOTICE $nick :Request sent."
 }
}

bind pub -|- !nickinfo request_ns
bind pub -|- !chaninfo request_ns
bind notc -|- "*Info for *" get_ns
bind notc -|- "*For extra info*" get_ns
bind notc -|- "*Last seen address*" get_ns
bind notc -|- "*Last seen time*" get_ns
bind notc -|- "*Time registered*" get_ns
bind notc -|- "*Time now*" get_ns
bind notc -|- "*URL*" get_ns
bind notc -|- "*Options*" get_ns
bind notc -|- "*Founder*" get_ns
bind notc -|- "*Mode Lock*" get_ns
bind notc -|- "*Last Topic*" get_ns
bind notc -|- "*Description:*" get_ns
bind notc -|- "*Memo Level*" get_ns
bind notc -|- "*Registered*" get_ns
bind notc -|- "*Last opping*" get_ns
bind notc -|- "*End of Info*" get_ns
Edit: Slight logical error fixed, that would render the script actionless (would only enqueue new request without actually processing the queue).
Edit: Forgot to make lastbind global.
Last edited by nml375 on Mon Apr 30, 2007 1:38 pm, edited 1 time in total.
NML_375
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Code: Select all

set mychannel "#channel"
bind pub -|- !whois script:whois

proc script:whois { nick host handle chan text } {
set text [split $text]
set user [lindex $text 0]
if {$user == ""} {puthelp "NOTICE $nick :You need to supply a nickname."; return}
putquick "WHOIS $user"
}

bind raw - "311" script:whois1
bind raw - "312" script:whois1
bind raw - "318" script:whois1
bind raw - "319" script:whois1
bind raw - "401" script:whois1

proc script:whois1 {from key args} {
global mychannel
set text [split $args]
set topaste [lrange $text 1 end]
regsub -all {\{} $topaste "" topaste
regsub -all {\}} $topaste "" topaste
regsub -all {\\} $topaste "" topaste
putserv "PRIVMSG $mychannel :$topaste"
}

putlog "!whois script loaded by iamdeath."
Enjoy your whois script, tested and working fine on Undernet.

nml awsome work, wish we could write codes like that too :P
Good job
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

It's not that hard, you simply has to make yourself one with the code ;)

Actually, it's a matter of practice and experience.. Keep at it, and you'll be there sooner or later :)
NML_375
Post Reply