mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2014
Posts: 24
J
Jokke Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Dec 2014
Posts: 24
Hi!


I've got this HUGE problem! I might have said yes to something I'm not able to do.

I would like to know how to read from a website using a socket, and print the outcome in the chat with minor adjustments.


Code:
alias theme return 
alias t.set {
  ;; 4 is time in seconds
  if ($1 == 1) return $+($theme,Din timer vil nu køre hvert time. ,$theme,.)
  elseif ($1 == 2) return $+($theme,,$nick,,$chr(44) Du har allerede en timer kørende! Type !timer off for at fjerne din timer.)
  elseif ($1 == 3) return $+($theme,[GamerInfo] $3- )
  elseif ($1 == 4) return 600
  elseif ($1 == 5) return $+($theme,Din timer er blevet fjernet fra rotationen.)
  elseif ($1 == 6) return $+($theme,$2 $+ 's timer er blevet fjernet fra rotationen.)

}
on *:NICK:{
  if ($timer($+(.,$nick.,$chan,.advert)).secs) {
    timer $+ $+(.,$nick,.,$chan,.advert) off
    var %com $left($gettok($timer($+(.,$nick.,$chan,.advert)).com,3-,44),$calc($len($gettok($timer($+(.,$nick.,$chan,.advert)).com,3-,44)) - 1))
    .timer $+ $+(.,$newnick,.,$chan,.advert) 0 $v1 msg $chan $+($,t.set,$chr(40),3,$chr(44),$newnick,$chr(44),%com,$chr(41)) 
  }
}

on *:TEXT:*:#:{
  if ($nick isop #) {
    if ($1 == !timer) {
      if ($2 == on) {
        if (!$timer($+(.,$nick.,$chan,.advert)).secs) {
          msg $chan $nick $t.set(1)
          msg $chan $t.set(3,$nick,$3-)
          .timer $+ $+(.,$nick,.,$chan,.advert) 0 $t.set(4) msg $chan $+($,t.set,$chr(40),3,$chr(44),$nick,$chr(44),$3-,$chr(41))
        }
        else {
          msg $chan $t.set(2)
        }
      }
      elseif ($2 == off) {
        if (!$3) {
          msg $chan $t.set(5)
          .timer $+ $+(.,$nick,.,$chan,.advert) off 
        }
        elseif ($3 && $nick($chan,$nick,@&~)) {
          msg $chan $t.set(6,$3)
          .timer $+ $+(.,$3,.,$chan,.advert) off 
        }
      }
    }
  }
}


I got this semi automatic script, to post whta ever in the channels, can I get that script to read from a .txt file online and post the outcome?

Joined: Dec 2014
Posts: 24
J
Jokke Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Dec 2014
Posts: 24
Second note; If there is anything on google, i havn't found I'm very sorry. I believe i've tried what made sense to me!

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259

Joined: Dec 2014
Posts: 24
J
Jokke Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Dec 2014
Posts: 24
I've been reading about this for very long.. I have to admit I've said yes to something I can't do.


Is there anyone, who will help a fellow human with this small task?

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
My long distance mind-reading abilities are really hindered by the cloudy weathered today, so you'll have to make an exception for me and instead just post what site you want to read from, and what data you're looking for... wink

Last edited by Sakana; 17/02/15 11:28 PM.
Joined: Dec 2014
Posts: 24
J
Jokke Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Dec 2014
Posts: 24
I'll be forever thankfull!


It's an "easy read" I hope. it's from http://www.playgames.dk/playtime.txt and the only think i need to read from the file is the small line, where I have to get www.playgames.dk infront.. (If it's hard to do, DON'T do it! I'll get the output to a full link in the .txt)

I just it inside a timer of some sort, to post it in the channel every 30 minutes or so.. I really hate that I can't do it by my self, and ofcourse I'll give you all the credits!

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
This works ;p


... though it is apparently not strictly correct to use sockread -f like that. Wims explained why, but I was too stupid to understand what else to do

Code:
alias gmr sockopen gmr www.playgames.dk 80

on *:SockOpen:gmr: {  
  sockwrite -n $sockname GET /playtime.txt HTTP/1.1
  sockwrite -n $sockname Host: www.playgames.dk
  sockwrite -n $sockname
}

on *:sockread:gmr: {
  var %data | sockread -f %data
  if (html isin %data) { 
    set %link %data 
    echo -ag %link | sockclose $sockname
  }
}

Joined: Dec 2014
Posts: 24
J
Jokke Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Dec 2014
Posts: 24
Thank you very much!

I'll try to get this to work tommorow!

I'll update the thread if i can't get it to work.. xD


Thanks once again!

Joined: Dec 2014
Posts: 24
J
Jokke Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Dec 2014
Posts: 24
Code:
alias gmr sockopen gmr www.playgames.dk 80

on *:SockOpen:gmr: {  
  sockwrite -n $sockname GET /playtime.txt HTTP/1.1
  sockwrite -n $sockname Host: www.playgames.dk
  sockwrite -n $sockname
}

on *:sockread:gmr: {
  var %data | sockread -f %data
  if (html isin %data) { 
    set %link %data 
    echo -ag %link | sockclose $sockname
  }
}

on *:TEXT:!test*:#gamerhuset: {
  if ($nick isop #) {
    .msg $chan Jokkebaby %link %data
    var %data | sockread -f %data
    if (html isin %data) { 
      set %link %data 
      echo -ag %link | sockclose $sockname
    }
  } 
  else {
    if (($($+(%,commandspam.,$nick),2) == On )  || ($($+(%,commandspam.,$chan),2) == On ))  { return }
    .halt
  }
}


I tried something like this, but ofcourse it won't work.. I have no clue how to use the information it pulls out from the socket script.. D:


EDIT; I've tried once more:

Code:
alias gmr sockopen gmr www.playgames.dk 80

on *:SockOpen:gmr: {  
  sockwrite -n $sockname GET /playtime.txt HTTP/1.1
  sockwrite -n $sockname Host: www.playgames.dk
  sockwrite -n $sockname
}

on *:sockread:gmr: {
  var %data | sockread -f %data
  if (html isin %data) { 
    set %link %data 
    echo -ag %link | sockclose $sockname
  }
}

on 1:text:!test:#: {

  ;We will create the socket and mark it with the channel where it has to send the answer

  var %sock = gmr $+ $ticks
  sockopen %sock www.playgaes.dk 80
  sockmark %sock $chan

}


Still won't work .. smirk Who ever makes it and gets it to work will get all the internet points i have! (Automatic script, will give 50+ E-Points!)

Last edited by Jokke; 18/02/15 07:58 PM.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
What the fork? laugh


Code:
on *:text:!test:#: {

set %chan #
sockopen gmr www.playgames.dk 80


on *:SockOpen:gmr: {  
  sockwrite -n $sockname GET /playtime.txt HTTP/1.1
  sockwrite -n $sockname Host: www.playgames.dk
  sockwrite -n $sockname
}

on *:sockread:gmr: {
  var %data | sockread -f %data
  if (html isin %data) { 
  msg %chan %data | sockclose $sockname
  }
 }
}

Last edited by Sakana; 18/02/15 08:14 PM.
Joined: Dec 2014
Posts: 24
J
Jokke Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Dec 2014
Posts: 24
Oh my god! It works! (almost.)

Code:
* /sockwrite: 'GET' no such socket (line 8, script5.ini)
-
/resident-evil-biohazard-remaster-p-1400.html
-
[21:47:20] ON Unknown command


How come it does that?

Btw, HEY DANSKER! laugh

Last edited by Jokke; 18/02/15 08:49 PM.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Oops ^), hej

Code:
on *:text:!test:#: {

  set %chan #
  sockopen gmr www.playgames.dk 80
}

on *:SockOpen:gmr: {  
  sockwrite -n $sockname GET /playtime.txt HTTP/1.1
  sockwrite -n $sockname Host: www.playgames.dk
  sockwrite -n $sockname
}

on *:sockread:gmr: {
  var %data | sockread -f %data
  if (html isin %data) { 
    msg %chan %data | sockclose $sockname
  }
}

Last edited by Sakana; 18/02/15 09:06 PM.
Joined: Dec 2014
Posts: 24
J
Jokke Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Dec 2014
Posts: 24
Originally Posted By: Sakana
Oops ^), hej

Code:
on *:text:!test:#: {

  set %chan #
  sockopen gmr www.playgames.dk 80
}

on *:SockOpen:gmr: {  
  sockwrite -n $sockname GET /playtime.txt HTTP/1.1
  sockwrite -n $sockname Host: www.playgames.dk
  sockwrite -n $sockname
}

on *:sockread:gmr: {
  var %data | sockread -f %data
  if (html isin %data) { 
    msg %chan %data | sockclose $sockname
  }
}



Thank you so much! I ow you one!

/thread


Link Copied to Clipboard