mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
There's a few HTTP links in a single line but I'd like my script to capture the 1st HTTP link found (or 2nd or 3rd - depends if they changed the layout in the future?) and use that to echo back to myself.
here's example...

<moviebot> The Lion King (Animation, Adventure, Drama) - https://www.imdb.com/title/tt6105098 - Official Site Link : https://movies.disney.com/the-lion-king-2019 - Blu-ray due out on or around 22nd Oct 2019
<moviebot> Fast & Furious: Hobbs & Shaw (Action, Adventure) - https://www.imdb.com/title/tt6806448 - Official Site Link : https://www.hobbsandshaw.com - Blu-ray due out on or around 5th Nov 2019
...
...


And so on, but if I use $5 on that Lion King, it'll picks up https://www.imdb.com/title/tt6105098 but not that F&F because that's would show up as & frown

If I do my way, it'll be very messy i.e.
Code
If (http isin $1) { /echo -a $1 | halt }
else (http isin $2) { /echo -a $2 | halt }
else (http isin $3) { /echo -a $3 | halt }
else (http isin $4) { /echo -a $4 | halt }
else (http isin $5) { /echo -a $5 | halt }
else (http isin $6) { /echo -a $6 | halt }
else (http isin $7) { /echo -a $7 | halt }

But also, "optional", I'd like to output to something like this

The Lion King - https://www.imdb.com/title/tt6105098

Strip out the genre and the rest of the line because it's cleaner for me to read rather than having to read that long line from moviebot.

I'm still a newbie to coding - can only write very basic code - I'd appreciated for any help.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
assuming you want to avoid color codes getting in the way, you would use $strip to sanitize the input. $1 would only be the 1st word, so you'd want $1- to peek at all words. Have a look at this and other links at https://en.wikichip.org/wiki/mirc/token_manipulation

If you want to match the 1st word beginning with http, you could do like:

//tokenize 32 foo bar httpSTUFF test foo | echo -a $wildtok($strip($1-), http*, 1, 32)

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Alright, I'll give it a try .. thanks
Will reply back if I'm stuck with codes wink
Yea, I'm aware of $strip colours just that I'm too lazy to code properly on forums ;P

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
you could use regex:

Code
on *:TEXT:*:#:{

  ; matches: name (genres) - http...
  var %pattern = /^.+? \([^()]+\) - (https?:\/\/\S+)/S

  if ($regex($1-, %pattern)) {
    var %name = $regml(1)
    var %link = $regml(2)

    ; do stuff 
  }
}

Last edited by FroggieDaFrog; 01/12/19 05:50 AM.

I am SReject
My Stuff

Link Copied to Clipboard