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

#1 2011-12-22 13:18:54

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

Chat.PY and Other Features

1. The chat has the same rules as the Scratch website

2. Follow Rule #1, it's the Golden Rule

3. No swearing, cussing, foul talk, or inappropriate language.

4. No linking to bad sites. ( Inappropriate, lots of swearing )

5. No asking about private information. ( their location, phone number, age, gender )

6. Behave. No flaming, being rude, talking rudely of others, and in general, be nice.

7. No spoofing. No impersonating other users or pretending to be them.

8. No spamming. No sending useless, annoying, non-related text to chat.

Any violation of the following rules will result in a warning, mute, or IP ban from the server.

Welcome to Chat.PY 2.0! (Or 2.0 Chat.PY, either works.)

Chat.PY is a chat/IRC like project for Scratch! The server was coded using Python, and you can see it's source here! You can chat in real-time with other Scratchers. I would ask that you be respectful to everyone, so follow the rules.  smile

There are a couple ways to connect. You can use Mesh, Remote Sensor Connections, or connect without leaving your browser (which currently doesn't work, sadly). The project is here! You will need to download it to connect through Mesh or Remote Sensor Connections.

Mesh - This is a good article on how to enable Mesh for Scratch. After you have it enabled; Shift-Click the "Share" option at the top, and the click "Join". Type in 'scratch.playfultest.tk' (no quotes) for the IP. After that, click the Green-flag and you should see 'Guest## has joined scratch!' (## being any number).

Remote Sensor Connections - Go to the Sensing section, scroll down to the bottom and right-click the Sensor Value Block and select "Enable Remote Sensor Connections". After that, open this. Once it says "Connected!" After that, click the Green-flag in Scratch and you should see 'Guest## has joined scratch!' (## being any number).

Browser - You can try it here. But it's kind of buggy and tends to disconnect.

Windows Executable - Thanks to Ohaider he has posted an EXE which you can download here.

If you have any questions, feel free to post them here!

I've noticed a bug where the 'Guest## has joined scratch!' doesn't show up when you first connect. Not sure what's wrong there though.

----

Okay. Some details on how the server works and how to use those commands on the side.

The server was built to work as a "plugin server". So the client tells the server what plugin it wants to use and the server acts accordingly.

So the first thing that is done, is it broadcasts "<chat2" to the server, telling it that it wants to use the chat2 (Chat.PY 2.0) plugin. Then the server passes on all the broadcast data starting with a colon ( smile  to the plugin that takes care of chat2 users. So you can broadcast ':switch-name new_name' and it'll switch your name to 'new_name'.

Since the plugin was coded to store all the data on the server, it stores that name and waits for you to send a message (through ':send message text here'). Once it receives the message it removes the colon and it checks the word right after the colon (which is 'send'), so it removes 'send' from the message and leaves the message that you want to send.

So it takes that message and looks at what room you are in (default is 'scratch') and then it checks which users are in the room and sends it to each user. The message is stored in the Sensor-value block with the name 'chat' (I think  tongue ) and then sends the broadcast 'new_message' so the client knows that there is new data in 'chat' and then displays it in the 'Log' list.

It basically does that for every command/broadcast sent. Checks to see if there is a colon ( smile  and sends it to all the plugins loaded for that user. So back to loading the plugin. When you tell the server which plugin you want to use, it loads the most recent version. So every time you send '<chat2', is removes the old version (so you end up loosing your name, authentication level, and the room you are in) and loads the new version (or the same version, but still removes the original one loaded).

So when you broadcast '<chat2' it checks to see if it's already been loaded, and if it has, removes it and loads it again. Always keeping you up to date, and I never have to restart the server unless it's part of the plugin server code itself. Less down time and more capability!

This also allows me to "host" multiple plugins, so I could actually run three different chat plugins on a single server. Though that's a waste, which is why I added rooms to Chat.PY. I can also host a multiplayer game (Virtual Space will eventually be one, hopefully) and Chat.PY on the same serve. And since they are separate plugins, they won't break each other.

Now onto how to use the commands! A few of the basic commands you should know is 'nick', 'room', 'list', and 'ascratch'. When typing in commands, you have to type a forward-slash (/) then enter, then the command, enter, and then type in the info it asks for. To make it simple for me, semi-colon ( wink  means "enter". So /;room;scratch is /, enter, room, enter, scratch, enter.

So /;nick;username changes your nick to 'username'. /;room;room_name switches which room you are in. /;list displays the users in the room. /;ascratch;username;password logs you into/authenticates you to your Scratch account.

I also don't store your passwords or usernames (so once it's used to authenticate you or not, it disappears). But even if you don't believe me, I plan on setting up a separate auth system which can be used as well.

Most of the other commands are mostly moderation commands. If you have any questions, feel free to ask them!

----

For anyone that wants a room for a collab, I am willing to make a room for it. Just ask and I'll get it created as soon as possible.

Last edited by Magnie (2012-04-04 15:20:24)

Offline

 

#2 2011-12-22 13:37:05

Tbtemplex97
Scratcher
Registered: 2011-11-12
Posts: 100+

Re: Chat.PY and Other Features

Amazing!"

YAY! First

Last edited by Tbtemplex97 (2011-12-30 16:33:05)


Online Status: http://blocks.scratchr.org/API.php?action=onlineStatus&amp;user=Tbtemplex97
Darkspace Coming Soon!, Try the Singleplayer Demo

Offline

 

#3 2011-12-22 13:39:35

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Chat.PY and Other Features

You should post the Python source, too, for Mac people.  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#4 2011-12-22 13:46:16

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

Re: Chat.PY and Other Features

Tbtemplex97: Could you post a screenshot or copy and paste the text here? On step 10 at the end, there is a "tutorial" on how to do that with the .exe

blob8108: Yeah, I was debating on that before I posted it. I added it to the post.  smile

Offline

 

#5 2011-12-22 14:15:48

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

Re: Chat.PY and Other Features

http://imageflock.com/img/1324581447.png

That's what I got when I ran it, and then when I ran your chat program, nothing happened when I sent messages.

Last edited by ohaiderstudios (2011-12-22 14:17:44)


Fork Clamor on GitHub!

Offline

 

#6 2011-12-22 14:35:42

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

Re: Chat.PY and Other Features

ohaiderstudios wrote:

http://imageflock.com/img/1324581447.png

That's what I got when I ran it, and then when I ran your chat program, nothing happened when I sent messages.

Hmm, I think I found the problem. It seems that when clients disconnect, they sometimes don't disconnect properly, and the server keeps dead threads alive, so when a living client sends a message that a dead thread is following, the living thread dies because it's trying to send a message over a non-existing connection.

So I need to do two things, fix the client so it disconnects properly, and set up the server so it dead threads actually die and don't exist anymore.

Last edited by Magnie (2011-12-22 14:36:33)

Offline

 

#7 2011-12-22 14:38:14

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

ohaiderstudios wrote:

http://imageflock.com/img/1324581447.png

That's what I got when I ran it, and then when I ran your chat program, nothing happened when I sent messages.

I got the exact same thing.  hmm


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#8 2011-12-22 14:58:06

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

Re: Chat.PY and Other Features

MathWizz wrote:

ohaiderstudios wrote:

http://imageflock.com/img/1324581447.png

That's what I got when I ran it, and then when I ran your chat program, nothing happened when I sent messages.

I got the exact same thing.  hmm

I've found the source of the error, I've fixed the code that has been posted, but the .exe will be out-dated for a bit till I have a fully functional mirror working.

Edit: The non-existing 'server' error has been fixed!

Last edited by Magnie (2011-12-22 15:06:59)

Offline

 

#9 2011-12-22 15:11:15

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Is the mirror just forwarding the connection from Scratch to the server?


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#10 2011-12-22 15:16:55

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

Re: Chat.PY and Other Features

MathWizz wrote:

Is the mirror just forwarding the connection from Scratch to the server?

Yeah

Offline

 

#11 2011-12-22 15:18:23

Servine
Scratcher
Registered: 2011-03-19
Posts: 1000+

Re: Chat.PY and Other Features

Hey magnie.

I accidentally put the wrong ip in, and it came up with the same error as in post 4. But when I did it right, it didnt even connect to scratch at all!


http://bluetetrarpg.x10.mx/usercard/?name=Servine

Offline

 

#12 2011-12-22 15:21:36

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

Re: Chat.PY and Other Features

Servine wrote:

Hey magnie.

I accidentally put the wrong ip in, and it came up with the same error as in post 4. But when I did it right, it didnt even connect to scratch at all!

Could you post the error?

Offline

 

#13 2011-12-22 15:31:51

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

I wrote my own mirror, but it's still not working. Is there a server error?


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#14 2011-12-22 15:33:09

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: Chat.PY and Other Features

Hi magnie I am working on the same kind of thing in JAVA and I have also had the same kind of problems with clients disconnecting my solution was to close the socket(socketname.close(); )on the client but also change my loop in my connection thread to a while loop (don't know the pyton equivalent) with the condition: !(not)socket.isclosed

I may try you program when I can


http://i.imgur.com/1QqnHxQ.png

Offline

 

#15 2011-12-22 15:33:46

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

Re: Chat.PY and Other Features

MathWizz wrote:

I wrote my own mirror, but it's still not working. Is there a server error?

No, I saw a connection from "68.72.x.x" is that you? ( http://whatismyip.com ) You haven't disconnected though.

Offline

 

#16 2011-12-22 15:35:37

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Magnie wrote:

MathWizz wrote:

I wrote my own mirror, but it's still not working. Is there a server error?

No, I saw a connection from "68.72.x.x" is that you? ( http://whatismyip.com ) You haven't disconnected though.

That's me.  hmm  I don't know what's wrong...

Last edited by MathWizz (2011-12-22 15:36:01)


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#17 2011-12-22 15:39:00

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Now my connection is getting refused.

EDIT: It wasn't your server. It was Scratch.  tongue

Last edited by MathWizz (2011-12-22 15:40:15)


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#18 2011-12-22 15:40:38

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

Re: Chat.PY and Other Features

MathWizz wrote:

Magnie wrote:

MathWizz wrote:

I wrote my own mirror, but it's still not working. Is there a server error?

No, I saw a connection from "68.72.x.x" is that you? ( http://whatismyip.com ) You haven't disconnected though.

That's me.  hmm  I don't know what's wrong...

Hmm.

Code:

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print("Connecting to Server...")
sock.connect(('scratch.playfultest.tk', 6112)) # Connect to Scratch
print("Connected to Server!")
sock.send("0000 broadcast '>test'")
print sock.recv(1024)
sock.close()
raw_input()

Not sure, but I'll watch and see if anything is sent and if you disconnect properly.

Edit: Oh, so you got it to work?

Last edited by Magnie (2011-12-22 15:41:20)

Offline

 

#19 2011-12-22 15:42:26

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Everything seems to be working, but I get nothing when I try to chat.

EDIT: I'm an idiot. I forwarded Scratch's output to your server, but not from your server to Scratch. Let me fix that....

Last edited by MathWizz (2011-12-22 15:45:18)


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#20 2011-12-22 15:46:35

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

Re: Chat.PY and Other Features

MathWizz wrote:

Everything seems to be working, but I get nothing when I try to chat.

EDIT: I'm an idiot. I forwarded Scratch's output to your server, but not from your server to Scratch. Let me fix that....

Hehe, I see a lot of connections from you.  tongue

Offline

 

#21 2011-12-22 15:48:13

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Magnie wrote:

MathWizz wrote:

Everything seems to be working, but I get nothing when I try to chat.

EDIT: I'm an idiot. I forwarded Scratch's output to your server, but not from your server to Scratch. Let me fix that....

Hehe, I see a lot of connections from you.  tongue

tongue


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#22 2011-12-22 15:53:55

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

I'm sure everything it working at this point (I am closing my connections properly too  tongue ) but still nothing is being received.


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#23 2011-12-22 15:55:23

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

Re: Chat.PY and Other Features

MathWizz wrote:

I'm sure everything it working at this point (I am closing my connections properly too  tongue ) but still nothing is being received.

Yeah, could you fix my mirror so it disconnects properly too?  tongue

I'm going to reset the server ( clear up dead threads and add some new code for monitoring ).

Edit: Reset ( it only takes like 30 seconds as long as there aren't any errors )

Last edited by Magnie (2011-12-22 15:57:31)

Offline

 

#24 2011-12-22 16:07:02

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Ok, hang on a sec...


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#25 2011-12-22 16:09:47

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Chat.PY and Other Features

Have you considered using a framework like Twisted for this sort of thing? I imagine it could make things easier (or sometimes just unnecessarily complicated  tongue )


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

Board footer