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.

isin / string match

Old posts that have not been replied to for several years.
Locked
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

isin / string match

Post by NewzUK »

Hi

I'm trying to modify a script so that if the word reuters is contained in $url it will msg the channel one thing and if not, another.

This is what I've come up with but I don't know if 'isin' is valid in TCL like it is in mIRC scripting...

if (reuters isin $url) {
puthelp "PRIVMSG $chan :12,12 1,15 $title - Reuters "
puthelp "PRIVMSG $chan :» http://abcnews.go.com$url" }
else {
puthelp "PRIVMSG $chan :12,12 1,15 $title - AP "
puthelp "PRIVMSG $chan :» http://abcnews.go.com$url" }

Thanks in advance...
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

if {[lsearch -exact [string tolower $url] "reuters"] != -1} {
# it matches..
}
Once the game is over, the king and the pawn go back in the same box.
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

thanks caesar

it dosn't seem to be catching the word, and is returning the news in the 'else' format everytime even if reuters is in the URL...here's the part of the script:

### Compair the both hashes, announce news if they differ and create new datafile.
if {$newhash != $oldhash} {
if {[lsearch -exact [string tolower $url] "reuters"] != -1} {
abcmsg "4,4 1,15 [gettime -5]ET $title - Reuters "
abcmsg "4,4 0,14 » http://abcnews.go.com$url "
} else {
abcmsg "4,4 1,15 [gettime -5]ET $title - AP "
abcmsg "4,4 0,14 » http://abcnews.go.com$url "
}
}

Here's an example of a url with the word in it:
http://abcnews.go.com/wire/World/reuter ... 08_93.html

that's the one I want it to send the first msgs in - if reuters isn't in it then I want it to send the other...

thanks again.
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

[11:31] (caesar): .tcl set url "foo bar reuters moo" ; if {[lsearch -exact [string tolower $url] "reuters"] != -1} { putlog "bla" }
[11:31] (Toy): [11:31] bla
[11:31] (Toy): Tcl:
As you can see is working fine at me.. probably your $url is not good or something..

Also, I've tryed that link and got an "Sorry. This content is not available. We apologize for the inconvenience." msg from that page..
Once the game is over, the king and the pawn go back in the same box.
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

sorry I mis-pasted the sample URL:

http://abcnews.go.com/wire/World/reuter ... 08_26.html

that one works...
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

caesar wrote:

Code: Select all

if {[lsearch -exact [string tolower $url] "reuters"] != -1} {
# it matches..
}
why not using string match -nocase *reuters* ? isn't $url a string?
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

thanks arcane - that works! :D
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

lazy probably :mrgreen:
Once the game is over, the king and the pawn go back in the same box.
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

lazy? his worked and yours didn't so I'd ask myself who is the lazy one :P
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

NewzBoy wrote:lazy? his worked and yours didn't so I'd ask myself who is the lazy one :P
i think he meant himself.

...at least i hope so :P
@caesar: hmm... how long ago is it that you read that topic about "using list commands on strings" last time? :mrgreen:
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
User avatar
CrazyCat
Revered One
Posts: 1359
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

arcane, you're not fair....
remember that caesar is old and tired :)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I'm Grandpa now? :mrgreen: I meant for myself that I sometimes tend to be lazy and screw up things.. :P
Once the game is over, the king and the pawn go back in the same box.
User avatar
CrazyCat
Revered One
Posts: 1359
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Caesar, don't worry :)
We all make mistakes sometimes, our brains are working too much.
But we can't do anything against that, it's the trouble that know any genious :)
Locked