mIRC Home    About    Download    Register    News    Help

Print Thread
#257832 21/05/16 02:28 AM
Joined: May 2016
Posts: 50
T
Babel fish
OP Offline
Babel fish
T
Joined: May 2016
Posts: 50
Hi so I have recently been messing around with sockets though it doesn't work. I get the error message: /sockwrite: 'GET' no such socket (line 36, remote.ini)

I would very much like to get some help thank you!

on *:TEXT:!connect:#magnusgameplay:{
sockopen Test thefaaborg.dk 80
}

on *:SOCKOPEN:Test: {
sockwrite -nt $RSplay GET /protocal.html
sockwrite -nt $RSplay Host: thefaaborg.dk
sockwrite $RSplay $crlf
}

on *:SOCKREAD:Test: {
if (!$sockerr) {
var %sockreader
sockread %sockreader
if (For mig har chatten* iswm %sockreader) {
tokenize 32 %sockreader
Test $4
sockclose Test
}
}
}


Life is potato.
Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Hey your script looks mostly fine! Good job!
What is $RSplay supposed to return?
There should be a socket name where it is. But because it doesnt return anything mirc sees GET as the socket name and returns error cause there is not such socket! Why dont you use $sockname ? smile

Joined: May 2016
Posts: 50
T
Babel fish
OP Offline
Babel fish
T
Joined: May 2016
Posts: 50
Thanks for the quick reply, Im trying to setup a system that let's people request to get my Chat bot connected to their twitch chat via external website, though i'm not having any luck. I have changed everything to be $Test but no luck thus far.


Life is potato.
Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
No problem! smile
The socket name is returned by $sockname idenitifier.
In your script the socket name is Test so you can either use Test or $sockname .

Joined: May 2016
Posts: 50
T
Babel fish
OP Offline
Babel fish
T
Joined: May 2016
Posts: 50
So how should my script look? I don't quite get it. Sorry for the inconvenience


Life is potato.
Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Because you write stuff to the socket you have opened, after "sockwrite -nt " ,which the command that writes to socket , you must use $sockname
The sockopen command doesnt need the $sockname identifier after it because it opens the socket you want. In your case "test"
So to open the sockname as you did at original script
Code:
 
sockopen Test thefaaborg.dk 80 

And to write to the socket
Code:
sockwrite -nt $sockname <stuff here>

Also sockclose needs $sockname after it.
Code:
sockclose $sockname

P.S just to be clear: $sockname returns the name of the socket. That eans that whatever the name of the socket is it will take the place of $sockname as am argument.
Example: just like $nick returns the name of the user that triggers the on text event

Last edited by OrFeAsGr; 21/05/16 03:14 AM.
Joined: May 2016
Posts: 50
T
Babel fish
OP Offline
Babel fish
T
Joined: May 2016
Posts: 50
But now it just doen't do anything once i excecute it


Life is potato.
Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Try sending me the code as it is now smile

Joined: May 2016
Posts: 50
T
Babel fish
OP Offline
Babel fish
T
Joined: May 2016
Posts: 50
on *:TEXT:!connect:#magnusgameplay:{
sockopen Test thefaaborg.dk 80
}

on *:SOCKOPEN:Test: {
sockwrite -nt $sockname GET /protocal.html
sockwrite -nt $sockname Host: thefaaborg.dk
sockwrite $sockname $crlf
}

on *:SOCKREAD:Test: {
if (!$sockerr) {
var %sockreader
sockread %sockreader
if (For mig har chatten* iswm %sockreader) {
tokenize 32 %sockreader
Test $4
; Im trying to make it excecute a command here based on $4
sockclose Test
}
}
}


Life is potato.
Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Have you made an alias test? Maybe there is something wrong in that alias. Can i see it?
Also try adding
Code:
echo -a %sockreader

After the line you use sockread.that way you'll see if the page is written correctly/the connection is made proeprly.

Joined: May 2016
Posts: 50
T
Babel fish
OP Offline
Babel fish
T
Joined: May 2016
Posts: 50
This is the alias:
alias Test {
msg # test
}

It doesn't display anything once added the echo

on *:SOCKREAD:Test: {
if (!$sockerr) {
var %sockreader
sockread %sockreader
if (For mig har chatten* iswm %sockreader) {
tokenize 32 %sockreader
echo -a %sockreader
sockclose Test
}
}
}


Life is potato.
Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Ok so in the alias if you want to use the first parameter you need $1 and not #
(# returns the channel name in events such as on text, on join etc.)
So for example an alias works this way: if you do
test glass wood iron

In the alias test
$1 will return glass
$2 will return wood
$3 will return iron
And so on..
So try msg $1 test

And also what i meant was using echo before the if and after the sockread! That way everthing will be printed to the active window
EDIT: CORRECTED EXAMPLE (sorry i'm sleepy :p)

Last edited by OrFeAsGr; 21/05/16 03:40 AM.
Joined: May 2016
Posts: 50
T
Babel fish
OP Offline
Babel fish
T
Joined: May 2016
Posts: 50
It still does not return anything, I'm kinda noobie at mirc so maybe sockets just ain't for me BUT I need to get it working otherwise I can't use the bot for anything

on *:SOCKREAD:Test: {
echo -a %sockreader
if (!$sockerr) {
var %sockreader
sockread %sockreader
if (For mig har chatten* iswm %sockreader) {
tokenize 32 %sockreader

sockclose Test
}
echo -a %sockreader
}
}


Life is potato.
Joined: May 2016
Posts: 50
T
Babel fish
OP Offline
Babel fish
T
Joined: May 2016
Posts: 50
Hmmh seems as though I got it to work! now I just can't seem to take the thefaaborg magnusgameplay tillableToast and pick one of them using $2

on *:SOCKREAD:Test: {
if (!$sockerr) {
var %sockreader
sockread %sockreader
if (thefaaborg magnusgameplay tillableToast iswm %sockreader) {
tokenize 32 %sockreader
echo $2 (This right here should display magnusgameplay)
sockclose Test
}
}
}


Life is potato.
Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
TillableToast is in a different line and you tokenize the reader so you can make it:
Code:
if ($1-2 == thefaaborg magnusgameplay) {

The rest is fine

Joined: May 2016
Posts: 50
T
Babel fish
OP Offline
Babel fish
T
Joined: May 2016
Posts: 50
But what I want to do is to make it to a user clicks "Connect Bot" on my website (I have it hooked up to Twitch API) so that it then sends the Twitch username to the bot, so it knows what channel to connect to. So my idea was to make their twitch name appear in the HTML file, so that I then could grab it using the %socketreader


Life is potato.
Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
$2 will return the channel nam , you can do
join $2
In the if i told you and the bot will join!
On HTML i have no advices cause i dont know much.
I'll be back later! Need sleep! Cya!


Link Copied to Clipboard