mIRC Home    About    Download    Register    News    Help

Print Thread
#225624 06/09/10 04:13 PM
Joined: Apr 2010
Posts: 24
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
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,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You may need to write a socket script to receive info from and send your request to a website.

Joined: Apr 2010
Posts: 24
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
Can u be a little bit more clear please, im new to mirc scripting so wont understand all the advanced stuff :p


Joined: May 2007
Posts: 37
C
Ameglian cow
Offline
Ameglian cow
C
Joined: May 2007
Posts: 37
you could try this tutorial i wrote: http://forum.swiftirc.net/viewtopic.php?t=4378

Joined: Apr 2010
Posts: 24
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
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,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2010
Posts: 24
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
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!

Joined: Apr 2010
Posts: 24
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
Anyone help please wink

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2010
Posts: 69
N
Babel fish
Offline
Babel fish
N
Joined: Aug 2010
Posts: 69
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.


"There is no theory of evolution, only a list of creatures Chuck Norris allows to live."
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
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.

I am SReject
My Stuff
Joined: Apr 2010
Posts: 24
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
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