DCS Computer Services' Tech Corner

Open Discussions on Microsoft Windows, Computer Hardware and Software, Malware, Online Security and All Things Tech
It is currently Fri Sep 10, 2010 1:08 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: channel users version reply
PostPosted: Mon Jan 11, 2010 7:16 pm 
Offline

Joined: Mon Jan 11, 2010 6:58 pm
Posts: 11
Hello,
I'm trying to make my egg send a /ctcp version on request, giving reply on chan if available or telling there's no answer after 10 seconds waiting for response
Quote:
<nick> !version <nick2>
<eggdrop> <nick2> is using Sample IRC Client 1.0

Code:
bind ctcr - VERSION version:reply
bind pub - !version check:version

proc check:version {nick uhost hand chan arg} {
global cversion
set cversion([string tolower $arg]) 1
putserv "PRIVMSG $arg :\001VERSION\001"
utimer 10 [list no:version:reply $nick $uhost $chan]
}

proc version:reply {nick uhost hand chan dest kw arg} {
global cversion
if {[info exists cversion([string tolower $arg])]} {
putserv "PRIVMSG $chan :$arg is using $cversion"
unset cversion([string tolower $arg])
}
}

proc no:version:reply {nick uhost chan arg} {
global cversion
if {[info exists cversion([string tolower $arg])] && [onchan $arg $chan]} {
putserv "PRIVMSG $chan :No CTCP version reply"
unset cversion([string tolower $arg])
}
}

putlog "Version Reply"

It doesn't work
Quote:
[02:10] Tcl error in script for 'timer26929':
[02:10] wrong # args: should be "no:version:reply nick uhost chan arg"

Thanks for helping ;)


Top
 Profile E-mail  
 
 Post subject: Re: channel users version reply
PostPosted: Tue Jan 12, 2010 6:33 am 
Offline
Owner
User avatar

Joined: Wed Feb 25, 2009 8:27 pm
Posts: 21
Location: Tennessee
try changing this line...
Code:
utimer 10 [list no:version:reply $nick $uhost $chan]

to look more like...
Code:
utimer 10 [list no:version:reply $nick $uhost $chan $arg]

_________________
SpiKe

http://www.mytclscripts.com


Top
 Profile E-mail  
 
 Post subject: Re: channel users version reply
PostPosted: Tue Jan 12, 2010 12:38 pm 
Offline

Joined: Mon Jan 11, 2010 6:58 pm
Posts: 11
Thank you Spike^^

Now, the bot makes the /ctcp version, but sends reply only to console, not to channel, also it has an error message
Quote:
[19:26] Tcl error [version:reply]: wrong # args: should be "version:reply nick uhost hand chan dest kw arg"
[19:26] CTCP reply VERSION: mIRC v6.35 + irssi skin from nick2 (nick2@masked-B25A34C7.com) to superbot

So, I tried:
Code:
proc version:reply {version:reply nick uhost hand chan dest kw arg}

New error message is:
Quote:
[19:43] Tcl error [version:reply]: wrong # args: should be "version:reply version:reply nick uhost hand chan dest kw arg"

Oh, now the bot sends /ctcp to console, and also sends to channel the message "No CTCP version reply" (for the same request)
And if really there is not version reply, the script doesn't do anything :oops:


Top
 Profile E-mail  
 
 Post subject: Re: channel users version reply
PostPosted: Sun Jan 17, 2010 12:43 pm 
Offline
Owner
User avatar

Joined: Wed Feb 25, 2009 8:27 pm
Posts: 21
Location: Tennessee
The process version:reply is called by the bind: bind ctcr - VERSION version:reply

From the eggdrop documentation, eggdrop tcl commands we look up bind ctcr...

Quote:
CTCP (stackable)

bind ctcp <flags> <keyword> <proc>
proc-name <nick> <user@host> <handle> <dest> <keyword> <text>
...and see that any process called by bind ctcr MUST take exactly 6 arguments
and none of them are channel. You will have to pass that to proc version:reply
some other way, maybe in the global cversion variable.


Also: proc version:reply needed some major rework to function at all:).
Watch your variable names, every process can use them differently!

Code:
bind pub - !version check:version

proc check:version {nick uhost hand chan arg} {
  global cversion
  set cversion([string tolower $arg]) $chan
  putserv "PRIVMSG $arg :\001VERSION\001"
  utimer 10 [list no:version:reply $nick $uhost $chan $arg]
}

bind ctcr - VERSION version:reply

proc version:reply {nick uhost hand dest kw arg} {
  global cversion
  if {[info exists cversion([string tolower $nick])]} {
    putserv "PRIVMSG $cversion([string tolower $nick]) :$nick is using $arg"
    unset cversion([string tolower $nick])
  }
}

proc no:version:reply {nick uhost chan arg} {
  global cversion
  if {[info exists cversion([string tolower $arg])] && [onchan $arg $chan]} {
    putserv "PRIVMSG $chan :No CTCP version reply from $arg"
    unset cversion([string tolower $arg])
  }
}

putlog "Version Reply"



NOTE: this replies only the first version reply line from the nick!
Any further script versions are ignored, probably not exactly what you're after.

See how that does and let me know.

_________________
SpiKe

http://www.mytclscripts.com


Top
 Profile E-mail  
 
 Post subject: Re: channel users version reply
PostPosted: Sun Jan 17, 2010 2:33 pm 
Offline
Owner
User avatar

Joined: Wed Feb 25, 2009 8:27 pm
Posts: 21
Location: Tennessee
I like this slightly modified version of the script.
It waits longer and will show all the script replies.
It uses the stripcodes command that was new in eggdrop 1.6.17

Code:
bind pub - !version check:version

proc check:version {nick uhost hand chan arg} {
  global cversion
  set cversion([string tolower $arg]) [list $chan 0]
  putserv "PRIVMSG $arg :\001VERSION\001"
  utimer 20 [list no:version:reply $chan $arg]
}

bind ctcr - VERSION version:reply

proc version:reply {nick uhost hand dest kw arg} {
  global cversion
  if {[info exists cversion([string tolower $nick])]} {
    foreach {ch cnt} $cversion([string tolower $nick]) { break }
    incr cnt
    if {$cnt=="1"} {
      putserv "PRIVMSG $ch :$nick is using $arg"
    } else {
      putserv "PRIVMSG $ch :$nick: [stripcodes bcug $arg]"
    }
    set cversion([string tolower $nick]) [list $ch $cnt]
  }
}

proc no:version:reply {chan nick} {
  global cversion
  if {[info exists cversion([string tolower $nick])]} {
    set cnt [lindex $cversion([string tolower $nick]) 1]
    if {$cnt=="0" && [onchan $nick $chan]} {
      putserv "PRIVMSG $chan :No CTCP version reply from $nick"
    }
    unset cversion([string tolower $nick])
  }
}

putlog "Version Reply"

_________________
SpiKe

http://www.mytclscripts.com


Top
 Profile E-mail  
 
 Post subject: Re: channel users version reply
PostPosted: Mon Jan 18, 2010 12:58 pm 
Offline

Joined: Mon Jan 11, 2010 6:58 pm
Posts: 11
Just two modifications are needed:
Code:
set arg [lindex $arg 0]

This way, the script recognizes nicks followed by empty spaces (<nick >).

Code:
putlog "Version Reply by Spike^^"


I tried both versions, the one that replies only the first version reply line and the longer one. Both works fine.

Thank you very much for spending your time with it :)


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group