egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TCL script Help
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Tue Aug 29, 2006 7:30 am    Post subject: TCL script Help Reply with quote

hey guys, looking for a bit ov support Razz

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 Smile

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
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Tue Aug 29, 2006 9:03 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Tue Aug 29, 2006 9:44 am    Post subject: Reply with quote

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

thanks
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Aug 29, 2006 6:53 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Aug 30, 2006 4:52 am    Post subject: Reply with quote

Actually; you'd have to have +o flags and be opped in the channel.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Wed Aug 30, 2006 3:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Aug 30, 2006 3:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Wed Aug 30, 2006 5:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Thu Aug 31, 2006 2:58 pm    Post subject: Reply with quote

dragonlord, ur script worked great man ty

and ty to rest Smile
Back to top
View user's profile Send private message
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Thu Oct 05, 2006 4:23 pm    Post subject: Reply with quote

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 Sad

any ideas
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Thu Oct 05, 2006 5:16 pm    Post subject: Reply with quote

did you re-add your users with the same flags?
Back to top
View user's profile Send private message
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Thu Oct 05, 2006 6:20 pm    Post subject: Reply with quote

yeh nothing has changed with it exepct a fresh install ov eggdrop Sad
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 Sad
Back to top
View user's profile Send private message
Linux
Halfop


Joined: 04 Apr 2004
Posts: 71
Location: Under The Sky

PostPosted: Fri Oct 06, 2006 12:52 am    Post subject: Reply with quote

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 Sad

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 Sad

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
Code:
.help whois

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Oct 06, 2006 8:37 am    Post subject: Reply with quote

@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
View user's profile Send private message
Linux
Halfop


Joined: 04 Apr 2004
Posts: 71
Location: Under The Sky

PostPosted: Fri Oct 06, 2006 12:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
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
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber