mIRC Home    About    Download    Register    News    Help

Print Thread
#225624 06/09/10 04:13 PM
L
lassyakjedi
lassyakjedi
L
Hey guys ,
I'm not much of an mirc coder at the moment, but have managed to create a decent bot smile
My query here is ,is there any way to link a particular website to my bot using scripts.Scripts that read data from the website and transfer it to my bot,when some user triggers my bot?
Basically i am making a bot that reads data from a text based gaming site (Take www.ruinsofchaos.com ,for example)

Example:
If there is a player named ABC on the website,
in my mirc window when i type '!link ABC'
i want my bot to display that particular players link.
something like
Code:
<user>!link ABC
<Bot>http://www.ruinsofchaos.com/stats.php?id=4358952

Last edited by lassyakjedi; 06/09/10 05:04 PM.
Joined: Jul 2007
Posts: 1,124
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,124
You may need to write a socket script to receive info from and send your request to a website.

L
lassyakjedi
lassyakjedi
L
Can u be a little bit more clear please, im new to mirc scripting so wont understand all the advanced stuff :p


C
Chessnut
Chessnut
C
you could try this tutorial i wrote: http://forum.swiftirc.net/viewtopic.php?t=4378

L
lassyakjedi
lassyakjedi
L
ok will go through that and give it a try smile
Also ,are all sockets written in remotes or Aliases ?

Last edited by lassyakjedi; 12/09/10 11:15 AM.
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Everything is written in Remotes except aliases (and those can be written in remotes if prefixed with "alias"). Unless someone says otherwise, anything given on this forum will usually go into Remotes.

L
lassyakjedi
lassyakjedi
L
I gave my best shot after reading that tutorial...Great tutorial btw Chessnut smile
The beginning was easy enough to follow but i got stuck when i came to the SOCKREAD and SOCKCLOSE parts.

The game name is kingsofchaos as i said earlier
Quote:
Example:
If there is a player named ABC on the website,
in my mirc window when i type '!link ABC'
i want my bot to display that particular players link.
something like
Code:

<user>!link ABC
<Bot>http://www.kingsofchaos.com/stats.php?id=4358952 (just an example)


This is what i have managed to do so far.
Also all url of players are on the battlefield.php if that helps.(http://www.kingsofchaos.com/battlefield.php)

Code:
sockopen kocsock www.kingsofchaos.com 80
on $*:text:!link*:#: {
if ($sock(kocplay)) .sockclose kocplay
set %kocplayway $iif($left($1,1) == @, msg $chan, notice $nick)
sockopen kocplay www.kingsofchaos.com.com 80
}
on *:SOCKOPEN:kocplay: {
sockwrite -nt $sockname GET /lang/en/aff/kingsofchaos/title.ws HTTP/1.1
sockwrite -nt $sockname Host: www.kingsofchaos.com
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:kocplay: {
  if ($sockerr) { halt }
  else {
  ...
  }
}

Any help will be appreciated smile
Thanks in advance!

L
lassyakjedi
lassyakjedi
L
Anyone help please wink

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Remove www. from your sockopen command (remove the duplicate one at the top), remove the duplicate .com from the sockopen command, and try HTTP/1.0 instead of 1.1. Also, if it's on battlefield.php, you should use that in your GET instead of what you have there now.

N
N3M3S1S
N3M3S1S
N
You may have to add certain functions so that it responds to that website's syntax.

Code:
on *:TEXT:!kings*:#: {
  %king.chan = $chan
  kingsofchaos $1-
}
alias kingsofchaos {
  ;add syntax to variable here
  %king.srch = $1-
  sockclose kings
  sockopen kings kingsofchaos.com 80
}
on *:SOCKOPEN:kings: {
  ;might have to add log-in as well
  sockwrite -n $sockname GET %king.srch HTTP/1.0
  sockwrite -n $sockname Host: www.kingsofchaos.com
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname Content-Type: text/html
  sockwrite -n $sockname $crlf
}
on *:SOCKREAD:kings: {
  sockread %kings

  ;may need to add $regex or $regml to sperate info from html.
  %king.num = 1

  ;change the number to appropriate number of information
  if (%king.num < 6) { 
    msg %king.chan %kings
    inc %king.num
  }
  elseif (%king.num >= 6) { sockclose king }
}
on *:SOCKCLOSE:king: { unset %king* }


Try something like that or improve upon this. I just threw it together as an example. One thing I noticed is that in order to do anything with that website you might have to have the bot log into the website through the sockets as well.

Joined: Apr 2010
Posts: 964
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 964
So i've been looking into it, and here is the problem, due to them using multiple pages to return the result if the player being searched for is on any page other than the first, I can't make an easy way to get it :\

Last edited by FroggieDaFrog; 10/10/10 03:51 AM.
L
lassyakjedi
lassyakjedi
L
Originally Posted By: N3M3S1S
You may have to add certain functions so that it responds to that website's syntax.

Code:
on *:TEXT:!kings*:#: {
  %king.chan = $chan
  kingsofchaos $1-
}
alias kingsofchaos {
  ;add syntax to variable here
  %king.srch = $1-
  sockclose kings
  sockopen kings kingsofchaos.com 80
}
on *:SOCKOPEN:kings: {
  ;might have to add log-in as well
  sockwrite -n $sockname GET %king.srch HTTP/1.0
  sockwrite -n $sockname Host: www.kingsofchaos.com
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname Content-Type: text/html
  sockwrite -n $sockname $crlf
}
on *:SOCKREAD:kings: {
  sockread %kings

  ;may need to add $regex or $regml to sperate info from html.
  %king.num = 1

  ;change the number to appropriate number of information
  if (%king.num < 6) { 
    msg %king.chan %kings
    inc %king.num
  }
  elseif (%king.num >= 6) { sockclose king }
}
on *:SOCKCLOSE:king: { unset %king* }


Try something like that or improve upon this. I just threw it together as an example. One thing I noticed is that in order to do anything with that website you might have to have the bot log into the website through the sockets as well.


Well i get This Error:
<&Btxx>!kings dark222
<~Bot1> <html>
<~Bot1> <head><title>400 Bad Request</title></head>
<~Bot1> <body bgcolor="white">
<~Bot1> <center><h1>400 Bad Request</h1></center>
<~Bot1> <hr><center>nginx/0.6.32</center>
<~Bot1> </body>
<~Bot1> </html>

Last edited by lassyakjedi; 10/10/10 06:42 PM.

Link Copied to Clipboard