| View previous topic :: View next topic |
| Author |
Message |
Ace-T Halfop
Joined: 29 Aug 2006 Posts: 82
|
Posted: Tue Aug 29, 2006 7:30 am Post subject: TCL script Help |
|
|
hey guys, looking for a bit ov support
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: |
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 |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Tue Aug 29, 2006 9:03 am Post subject: |
|
|
Try:
| Code: | 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 |
|
| Back to top |
|
 |
Ace-T Halfop
Joined: 29 Aug 2006 Posts: 82
|
Posted: Tue Aug 29, 2006 9:44 am Post subject: |
|
|
seems to work only prob now is the chanel owner can only do it and not any1 with half ops or above
thanks |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Tue Aug 29, 2006 6:53 pm Post subject: |
|
|
| Code: | | 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 |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Aug 30, 2006 4:52 am Post subject: |
|
|
Actually; you'd have to have +o flags and be opped in the channel. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Wed Aug 30, 2006 3:07 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Aug 30, 2006 3:43 pm Post subject: |
|
|
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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Wed Aug 30, 2006 5:54 pm Post subject: |
|
|
granted,
| Code: | | if {![isop $n $c]} { return } | will do what Ace-T asked for, stopping script if user is not a chanop (regardless of bot flags) |
|
| Back to top |
|
 |
Ace-T Halfop
Joined: 29 Aug 2006 Posts: 82
|
Posted: Thu Aug 31, 2006 2:58 pm Post subject: |
|
|
dragonlord, ur script worked great man ty
and ty to rest  |
|
| Back to top |
|
 |
Ace-T Halfop
Joined: 29 Aug 2006 Posts: 82
|
Posted: Thu Oct 05, 2006 4:23 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Thu Oct 05, 2006 5:16 pm Post subject: |
|
|
| did you re-add your users with the same flags? |
|
| Back to top |
|
 |
Ace-T Halfop
Joined: 29 Aug 2006 Posts: 82
|
Posted: Thu Oct 05, 2006 6:20 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
Linux Halfop

Joined: 04 Apr 2004 Posts: 71 Location: Under The Sky
|
Posted: Fri Oct 06, 2006 12:52 am Post subject: |
|
|
| 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.
| Quote: | 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
From the following line;
| Code: | | 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: | | 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... |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Oct 06, 2006 8:37 am Post subject: |
|
|
@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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Linux Halfop

Joined: 04 Apr 2004 Posts: 71 Location: Under The Sky
|
Posted: Fri Oct 06, 2006 12:39 pm Post subject: |
|
|
| 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... |
|
| Back to top |
|
 |
|