mIRC Home    About    Download    Register    News    Help

Print Thread
Help with socket and reading from website #247211 24/07/14 03:26 AM
Joined: Jul 2014
Posts: 7
A
Aler360 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Jul 2014
Posts: 7
I want my bot to read what is on this website http://nightdev.com/hosted/followers.php?channel=aler360&limit=5 but when i use my code it doesnt return anything. Im farilly new to sockets and could be doing a very silly mistake plz help

alias test {
sockopen test nightdev.com 80
}

on *:sockopen:test: {
sockwrite -n $sockname get /hosted/followers.php?channel=aler360&limit=5 HTTP/1.0
sockwrite -n $sockname User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
sockwrite -n $sockname Host: nightdev.com
sockwrite -n $sockname Accept-Language: en-us
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname
}

on *:sockread:test: {
if ($sockerr) {
echo -a Error.
halt
}
else {
var %temp
sockread %temp
if (something isin %temp) {
do something
}
elseif (somethingelse isin %temp) {
do something else
}
}
}

Re: Help with socket and reading from website [Re: Aler360] #247213 24/07/14 03:30 AM
Joined: Jul 2014
Posts: 48
A
AeonPsych Offline
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
try this instead
Code:
on *:sockopen:test: {
   sockwrite -n $sockname GET /hosted/followers.php?channel=aler360&limit=5 HTTP/1.0
   sockwrite -n $sockname Host: nightdev.com $crlf $+ $crlf
}

Re: Help with socket and reading from website [Re: AeonPsych] #247215 24/07/14 03:42 AM
Joined: Jul 2014
Posts: 7
A
Aler360 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Jul 2014
Posts: 7
it didnt seam to work i just got no responce

Re: Help with socket and reading from website [Re: Aler360] #247216 24/07/14 04:04 AM
Joined: Jul 2014
Posts: 48
A
AeonPsych Offline
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
what do you mean you don't get a response?

i tried
Code:
on *:text:!followers:#:{
  test
}


alias test {
  sockopen test nightdev.com 80
}

on *:sockopen:test: {
  sockwrite -n $sockname GET /hosted/followers.php?channel=aler360&limit=5 HTTP/1.0
  sockwrite -n $sockname Host: nightdev.com $crlf $+ $crlf
}

on *:sockread:test: {
  if ($sockerr) { return }
  var %read | sockread -f %read
  while ($sockbr) {
    if (%read != $null) echo -ag %read
    sockread -f %read
}



And it echo the entire page back. It's the same code you are using, with my updated sockopen code block that I posted earlier. All the read part is doing is echo anything that is read from the server. This means that you should be getting a response. Your if statements probably aren't checking correctly

Re: Help with socket and reading from website [Re: AeonPsych] #247230 24/07/14 02:10 PM
Joined: Jul 2014
Posts: 7
A
Aler360 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Jul 2014
Posts: 7
Thus echo the website but it doesnt post it back in chat

Last edited by Aler360; 24/07/14 03:01 PM.
Re: Help with socket and reading from website [Re: Aler360] #247239 24/07/14 05:16 PM
Joined: Jul 2014
Posts: 7
A
Aler360 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Jul 2014
Posts: 7
HELP Plz

Re: Help with socket and reading from website [Re: Aler360] #247252 25/07/14 01:01 AM
Joined: Jul 2014
Posts: 48
A
AeonPsych Offline
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
well, to message it back in chat, use the msg channel command. You wouldn't want to read the entire website back to chat, though. If it spams the chat really fast, you get kicked off the irc server.

Re: Help with socket and reading from website [Re: AeonPsych] #247255 25/07/14 01:49 AM
Joined: Jul 2014
Posts: 7
A
Aler360 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Jul 2014
Posts: 7
How would i use implement the msg channel command

Re: Help with socket and reading from website [Re: Aler360] #247257 25/07/14 05:54 AM
Joined: Jul 2014
Posts: 48
A
AeonPsych Offline
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
I'm a little confused, you know how to work sockets, but don't know basic mirc command syntax, usually its the other way around, lol.

anyways, the syntax for sending a message is:
Code:
msg #channelname Message to respond here.


if I put that as the exact message command, and the script bot was named "bot", the chat response would be

bot: Message to respond here.


You can also print out variables, and nick names, like $nick, or %variablename.

If you still have any question about simple mirc scripting commands and variable use, I'd suggest looking over the mirc help documentation, or searching online for some tutorials/wiki/databases. If you already know how to implement sockets, then help documentation or a tutorial might prove more useful to you, then back/forth question answering on a forum.

Re: Help with socket and reading from website [Re: Aler360] #247258 25/07/14 06:39 AM
Joined: Apr 2014
Posts: 191
B
blessing Offline
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
Code:
on *:text:!followers:#:{
  test msg #
}

alias test {
  sockclose test 
  sockopen test nightdev.com 80
  sockmark test $1-
}

on *:sockopen:test: {
  sockwrite -n $sockname GET /hosted/followers.php?channel=aler360&limit=5 HTTP/1.0
  sockwrite -n $sockname Host: nightdev.com $crlf $+ $crlf
}

on *:sockread:test: {
  if ($sockerr) { return }
  var %read | sockread -f %read
  while ($sockbr) {
    if (%read == $null) { var %data 1 }
    elseif %data { $sock(test).mark %read }
    sockread -f %read
  }
}