This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#126 2011-12-23 16:47:35

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Chat.PY and Other Features

Magnie wrote:

flashgocrazy wrote:

Magnie wrote:


There is a specific way to "redirect" it.

Have you even port-forwarded?

What program and what port?
Can't you just write a tut how to do this?

What I did to create this program:
Port-forwarded port: 6112
Created and tested the Python Server, Mirror, and project on my computer.
Compiled the Python Mirror into a .exe
Ran the server, went to http://canyouseeme.com, it said "Success! I can see your service!"
I also got my IP from there.
I posted my IP and project here and helped people connect.

I didn't do anything special ( except for redirecting the domain to my IP ).

Do you have to keep the python server app running every time you log on to your computer?


◕‿◕

Offline

 

#127 2011-12-23 16:53:12

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

flashgocrazy wrote:

Magnie wrote:

flashgocrazy wrote:


What program and what port?
Can't you just write a tut how to do this?

What I did to create this program:
Port-forwarded port: 6112
Created and tested the Python Server, Mirror, and project on my computer.
Compiled the Python Mirror into a .exe
Ran the server, went to http://canyouseeme.com, it said "Success! I can see your service!"
I also got my IP from there.
I posted my IP and project here and helped people connect.

I didn't do anything special ( except for redirecting the domain to my IP ).

Do you have to keep the python server app running every time you log on to your computer?

Yeah, I also have to leave my computer running 24/7 which should change once I get a real server.

Offline

 

#128 2011-12-23 17:28:31

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Chat.PY and Other Features

Code:

import socket
import time
from array import array

def sendScratchCommand(cmd):
    n = len(cmd)
    a = array('c')
    a.append(chr((n >> 24) & 0xFF))
    a.append(chr((n >> 16) & 0xFF))
    a.append(chr((n >>  8) & 0xFF))
    a.append(chr(n & 0xFF))
    return (a.tostring() + cmd)

sock = socket.socket()
sock.connect((socket.gethostbyname("scratch.playfultest.tk"), 6112))
name = raw_input("Name: ")
sock.send(sendScratchCommand('broadcast "<chat ' + name + ' has joined!"'))
msg = raw_input("Message: ")
while msg != "quit":
    sock.send(sendScratchCommand('broadcast "<chat ' + name + ': ' + msg + '"'))
    msg = raw_input("Message: ")
sock.close()

Magnie's requested code.

Last edited by ohaiderstudios (2011-12-23 17:30:32)


Fork Clamor on GitHub!

Offline

 

#129 2011-12-23 17:29:48

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

ohaiderstudios wrote:

Code:

import socket
import time
from array import array

def sendScratchCommand(cmd):
    n = len(cmd)
    a = array('c')
    a.append(chr((n >> 24) & 0xFF))
    a.append(chr((n >> 16) & 0xFF))
    a.append(chr((n >>  8) & 0xFF))
    a.append(chr(n & 0xFF))
    return (a.tostring() + cmd)

sock = socket.socket()
sock.connect((socket.gethostbyname("scratch.playfultest.tk"), 6112))
name = raw_input("Name: ")
msg = raw_input("Message: ")
while msg != "quit":
    sock.send(sendScratchCommand('broadcast "<chat ' + name + ': ' + msg + '"'))
    msg = raw_input("Message: ")
sock.close()

Magnie's requested code.

Sweet, thanks!

Offline

 

#130 2011-12-23 17:34:12

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Chat.PY and Other Features

Code:

import socket
import time

sock = socket.socket()
sock.connect((socket.gethostbyname("scratch.playfultest.tk"), 6112))
start = time.time()
sock.send("ping")
sock.recv(4)
end = time.time()
sock.close()
print("Response time: " + str(int(round((end - start) * 1000))) + "ms")

A simple ping script


Fork Clamor on GitHub!

Offline

 

#131 2011-12-23 17:55:33

rabbit1131
Scratcher
Registered: 2009-10-16
Posts: 1000+

Re: Chat.PY and Other Features

Why am I no longer able to connect?


The Intergalactic Adventures of Revesilia! I hope you will partake in this gigantic undertaking, to build the sequel to the hit map The Adventures of Revesilia! The Intergalactic Adventures of Revesilia Map Builders Application thread! http://internetometer.com/image/35004.png

Offline

 

#132 2011-12-23 18:07:19

gangsterpikachu
Scratcher
Registered: 2011-11-27
Posts: 2

Re: Chat.PY and Other Features

http://jsscratch.co.cc/MirrorApplet.html Doesn't work! I cant go to the page because its blocked. D:

Offline

 

#133 2011-12-23 18:23:23

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

gangsterpikachu wrote:

http://jsscratch.co.cc/MirrorApplet.html Doesn't work! I cant go to the page because its blocked. D:

Try: http://mirror.playfultest.tk

Offline

 

#134 2011-12-23 22:33:57

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Chat.PY and Other Features

I used to host a scratch server like you,
then I took an arrow to the knee  lol


◕‿◕

Offline

 

#135 2011-12-24 00:01:30

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

flashgocrazy wrote:

I used to host a scratch server like you,
then I took an arrow to the knee  lol

If you did, then you wouldn't be asking all these questions about port-forwarding and servers and stuff.

Offline

 

#136 2011-12-24 00:02:49

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Chat.PY and Other Features

Magnie wrote:

flashgocrazy wrote:

I used to host a scratch server like you,
then I took an arrow to the knee  lol

If you did, then you wouldn't be asking all these questions about port-forwarding and servers and stuff.

its a joke  lol

Last edited by flashgocrazy (2011-12-24 00:03:10)


◕‿◕

Offline

 

#137 2011-12-24 00:08:00

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

flashgocrazy wrote:

Magnie wrote:

flashgocrazy wrote:

I used to host a scratch server like you,
then I took an arrow to the knee  lol

If you did, then you wouldn't be asking all these questions about port-forwarding and servers and stuff.

its a joke  lol

Whatever, I've never played Skyrim.

Offline

 

#138 2011-12-24 02:36:07

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Chat.PY and Other Features

Okay, so after a good two hours on chat with magnie, we got a listening program put together...

Code:

import socket
import time
from array import array

def parseScratchCommand(cmd):
    cmd = cmd[4:] # Remove the first four letters ( it's annoying to deal with )
    cmd = cmd.split(' ') # Split the string where there is a space. It helps to find out broadcasts.
    return cmd # Return the list. ['broadcast/sensor-update', 'valueWord1', 'valueWord2']

sock = socket.socket()
sock.connect((socket.gethostbyname("scratch.playfultest.tk"), 6112))
sock.send('0000broadcast "^chat"')
while True:
    data = parseScratchCommand(sock.recv(1024))
    if data[0] == "sensor-update":
        data.pop(0)
        data.pop(0)
        data = " ".join(data)
        data = [x for x in data]
        data.pop(0)
        data.pop()
        data = "".join(data)
        print(data)
sock.close()

or...just click here for the executable (no Python needed)

most of the credit goes to Magnie, I just pieced everything together...

Last edited by ohaiderstudios (2011-12-24 02:39:06)


Fork Clamor on GitHub!

Offline

 

#139 2011-12-24 10:02:10

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

ohaiderstudios wrote:

Okay, so after a good two hours on chat with magnie, we got a listening program put together...

Code:

import socket
import time
from array import array

def parseScratchCommand(cmd):
    cmd = cmd[4:] # Remove the first four letters ( it's annoying to deal with )
    cmd = cmd.split(' ') # Split the string where there is a space. It helps to find out broadcasts.
    return cmd # Return the list. ['broadcast/sensor-update', 'valueWord1', 'valueWord2']

sock = socket.socket()
sock.connect((socket.gethostbyname("scratch.playfultest.tk"), 6112))
sock.send('0000broadcast "^chat"')
while True:
    data = parseScratchCommand(sock.recv(1024))
    if data[0] == "sensor-update":
        data.pop(0)
        data.pop(0)
        data = " ".join(data)
        data = [x for x in data]
        data.pop(0)
        data.pop()
        data = "".join(data)
        print(data)
sock.close()

or...just click here for the executable (no Python needed)

most of the credit goes to Magnie, I just pieced everything together...

Thanks for posting it.  big_smile

Edit: -- Announcement --

Some of you have already noticed, and some of you already know that it was coming out, but there is an auth system being implemented. It is currently unfinished, but it is far enough to release. Currently there are plans for a full set of levels,

* = Awesome Owner ( If you must, please ignore the "Awesome" part, it's an inside joke )
~ = Moderator
+ = Authenticated User
- = Unauthenticated User
! = Failed Login ( It's the same as Unauthenticated User, but means they failed to login )
# = Muted User ( Which you can't see because they are muted  tongue  )

It's probably pretty obvious what each does. Currently, *, -, !, and # have been added ( well, they are all accessible  ).

One of the downsides, is that currently the "name has joined!" does not work, nor does the /me feature because of how the system was programmed in 5 hours without being truly worked on. ( I was spending most of my time chatting instead of programming the system.  tongue  )

Currently, authenticating/logging in works, but the registration script has not been created. Though due to security reasons ( and the fact I don't want to deal with passwords ), instead of using "passwords" to login, it is called "secret word" which will act as the same thing, but it should not be your password you use for Scratch or for any other site! I suggest finding a password generator and using that to create a password.

I will probably add a little more security to the secret words, but for now, it doesn't contain any security ( secret words are currently stored in plain text, but I guess that is the only insecurity... I need to find SHA256 for Python... ). Just for those of you that know about how the chat project was created, the passwords and usernames themselves are not saved like a normal variable, they are replaced with a message that says whether you logged in or not.

Any suggestions before I start to finish the authentication system? Ways to make it more secure ( other than hashing the passwords )?

Last edited by Magnie (2011-12-24 10:41:48)

Offline

 

#140 2011-12-24 11:34:07

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Chat.PY and Other Features

Magnie wrote:

ohaiderstudios wrote:

Okay, so after a good two hours on chat with magnie, we got a listening program put together...

Code:

import socket
import time
from array import array

def parseScratchCommand(cmd):
    cmd = cmd[4:] # Remove the first four letters ( it's annoying to deal with )
    cmd = cmd.split(' ') # Split the string where there is a space. It helps to find out broadcasts.
    return cmd # Return the list. ['broadcast/sensor-update', 'valueWord1', 'valueWord2']

sock = socket.socket()
sock.connect((socket.gethostbyname("scratch.playfultest.tk"), 6112))
sock.send('0000broadcast "^chat"')
while True:
    data = parseScratchCommand(sock.recv(1024))
    if data[0] == "sensor-update":
        data.pop(0)
        data.pop(0)
        data = " ".join(data)
        data = [x for x in data]
        data.pop(0)
        data.pop()
        data = "".join(data)
        print(data)
sock.close()

or...just click here for the executable (no Python needed)

most of the credit goes to Magnie, I just pieced everything together...

Thanks for posting it.  big_smile

Edit: -- Announcement --

Some of you have already noticed, and some of you already know that it was coming out, but there is an auth system being implemented. It is currently unfinished, but it is far enough to release. Currently there are plans for a full set of levels,

* = Awesome Owner ( If you must, please ignore the "Awesome" part, it's an inside joke )
~ = Moderator
+ = Authenticated User
- = Unauthenticated User
! = Failed Login ( It's the same as Unauthenticated User, but means they failed to login )
# = Muted User ( Which you can't see because they are muted  tongue  )

It's probably pretty obvious what each does. Currently, *, -, !, and # have been added ( well, they are all accessible  ).

One of the downsides, is that currently the "name has joined!" does not work, nor does the /me feature because of how the system was programmed in 5 hours without being truly worked on. ( I was spending most of my time chatting instead of programming the system.  tongue  )

Currently, authenticating/logging in works, but the registration script has not been created. Though due to security reasons ( and the fact I don't want to deal with passwords ), instead of using "passwords" to login, it is called "secret word" which will act as the same thing, but it should not be your password you use for Scratch or for any other site! I suggest finding a password generator and using that to create a password.

I will probably add a little more security to the secret words, but for now, it doesn't contain any security ( secret words are currently stored in plain text, but I guess that is the only insecurity... I need to find SHA256 for Python... ). Just for those of you that know about how the chat project was created, the passwords and usernames themselves are not saved like a normal variable, they are replaced with a message that says whether you logged in or not.

Any suggestions before I start to finish the authentication system? Ways to make it more secure ( other than hashing the passwords )?

Use SH512, it's top notch, 128 bytes of hex!
HAng on, I have the code for it somewhere...

Code:

>>> import hashlib
>>> h = hashlib.sha512("secretword").hexdigest()
>>> print h
1820e422c49f9c504bd2f91ab84f33f6c1c338599d124610bdc28f55d9010f160e99dec6280e691552db90e37fba6bce7b8e536f509b244c2c8cb2e5b9dd7c03
>>>

Oh and btw....I CAN'T GET INTO CHAT!!!!!!!!!!


Fork Clamor on GitHub!

Offline

 

#141 2011-12-24 11:52:08

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

ohaiderstudios wrote:

Magnie wrote:

ohaiderstudios wrote:

Okay, so after a good two hours on chat with magnie, we got a listening program put together...

Code:

import socket
import time
from array import array

def parseScratchCommand(cmd):
    cmd = cmd[4:] # Remove the first four letters ( it's annoying to deal with )
    cmd = cmd.split(' ') # Split the string where there is a space. It helps to find out broadcasts.
    return cmd # Return the list. ['broadcast/sensor-update', 'valueWord1', 'valueWord2']

sock = socket.socket()
sock.connect((socket.gethostbyname("scratch.playfultest.tk"), 6112))
sock.send('0000broadcast "^chat"')
while True:
    data = parseScratchCommand(sock.recv(1024))
    if data[0] == "sensor-update":
        data.pop(0)
        data.pop(0)
        data = " ".join(data)
        data = [x for x in data]
        data.pop(0)
        data.pop()
        data = "".join(data)
        print(data)
sock.close()

or...just click here for the executable (no Python needed)

most of the credit goes to Magnie, I just pieced everything together...

Thanks for posting it.  big_smile

Edit: -- Announcement --

Some of you have already noticed, and some of you already know that it was coming out, but there is an auth system being implemented. It is currently unfinished, but it is far enough to release. Currently there are plans for a full set of levels,

* = Awesome Owner ( If you must, please ignore the "Awesome" part, it's an inside joke )
~ = Moderator
+ = Authenticated User
- = Unauthenticated User
! = Failed Login ( It's the same as Unauthenticated User, but means they failed to login )
# = Muted User ( Which you can't see because they are muted  tongue  )

It's probably pretty obvious what each does. Currently, *, -, !, and # have been added ( well, they are all accessible  ).

One of the downsides, is that currently the "name has joined!" does not work, nor does the /me feature because of how the system was programmed in 5 hours without being truly worked on. ( I was spending most of my time chatting instead of programming the system.  tongue  )

Currently, authenticating/logging in works, but the registration script has not been created. Though due to security reasons ( and the fact I don't want to deal with passwords ), instead of using "passwords" to login, it is called "secret word" which will act as the same thing, but it should not be your password you use for Scratch or for any other site! I suggest finding a password generator and using that to create a password.

I will probably add a little more security to the secret words, but for now, it doesn't contain any security ( secret words are currently stored in plain text, but I guess that is the only insecurity... I need to find SHA256 for Python... ). Just for those of you that know about how the chat project was created, the passwords and usernames themselves are not saved like a normal variable, they are replaced with a message that says whether you logged in or not.

Any suggestions before I start to finish the authentication system? Ways to make it more secure ( other than hashing the passwords )?

Use SH512, it's top notch, 128 bytes of hex!
HAng on, I have the code for it somewhere...

Code:

>>> import hashlib
>>> h = hashlib.sha512("secretword").hexdigest()
>>> print h
1820e422c49f9c504bd2f91ab84f33f6c1c338599d124610bdc28f55d9010f160e99dec6280e691552db90e37fba6bce7b8e536f509b244c2c8cb2e5b9dd7c03
>>>

Oh and btw....I CAN'T GET INTO CHAT!!!!!!!!!!

Thanks!

That's odd... cause others are in... did you able Remote Sensors?  tongue

Offline

 

#142 2011-12-24 11:53:37

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Chat.PY and Other Features

Magnie wrote:

ohaiderstudios wrote:

Magnie wrote:

ohaiderstudios wrote:

Okay, so after a good two hours on chat with magnie, we got a listening program put together...

Code:

import socket
import time
from array import array

def parseScratchCommand(cmd):
    cmd = cmd[4:] # Remove the first four letters ( it's annoying to deal with )
    cmd = cmd.split(' ') # Split the string where there is a space. It helps to find out broadcasts.
    return cmd # Return the list. ['broadcast/sensor-update', 'valueWord1', 'valueWord2']

sock = socket.socket()
sock.connect((socket.gethostbyname("scratch.playfultest.tk"), 6112))
sock.send('0000broadcast "^chat"')
while True:
    data = parseScratchCommand(sock.recv(1024))
    if data[0] == "sensor-update":
        data.pop(0)
        data.pop(0)
        data = " ".join(data)
        data = [x for x in data]
        data.pop(0)
        data.pop()
        data = "".join(data)
        print(data)
sock.close()

or...just click here for the executable (no Python needed)

most of the credit goes to Magnie, I just pieced everything together...

Thanks for posting it.  big_smile

Edit: -- Announcement --

Some of you have already noticed, and some of you already know that it was coming out, but there is an auth system being implemented. It is currently unfinished, but it is far enough to release. Currently there are plans for a full set of levels,


It's probably pretty obvious what each does. Currently, *, -, !, and # have been added ( well, they are all accessible  ).

One of the downsides, is that currently the "name has joined!" does not work, nor does the /me feature because of how the system was programmed in 5 hours without being truly worked on. ( I was spending most of my time chatting instead of programming the system.  tongue  )

Currently, authenticating/logging in works, but the registration script has not been created. Though due to security reasons ( and the fact I don't want to deal with passwords ), instead of using "passwords" to login, it is called "secret word" which will act as the same thing, but it should not be your password you use for Scratch or for any other site! I suggest finding a password generator and using that to create a password.

I will probably add a little more security to the secret words, but for now, it doesn't contain any security ( secret words are currently stored in plain text, but I guess that is the only insecurity... I need to find SHA256 for Python... ). Just for those of you that know about how the chat project was created, the passwords and usernames themselves are not saved like a normal variable, they are replaced with a message that says whether you logged in or not.

Any suggestions before I start to finish the authentication system? Ways to make it more secure ( other than hashing the passwords )?

Use SH512, it's top notch, 128 bytes of hex!
HAng on, I have the code for it somewhere...

Code:

>>> import hashlib
>>> h = hashlib.sha512("secretword").hexdigest()
>>> print h
1820e422c49f9c504bd2f91ab84f33f6c1c338599d124610bdc28f55d9010f160e99dec6280e691552db90e37fba6bce7b8e536f509b244c2c8cb2e5b9dd7c03
>>>

Oh and btw....I CAN'T GET INTO CHAT!!!!!!!!!!

Thanks!

That's odd... cause others are in... did you able Remote Sensors?  tongue

What? Yes...I'm using the latest Chat.py and the applet...
I'm listening to you, fresh, and LaPenguino on the listener thiough xD
Please help me!  sad


Fork Clamor on GitHub!

Offline

 

#143 2011-12-24 11:58:40

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Chat.PY and Other Features

I just lost communication from the server...I get an error in both applet and EXE

Pinging...

I still get response from ping with CMD, but not with my special program...:'(
I think it's something over on your side at this point.
Nothing more is coming through the listener either...> sad

Last edited by ohaiderstudios (2011-12-24 11:59:16)


Fork Clamor on GitHub!

Offline

 

#144 2011-12-24 12:05:17

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Chat.PY and Other Features

ohaiderstudios wrote:

I just lost communication from the server...I get an error in both applet and EXE

Pinging...

I still get response from ping with CMD, but not with my special program...:'(
I think it's something over on your side at this point.
Nothing more is coming through the listener either...> sad

Okay, I'm back on the listener, still no go for the chat proram itself...


Fork Clamor on GitHub!

Offline

 

#145 2011-12-24 12:09:33

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

ohaiderstudios wrote:

ohaiderstudios wrote:

I just lost communication from the server...I get an error in both applet and EXE

Pinging...

I still get response from ping with CMD, but not with my special program...:'(
I think it's something over on your side at this point.
Nothing more is coming through the listener either...> sad

Okay, I'm back on the listener, still no go for the chat proram itself...

What errors are you getting?

Offline

 

#146 2011-12-24 12:14:37

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Chat.PY and Other Features

Magnie wrote:

ohaiderstudios wrote:

ohaiderstudios wrote:

I just lost communication from the server...I get an error in both applet and EXE

Pinging...

I still get response from ping with CMD, but not with my special program...:'(
I think it's something over on your side at this point.
Nothing more is coming through the listener either...> sad

Okay, I'm back on the listener, still no go for the chat proram itself...

What errors are you getting?

No errors, just no worky...


Fork Clamor on GitHub!

Offline

 

#147 2011-12-24 12:26:42

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

ohaiderstudios wrote:

Magnie wrote:

ohaiderstudios wrote:


Okay, I'm back on the listener, still no go for the chat proram itself...

What errors are you getting?

No errors, just no worky...

Hmm... not sure... I'm currently fixing a few other problems, but the server will still be online.

I don't see what's wrong though.  hmm

Offline

 

#148 2011-12-24 14:12:50

FreshStudios
Scratcher
Registered: 2011-04-11
Posts: 500+

Re: Chat.PY and Other Features

Doesn't work  sad  It says "choose a file" when I try 2 open it?


http://i43.tinypic.com/24ymnbn.png

Offline

 

#149 2011-12-24 14:15:54

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

FreshStudios wrote:

Doesn't work  sad  It says "choose a file" when I try 2 open it?

It only works in Python.

Offline

 

#150 2011-12-24 14:24:56

FreshStudios
Scratcher
Registered: 2011-04-11
Posts: 500+

Re: Chat.PY and Other Features

OK so now we need to open python when we use it?


http://i43.tinypic.com/24ymnbn.png

Offline

 

Board footer