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.

Triggering dcc:tcl and dcc:tcl on bind pub

Old posts that have not been replied to for several years.
Locked
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Triggering dcc:tcl and dcc:tcl on bind pub

Post by awyeah »

Is there anyway I can enable .tcl and .set commands as 'pub' commands which can be say triggered on channels, or even bind msg, when the bot is messaged, instead of the partyline -- without modifying the source code?

Code: Select all

#unbind dcc n tcl *dcc:tcl
#unbind dcc n set *dcc:set
Also if I way to relay tcl error messages, in channels or private messages to users, I should just string match the tcl error output in partyline and relay it where ever I like I guess?
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Re: Triggering dcc:tcl and dcc:tcl on bind pub

Post by De Kus »

you can use eval like this:

Code: Select all

bind pub n tcl pub:tcl

proc pub:tcl {nick uhost hand chan text} {
   catch {eval $text} output
   foreach line [split $output \n] {
      puthelp "PRIVMSG $chan :$line"
   }
   return 1
}
however, I hope you are aware of the security issues of that :D.

for set you will prabably have to use:
set evaluate "set $text"
eval $evaluate
Last edited by De Kus on Sat Apr 23, 2005 12:55 pm, edited 1 time in total.
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 »

Yes thanks, so the mask is "tcl", rest the same okay got that... nothing big I guess. Yes I am aware of the security issues, no one except me has access to my bot plus +mn ;)
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

btw. maybe you want to do:

Code: Select all

foreach line [split $output \n] {
  puthelp "PRIVMSG $chan :$line"
}
otherwise the output would be cut off on first newline.
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 »

.tcl works fine -- doesn't work for global vars, without the foreach atm, but .set isn't working.

<awyeah-> .set testvar 123
<adapter> Set: 123
<awyeah-> okay hmm
<awyeah-> .tcl putlog $testvar
<adapter> Tcl: can't read "testvar": no such variable


tcl is unable to display global vars:

<awyeah-> .tcl putlog $botnick
<adapter> Tcl: can't read "botnick": no such variable
<awyeah-> .tcl set errorInfo
<adapter> Tcl: can't read "errorInfo": no such variable

Code: Select all

proc pub:set {nick uhost hand chan text} {
  set evaluate "set [lindex $text 0] \"[lrange $text 1 end]\""
  puthelp "PRIVMSG $chan :Set: [eval $evaluate]"
  return 1
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

That's because the set variable is not global.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Then maybe:

Code: Select all

proc pub:set {nick uhost hand chan text} {
  set evaluate1 "set [lindex $text 0] \"[lrange $text 1 end]\""
  set evaluate2 "global [lindex $text 0]"
  puthelp "PRIVMSG $chan :Set: [eval $evaluate1]"
  eval $evaluate2
  return 1
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

just use:

Code: Select all

set evaluate "set ::$text"
eval $evaluate
only change: :: added. as alternate you can change it to:
set evaluate "uplevel #0 set $text"
maybe the uplevel variant is better, when you want to change a variable within a namespace like: "set script::active 1". I am not sure if a custom namespace is always a subnamespace of the global namespace.

PS: using "uplevel #0 " for the !tcl trigger is an option as well.
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...
Locked