|
AntuV
|
AntuV
|
What I want to do is to get rid of Nightbot as it isn't fast enough due to certain limitations it has. So... I have a mini-game in a channel I admin, a PvP mini-game. You'd input "!pvp b" and then retrieve what's in http://agussdg.ga/verificar.php?user1=a&user2=b where "a" is the user who triggered the command and "b" is the target user. (NOTE: it won't work at this moment if it's not from Nightbot's IP) I have problems retrieving the text it generates and I don't know if I'm doing it right. Here's the script I got at this moment: on 1:text:!pvp*:#: {
var %sock = pvp
sockopen %sock agussdg.ga 80
sockread %sock
}
on 1:sockopen:pvp*: {
sockwrite -n $sockname GET /verificar.php?user1= $+ $nick $+ &user2= $+ $2 HTTP/1.1
sockwrite -n $sockname Host: www.agussdg.ga
sockwrite -n $sockname $crlf
}
on 1:sockread:pvp*: {
var %t
sockread %t
while ($sockbr) {
echo %t
sockread %t
}
sockclose $sockname
}
Last edited by AntuV; 09/06/15 03:36 AM.
|
|
|
|
Joined: May 2015
Posts: 245
Fjord artisan
|
Fjord artisan
Joined: May 2015
Posts: 245 |
(NOTE: it won't work at this moment if it's not from Nightbot's IP) maybe your way of restricting IP causes problems?
|
|
|
|
Joined: May 2015
Posts: 245
Fjord artisan
|
Fjord artisan
Joined: May 2015
Posts: 245 |
all i got
1: HTTP/1.1 200 OK
1: Date: Tue, 09 Jun 2015 10:14:52 GMT
1: Server: Apache
1: X-Powered-By: PHP/5.5.21
1: Content-Encoding: gzip
1: Vary: Accept-Encoding
1: Content-Length: 70
1: Keep-Alive: timeout=2, max=100
1: Connection: Keep-Alive
1: Content-Type: text/html; charset=UTF-8
1:
1:
|
|
|
|
Joined: Jan 2004
Posts: 1,330
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,330 |
You don't receive all the data in single sockread, so don't sockclose at the end of it.
|
|
|
|
Joined: Jul 2006
Posts: 4,020
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,020 |
I wrote a lot about how to properly read with on sockread, see in particular the section about the last line not showing up http://en.wikichip.org/wiki/mirc/commands/sockread
Last edited by Wims; 09/06/15 11:34 AM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
AntuV
|
AntuV
|
(NOTE: it won't work at this moment if it's not from Nightbot's IP) maybe your way of restricting IP causes problems? I was refering to the mini-game itself. If you go to that URL it will show "Esta ({IP}) no es la IP de Nightbot" what translates to: "This ({IP}) isn't Nightbot's IP". At least it should return that
Last edited by AntuV; 09/06/15 03:50 PM.
|
|
|
|
AntuV
|
AntuV
|
You don't receive all the data in single sockread, so don't sockclose at the end of it. I'll read this and come back later! Thanks to both!
|
|
|
|
Joined: May 2015
Posts: 245
Fjord artisan
|
Fjord artisan
Joined: May 2015
Posts: 245 |
tnx to Wims and Loki12583  /pvp a b
alias pvp {
var %sock = $+(pvp,$1,$$2)
if ($sock(%sock)) { sockclose %sock }
sockopen %sock agussdg.ga 80
sockmark %sock $1 $2
}
on *:sockopen:pvp*: {
var %nick1 = $gettok($sock($sockname).mark,1,32)
var %nick2 = $gettok($sock($sockname).mark,2,32)
var %u = $+(user1=,%nick1,&user2=,%nick2)
sockwrite -n $sockname GET /verificar.php HTTP/1.1
sockwrite -n $sockname Host: agussdg.ga
sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
sockwrite -n $sockname Connection: keep-alive
sockwrite -n $sockname $+($crlf,%u)
}
on *:sockread:pvp*: {
if ($sockerr) { return }
var %temp = $null
sockread %temp
if ($sockbr == 0) sockread %temp
echo -ag on-read: %temp
}
on *:sockclose:pvp*:{
if (!$sockerr) {
var %temp = $null
sockread -f %temp
if ($sockbr == 0) return
echo -ag on-close: %temp
}
}
|
|
|
|
AntuV
|
AntuV
|
tnx to Wims and Loki12583  /pvp a b
alias pvp {
var %sock = $+(pvp,$1,$$2)
if ($sock(%sock)) { sockclose %sock }
sockopen %sock agussdg.ga 80
sockmark %sock $1 $2
}
on *:sockopen:pvp*: {
var %nick1 = $gettok($sock($sockname).mark,1,32)
var %nick2 = $gettok($sock($sockname).mark,2,32)
var %u = $+(user1=,%nick1,&user2=,%nick2)
sockwrite -n $sockname GET /verificar.php HTTP/1.1
sockwrite -n $sockname Host: agussdg.ga
sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
sockwrite -n $sockname Connection: keep-alive
sockwrite -n $sockname $+($crlf,%u)
}
on *:sockread:pvp*: {
if ($sockerr) { return }
var %temp = $null
sockread %temp
if ($sockbr == 0) sockread %temp
echo -ag on-read: %temp
}
on *:sockclose:pvp*:{
if (!$sockerr) {
var %temp = $null
sockread -f %temp
if ($sockbr == 0) return
echo -ag on-close: %temp
}
}
Wow! You made it to show the text at least!  What I needed was a command that if someone called UserA inputs "!pvp UserB" then it will retrieve the text in "agussdg.ga/verificar.php?user1=UserA&user2=UserB". I'll see if I can edit it to make it like that!
|
|
|
|
Joined: May 2015
Posts: 245
Fjord artisan
|
Fjord artisan
Joined: May 2015
Posts: 245 |
on-text event with calling pvp-alias like !pvp player2 => /pvp $nick $2
|
|
|
|
AntuV
|
AntuV
|
on-text event with calling pvp-alias like !pvp player2 => /pvp $nick $2 on *:text:!pvp*:#: {
//pvp $nick $2
} Like this? If I make it like that, the argument that should be the player2, is null 
|
|
|
|
Joined: May 2015
Posts: 245
Fjord artisan
|
Fjord artisan
Joined: May 2015
Posts: 245 |
And what you typed in chat to test it?
|
|
|
|
AntuV
|
AntuV
|
And what you typed in chat to test it? In twitch I typed "!pvp Agussdg_" The php file verifies the user exists, but only after veryfing there is an argument that isn't null, which is the case. Screenshot: http://puu.sh/iiryf/661b07f9f9.png
|
|
|
|
Joined: May 2015
Posts: 245
Fjord artisan
|
Fjord artisan
Joined: May 2015
Posts: 245 |
|
|
|
|
Joined: May 2015
Posts: 245
Fjord artisan
|
Fjord artisan
Joined: May 2015
Posts: 245 |
|
|
|
|
AntuV
|
AntuV
|
I solved it doing this: sockwrite -n $sockname GET /verificar.php?user1= $+ %nick1 $+ &user2= $+ %nick2 HTTP/1.1 But now how do I get it to actually print it on Twitch chat? Because "echo -ag $chan %temp" does not, and "msg $chan %temp" neither 
|
|
|
|
Joined: Jan 2004
Posts: 1,330
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,330 |
$chan is not valid a socket event, you need to associate $chan with $sockname and store it either in a global variable, hash table, or by using the /sockmark command.
|
|
|
|
AntuV
|
AntuV
|
$chan is not valid a socket event, you need to associate $chan with $sockname and store it either in a global variable, hash table, or using the /sockmark command. How? I'm really new to this  alias pvp {
var %sock = $+(pvp,$1,$$2)
if ($sock(%sock)) { sockclose %sock }
sockopen %sock agussdg.ga 80
sockmark %sock $1 $2
}
on *:sockopen:pvp*: {
var %nick1 = $gettok($sock($sockname).mark,1,32)
var %nick2 = $gettok($sock($sockname).mark,2,32)
sockwrite -n $sockname GET /verificar.php?user1= $+ %nick1 $+ &user2= $+ %nick2 HTTP/1.1
sockwrite -n $sockname Host: agussdg.ga
sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
sockwrite -n $sockname Connection: keep-alive
sockwrite -n $sockname $crlf
}
on *:sockread:pvp*: {
if ($sockerr) { return }
var %temp = $null
sockread %temp
if ($sockbr == 0) sockread %temp
}
on *:sockclose:pvp*:{
if (!$sockerr) {
var %temp = $null
sockread -f %temp
if ($sockbr == 0) return
echo -ag $chan %temp
}
}
on *:text:!pvp*:#: {
//pvp $nick $2
} This is all the code
Last edited by AntuV; 09/06/15 08:13 PM.
|
|
|
|
Joined: Jan 2004
Posts: 1,330
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,330 |
You're already using /sockmark, so just add $chan to that. You should understand the code you're running.
|
|
|
|
|