FireChat is a program that showcases my own server, FireMMO (FireMMO has it's own thread here) With little coding, FireMMO can do almost anything. As a matter of fact, FireChat is only a few lines long. (FireMMO is a few hundred lines long. Oh...the pain)
Woo-Hoo! PMing is now supported. Get the new client!
The server is currently On.
Outdated, ignore: Notice: Currently, the server is turned off. I am working on some functionality that is crucial. It has to do with the mirror, and the mirror's will be obsolete. FireChat will not be online for a while until I can get this to work properly (or revert to my old method. Reply if you have any questions.
Here's instructions to get connected.
1) Download and open up FireChat
1a) Link here
1b) Does a dialog enabling Remote Sensors Connections come up?
1ba) If yes, click okay. Proceed to step 2
1bb) If no, go to sensing, and right-click the slider sensor value block at the bottom. Click enable remote sensors connections.
2) Run the python mirror:
2a) Source is this:
# Scratch Mirror # Version 1.5.0 # Originally by: Magnie. Modified by bobbybee for use in FireMMO import socket # Network base import time # For delaying purposes mostly. import threading # So it can send and receive at the same time anytime. import array # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # # CHOST is the IP Scratch is running on, if you are running it # # on this computer, then the IP is 127.0.0.1 # # Theoretically you could run this Mirror on another computer. # # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # # CPOST is the port Scratch is listening on, the default is # # 42001. Usually this is only change by a Scratcher who knows a # # about Squeak and networking with sockets. # # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # CHOST = '127.0.0.1' CPORT = 42001 # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # # SHOST is the IP the server is running on. # # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # # SPORT is the port that the server is using. 42002 is the # # unofficial port for Scratch Servers. The host will need to make # # sure to port-forward the port so people can connect from the # # internet. # # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # SHOST = 'firechat.servequake.com' SPORT = 42002 # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # # Some extra settings that are more for advanced users are below. # # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # # Time between checking the threads for broken ones. THREADCHECK = 5 class Client(threading.Thread): # This class listens for messages sent from Scratch and sends it to the Server. def parse_message(self, message): if message: sensors = {} broadcasts = [] commands = [] i = 0 while True: length = ord(message[i]) + ord(message[i+1]) + ord(message[i+2]) + ord(message[i+3]) command = message[i + 4:i + length + 4] commands.append(command) if (i + length + 4) < len(message): i = (i+4) + length else: del command break for command in commands: print command if command[0] == 'b': command = command.split('"') command.pop(0) broadcasts.append(command[0]) elif command[0] == 's': command = command.split('"') command.pop(0) print(command); try: command.remove(' ') except ValueError: pass sensors[command[0]] = command[1] return dict([('sensor-update', sensors), ('broadcast', broadcasts)]) else: return None def sendScratchCommand(self, 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)) server.sock.send(a.tostring() + cmd) def __init__(self, CHOST, CPORT): threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread. self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 ) print("Connecting to Scratch...") self.sock.connect((CHOST, CPORT)) # Connect to Scratch print("Connected to Scratch!") def run(self): global running print "Listening for Scratch messages." while running: data = self.sock.recv(1024) # Wait for something to be sent to the mirror data = self.parse_message(data) for sensor in data['sensor-update']: if sensor == "packet": self.send(data['sensor-update'][sensor]) def send(self, message): server.sock.send(message) # Send the data to the server. class Server(threading.Thread): # This class listens for messages from the Server and sends it to Scratch. def sendScratchCommand(self, cmd): n = len(cmd) a = [] a.append(chr((n >> 24) & 0xFF)) a.append(chr((n >> 16) & 0xFF)) a.append(chr((n >> 8) & 0xFF)) a.append(chr(n & 0xFF)) scratch.sock.send(''.join(a) + cmd) def __init__(self, SHOST, SPORT): threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread. self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 ) print("Connecting to Scratch Server...") self.sock.connect((SHOST, SPORT)) # Connect to the Server. print("Connected to Server!") def run(self): global running print "Listening for Server messages." while running: data = self.sock.recv(1024) # Listens for messages sent from the Server. self.sendScratchCommand("sensor-update packet \""+data+"\""); self.sendScratchCommand("broadcast dataready") def send(self, message): scratch.sock.send(message) # Sends messages to Scratch. running = 1 scratch = Client(CHOST, CPORT) # Start up the class for Scratch scratch.start() # This starts the 'run' function. server = Server(SHOST, SPORT) # Start up the class for Server server.start() # This starts the 'run' function on the class as well. while running: time.sleep(THREADCHECK) # The longer the wait time, the less CPU is used I think. try: # Check if the either thread died ( or exists anymore ). if scratch: pass if server: pass except: # If either are dead, end the program. running = 0 print "Finished running."
2b) Install python, if it's not installed already.
2c) Run the program.
3) Talk. Press the green-flag and chat!
If there are errors, post on this thread.
Known Bugs/Glitches:
-Forward slash (/) and double-quotes (") don't work.
Rules:
-No spamming
-No swearing/inappropriate content such as adult content
-No spoofing
-No hacking, or talking about illegal activities such as warez, or malware.
-Treat respectfully
-One account per person
Special Thanks to Magnie, the Scratcher who helped FireMMO succeed (and inspired me to make FireChat)
Last edited by bobbybee (2012-03-16 18:42:13)
Offline
Now you are going to be asked to make join and leave messages. Then you are going to end up being spammed, so then you will want to add admins/mods, and then others will want to be able to keep their name secure and ask you to create a register, etc.
Out of curiosity, are there any other commands? You may also want to mention /s (forward slashes) and "s (double-quotes) don't work.
Love the title.
Last edited by Magnie (2012-02-24 10:00:10)
Offline
I mentioned the glitches, I added rules. Join, leave, kick, and ban are easy. (ban is hard for me, though). I'll report a user if they spam (or break any rules, for that matter). It's okay if you say no, but do you want to be an admin/mod? I'll probably implement a profanity filter anyways.
Offline
I'll deny the offer. I've realized after many years, that being a moderator or admin is probably one of the hardest things ever.
Also, another tip/idea, I suggest putting the "Server: On" at the top of the topic-post.
Offline
I agree. I'm only doing it because it's my chat room. I'll put the server indicator at the top. Can you test the new joining/leaving functionality in a few minutes. I wrote some code for join message. (not yet leaving, leavings insane (not really, just lazy ) ...)
Offline
I see one problem. I have a sibling, username puppymk, who would also probably want to use this chat. However, because of the last rule (One account per person), If we both set up accounts, It would look like we were the same person because we are on the same Wi-Fi network. Any ideas on how this could work? (Or is this not something I need to worry about?)
Offline
That's a flaw, I guess. I just feel that if I say 1 account per Scratch account, people are going to spam, because if they get 1 account banned, they'll sign up using a test account. Maybe I'll say something like, "If you have a particular reason for needing several accounts, ask me and I may be able to bend the rules for you," or something similar.
Offline
Which version of Python is this made in?
Offline
Not sure. I think it is 2.something. You'd have to ask Magnie, though. Do you want to chat on this?
Offline
It's Python 2.7
I'll work on an .exe for this later.
Edit:
Here is an EXE for the mirror. Extract it, there will be a folder called "FireChatMirror" open that up then start up mirror.exe.
Last edited by Magnie (2012-02-24 13:28:21)
Offline
If I understand this right I need to be connected on an ip via mesh. Right? Because it's not working for me D:
edit: Thanks magnie for the exe
Last edited by slinger (2012-02-24 13:36:05)
Offline
slinger wrote:
If I understand this right I need to be connected on an ip via mesh. Right? Because it's not working for me D:
edit: Thanks magnie for the exe
Did you enable remote sensors, etc?
Cause I'm not receiving messages either.
Offline
slinger wrote:
Well I'm not sure what you mean by enable remote sensors.
edit: Aww can't be on now D:
Offline
Magnie wrote:
It's Python 2.7
I'll work on an .exe for this later.
Edit:
Here is an EXE for the mirror. Extract it, there will be a folder called "FireChatMirror" open that up then start up mirror.exe.
can you make it a mac app?
Offline
muppetds wrote:
Magnie wrote:
It's Python 2.7
I'll work on an .exe for this later.
Edit:
Here is an EXE for the mirror. Extract it, there will be a folder called "FireChatMirror" open that up then start up mirror.exe.can you make it a mac app?
Well, I attempted to make one, but I got an error in the "compiler" so I'm afraid not. Sorry. I attempted to use this on a Windows computer (which may be the problem, since I don't have a Mac). So if anyone else wants to try.
Offline
I'll try it (I'm on a mac)
(wow, my discussion on my thread while I'm not even on...)
Offline
Also Magnie, I received all of your messages (through the server anyways) Do you know if the mirror was receiving the messages?
Offline
bobbybee wrote:
Also Magnie, I received all of your messages (through the server anyways) Do you know if the mirror was receiving the messages?
No, I didn't receive any of my messages.
Offline
Magnie wrote:
bobbybee wrote:
Also Magnie, I received all of your messages (through the server anyways) Do you know if the mirror was receiving the messages?
No, I didn't receive any of my messages.
Maybe it doesn't send back the message you added?
Offline
I have a feeling it has to do something with the mirror...it never worked consistently for me. The thread terminates half the time...
Offline
I restarted the server, and it's running a clean binary now. I have a feeling I was running a weird version of FireMMO...
Try connecting now.
EDIT: Found the source of my grief. The connections should work now.
Last edited by bobbybee (2012-02-24 19:25:27)
Offline
I think I got leaving working right. Also, here is what I plan on doing and when:
-Profanity Filter
-Kicks
-Bans
-Timestamps
-IRC stuff...
Offline
How do I run the mirror?
Offline
ImagineIt wrote:
How do I run the mirror?
If you have Python 2.7, you would just double-click the file (I'm pretty sure). If you don't have Python, then you can use this EXE version: http://scratch.mit.edu/forums/viewtopic … 8#p1151288
Offline