alias Example {
sockclose example
sockopen -e Example github.com 443
; Check if there was an error.
; in practice this check is not required, if anyone know how to get $sockerr set after executing a /sockopen command that did not result in a script error, let me know
if ($sockerr) {
echo -ag There was an error: $sockerr
halt
}
}
; Listen for the on SOCKOPEN event.
on *:SOCKOPEN:Example:{
if ($sockerr) {
echo -ag there was an error: $sockerr : $sock($sockname).wsmsg
; we usually /return event, not halt them unless you specifically want to halt, when we want to stop processing)
return
}
; Write a GET request.
sockwrite -nt $sockname GET /svdermant/MinecraftBot/commits/master HTTP/1.1
sockwrite -n $sockname Host: github.com
sockwrite -nt $sockname $crlf
; Check if there was an error. again this check is not required in practice, same as above
if ($sockerr) {
echo -ag There was an error: $sockerr
halt
}
}
; Listen for the on SOCKREAD event.
on *:SOCKREAD:Example:{
; Check if there was an error.
if ($sockerr) {
echo -ag There was an error: $sockerr
halt
}
; Create a local variable to hold the data.
set %gitpush
set %c >
set %p </p>
; Read exactly one line from the received buffer, the data being read is put into the local variable.
sockread %gitpush
;if data was received but does not contain a new line, sockread won't read anything and $sockbr is 0, you need to stop processing and wait for the event to trigger again with more data, hopefully with a newline in it.
if ($sockbr == 0) return
; if a line has been found, Print it
echo -ag Data = %gitpush
if (*%c* isin %gitpush) && (*%p* isin %gitpush { set %git %gitpush }
;;write info.txt $noHTML(%gitpush)
echo -a %git
;not sure what you're trying to do with %a = %i here.
}