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.

TCL script Help

Help for those learning Tcl or writing their own scripts.
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

TCL script Help

Post by Ace-T »

hey guys, looking for a bit ov support :P

i made a php script to retrieve data from my site and print it in irc and works brilliant, but only prob is when a user uses the command it will get the data and put it in irc but if they do it in another channel my eggdrop bot is in it prints it in the channel set in the php script....

just wondering if there is an option to add summet to the tcl script so only if you have ops on irc u can use it :)

here is the tcl script

Code: Select all

package require http

bind pub - !stats stats
proc stats {n u h c a} {
set nick [lindex [split $a] 0]
if {$nick!=""} {
putquick "PRIVMSG #channelname Retrieving Data.... Please Wait..."
 set data [::http::geturl http://www.sitename.net/ircstats.php?search=$nick]
 foreach line [split [::http::data $data] \n] {
putquick "PRIVMSG #channelname Data Retrieval Complete."
  putquick "PRIVMSG #channelname $line"
 }
 ::http::cleanup $data
}
}
Last edited by Ace-T on Tue Aug 29, 2006 10:53 am, edited 1 time in total.
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Try:

Code: Select all

bind pub - !stats stats
proc stats {n u h c a} {
  if {![matchattr $h o|o $c] || ![isop $n $c]} { return }
  set nick [lindex [split $a] 0]
  if {$nick != ""} {
    putquick "PRIVMSG $c :Retrieving Data.... Please Wait..."
    set data [::http::data [set url [::http::geturl http://www.sitename.net/ircstats.php?search=$nick]]]
    if {$data == ""} {
      putquick "PRIVMSG $c :Data Retrieval Failed."
    } else {
      putquick "PRIVMSG $c :Data Retrieval Complete."
      foreach line [split $data \n] {
        putquick "PRIVMSG $c :$line"
      }
      ::http::cleanup $url
    }
  }
}
Also, next time please your proper indenting and incase the script within the code tags, makes it easier on the eyes to read.
r0t3n @ #r0t3n @ Quakenet
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Post by Ace-T »

seems to work only prob now is the chanel owner can only do it and not any1 with half ops or above :(

thanks
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Code: Select all

if {![matchattr $h o|o $c] || ![isop $n $c]} { return }
The above allows any bot user with +o (Global/Channel) flags or a channel Op to use the trigger it does not restict it to the bot owner.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Actually; you'd have to have +o flags and be opped in the channel.
NML_375
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

nml375 wrote:Actually; you'd have to have +o flags and be opped in the channel.
you need to learn operators used in if conditions
|| is "or"
&& is "and"

Alchera's snippet stops the script if the user is not recognized as an operator.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Oh, I'm fairly well accuainted with "and" and "or" operators...
I'm also quite familiar with De Morgan's theorem... (might wanna check it up)

A detailed analysis of the speciffic if-statement:
cond1: ![matchattr $h o|o $c]
cond2: ![isop $n $c]
op1: cond1 || cond2

cond1:
This will return true if [matchattr $h o|o $c] returns false

cond2:
This will return true if [isop $n $c] returns false

op1:
This will return true if either cond1 or cond2 is true, that is; if [matchattr...], [isop...], or both are false

Next, lets examine the body of the if-block...
if op1 returns true, execute return (there is no "else" clause)

Thus... if you either lack +o|o flag or is not opped (or a combination of both), the proc will return immediately.

Using De Morgan's theorem (or common sense) makes it clear that thus, you'll need both +o|o flags, and be opped to get past that return-statement...
NML_375
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

granted,

Code: Select all

if {![isop $n $c]} { return }
will do what Ace-T asked for, stopping script if user is not a chanop (regardless of bot flags)
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Post by Ace-T »

dragonlord, ur script worked great man ty

and ty to rest :)
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Post by Ace-T »

this worked fine til i reinstalled eggdrop no it just dont work....
it will work if i remove
if {![matchattr $h o|o $c] || ![isop $n $c]} { return } or dragons one :(

any ideas
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

did you re-add your users with the same flags?
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Post by Ace-T »

yeh nothing has changed with it exepct a fresh install ov eggdrop :(
everything elsse works expect my announce script cause its reporting from my site sometimes it cant resolve the host name but aprt from them 2 things everything else is fine :(
User avatar
Linux
Halfop
Posts: 71
Joined: Sun Apr 04, 2004 4:20 pm
Location: Under The Sky

Post by Linux »

Ace-T wrote:seems to work only prob now is the chanel owner can only do it and not any1 with half ops or above :(

thanks
&
Ace-T wrote:this worked fine til i reinstalled eggdrop no it just dont work....
it will work if i remove
if {![matchattr $h o|o $c] || ![isop $n $c]} { return } or dragons one :(

any ideas
All i observe is that you want your script can be used by Ops and Halfops, as you mention earlier that owner can do it others can't, dear friend there are 2 conditions on user status i.e OP(@), VOICE(+) & HALFOP(%) not only in Channel but in Bot aswell.
If you want to allow other users to use that script you should add them in the Bot with the particular flags.
l - halfop (user has halfop access to the channel)
m - master (user is a channel master)
n - owner (user is a channel owner)
o - op (user has op access to the channel)
For more flags info type the following command in Bot's partyline/dcc

Code: Select all

.help whois
From the following line;

Code: Select all

if {![matchattr $h o|o $c] || ![isop $n $c]} { return }
Above mentioned code stops the script if the user is not recognized as an operator or not oped on the channel.

If you want to allow others then set their flags or tell them to be Oped and use it. As for halfop matter replace above live with:

Code: Select all

if {![matchattr $h lo|lo $c] || ![isop $n $c] || ![ishalfop $n $c]} { return }

by this halfop can use it too.

REMEMBER: If you set the flags in Bot so there is no need for the users to gain OP or HALFOP for usage, Bot will recognized them as they are added and/but if you don't add them so they should be @ or % for its use.

Regards.
I'm an idiot, At least this one [bug] took about 5 minutes to find...
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

@Linux:
With that code, you'd have to be both opped and halfopped + have ol flags.

@Ace-T:
the piece of code in DragnLord's last post should work..
Can you check (using .channel <yourchannel>) that your bot properly recognizes the user, and sees it as being opped?
NML_375
User avatar
Linux
Halfop
Posts: 71
Joined: Sun Apr 04, 2004 4:20 pm
Location: Under The Sky

Post by Linux »

nml375 wrote:@Linux:
With that code, you'd have to be both opped and halfopped + have ol flags.
If you read my post again i will be very thankful, one thing i would like to tell you;

Usage:
'||' = OR
'&&' = AND


If users are added in the Bot as Op/Halfop then it is NOT nesassary to be OP(@) or Halfop(%) on channel too because Bot recon them with their flags and If users are not added then they SHOULD be OP(@) or Halfop(%) on channel.

Thats the reason i apply all the conditions with the flags "lo" or "Channel Op" or "Halfop".

Regards.
I'm an idiot, At least this one [bug] took about 5 minutes to find...
Post Reply