mIRC Homepage
Posted By: naki help - 09/08/03 04:28 AM
is there a way to get the <title>stuff</title> from this

<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><style><!

Posted By: pheonix Re: help - 09/08/03 04:33 AM
//echo -a $remove(<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><style><!,<html>,<head>,<meta http-equiv="content-type", content="text/html; charset=ISO-8859-1">style><!,content="text/html; charset=ISO-8859-1">,<style><!)
Posted By: codemastr Re: help - 09/08/03 04:34 AM
.echo -q $regex(%thetext,.*(<title>.*</title>).*)
.echo -a The title is: $regml(1)
Posted By: pheonix Re: help - 09/08/03 04:34 AM
or that :tongue:
Posted By: naki Re: help - 09/08/03 05:43 AM
Code:
alias sbot_web_open { sockopen sbot_web $gettok(%sbot_other,2,32) 80 }

on 1:sockopen:sbot_web: { 
  .sockwrite -n $sockname GET / HTTP/1.1
  .sockwrite -n $sockname Host: comcast.net
  .sockwrite $sockname $crlf  
  .timerweb 1 3 sockclose sbot_web
} 

on 1:sockread:sbot_web: {
  sockread -f %sb_raw
  ;echo @sbot 04 %sb_raw
  if (%sbot_web_title) {
    if (&lt;title&gt; isin %sb_raw) { 
      set %sbot_web_ts $regex(%sb_raw,.*(&lt;title&gt;.*&lt;/title&gt;).*)
      set %sbot_web_ts $remove($regml(1),&lt;title&gt;,&lt;/title&gt;)
      sbot_com privmsg %sbot_chan : $+ %sbot_nick $+ : [title: $gettok(%sbot_other,2,32) $+ $chr(93) %sbot_web_ts
      .sockclose sbot_web
      unset %sbot_web_title | unset %sbot_web_ts
    }

  } 
}


Sometimes when I do

title www.somesite.com or like www.sl.somesite.com

I get this

-
* /sockwrite: 'sbot_web' not connected (line 92, sbot.txt)
-

is there a way to fix this?
Posted By: KingTomato Re: help - 09/08/03 07:10 AM
.sockwrite -n $sockname Host: comcast.net

That line must match the website your querying. Also your query may not contain the http:// preifx or / suffix. must be a "clean" url such as www.google.com not http://www.google.com If you were to query google, you must use Host: www.google.com, not comcast.
Posted By: naki Re: help - 09/08/03 07:16 AM
is there a way to make that not show up then? I used .sockwrite but it still shows.
Posted By: KingTomato Re: help - 09/08/03 07:21 AM
paste ur script again highlighting the cline you have a problem with pls
Posted By: qwerty Re: help - 09/08/03 10:01 AM
Help file:
$sockerr
$sockerr is set to a value after each socket command/event and must be checked after each socket command and before processing an event to see if an error occurred.


So the on SOCKOPEN might trigger but only to report an error (which should be checked with $sockerr), in which case you won't be able to /sockwrite.
Posted By: naki Re: help - 09/08/03 05:07 PM
nm, I tried to see if I could use ^ and it worked. Thanks though.

Code:
on ^1:sockopen:sbot_web: { 
  .sockwrite -n $sockname GET / HTTP/1.1 | haltdef
  .sockwrite -n $sockname Host: $gettok(%sbot_other,2,32)
  .sockwrite $sockname $crlf  
  .timerweb 1 3 sockclose sbot_web
} 
Posted By: codemastr Re: help - 09/08/03 06:25 PM
Not related to your question but, don't do:
set %sbot_web_ts $regex(%sb_raw,.*(<title>.*</title>).*)
set %sbot_web_ts $remove($regml(1),<title>,</title>)


You said you wanted the <title></title> to remain, thats why I made it do that, if you really didn't want that then just use:

set %sbot_web_ts $regex(%sb_raw,.*<title>(.*)</title>.*)
set %sbot_web_ts $regml(1)

That way you don't need the $remove.
Posted By: naki Re: help - 09/08/03 08:21 PM
Thanks. At first that is what I just wanted. To get the <title>stuff</title> from things like that so I could use $remove, but since your way is cleaner I'm going to use that. I dont know anything about $regex
Posted By: naki Re: help - 09/08/03 09:31 PM
Now I've ran into another problem. When I do title www.somesite.com, it the bot doesnt even say anything anymore.

Here is the code.

Code:
on *:signal:sbot_read:{
  if ((join == $3) || (part == $3) || (privmsg == $3) || (notice == $3) || (topic == $3) || (kick == $3) || (mode == $3) || (quit == $3)) {
    set %sbot_nick $remove($gettok($2,1,33),:)
    set %sbot_addy $gettok($2,2,64)
    set %sbot_ident $gettok($gettok($2,1,64),2,33)
    set %sbot_chan $4
    set %sbot_com $3
    set %sbot_other $5-
  }

  if ($3 isnum) { .signal -n sbot_r [ $+ [ $3 ] ] $4- }
  elseif ($2 == ping) { .signal -n sbot_ping $3 | halt }
  else { .signal -n sbot_ [ $+ [ $3 ] ] }
  echo @sbot 04 $1-
}
 
on *:signal:sbot_privmsg:{
if (%sbot_nick == $me) {
    if (title isin $gettok(%sbot_other,1,32)) {
      set %sbot_web_title 1
      sbot_web_open
    }
  }
}
 
alias sbot_web_open { sockopen sbot_web $gettok(%sbot_other,2,32) 80 }
 
on ^1:sockopen:sbot_web: { 
  .sockwrite -n $sockname GET / HTTP/1.1 | haltdef
  .sockwrite -n $sockname Host: $gettok(%sbot_other,2,32)
  .sockwrite $sockname $crlf  
} 
 
on 1:sockread:sbot_web: {
  sockread -f %sb_raw
  ;echo @sbot 04 %sb_raw
  if (%sbot_web_title) {
    if (&lt;title&gt; isin %sb_raw) { 
      set %sbot_web_ts $regex(%sb_raw,.*&lt;title&gt;(.*)&lt;/title&gt;.*)
      set %sbot_web_ts $regml(1)
      sbot_com privmsg %sbot_chan : $+ %sbot_nick $+ : [title: $gettok(%sbot_other,2,32) $+ $chr(93) $iif(%sbot_web_ts != $null, %sbot_web_ts, error: cannot locate title)
      .sockclose sbot_web
      unset %sbot_web_title | unset %sbot_web_ts
    }
  } 
}


It worked before but now it isnt.
© mIRC Discussion Forums