New Casiocalc Inline Irc Client Preview
Started by
flyingfisch
, Mar 28 2012 03:14 PM
3 replies to this topic
#1
Posted 28 March 2012 - 03:14 PM
Several of you have contacted 2072 and I about having an IRC widget integrated into the site. 2072 and Forty-Two, who some of you may know as Seana11, made a great looking beta version for you to test out.
If you would like to help in testing, you can go here and try it out.
If you would like to help in testing, you can go here and try it out.
#2
Posted 28 March 2012 - 09:03 PM
Ok, so I'm going to try and explain how all of this works, as some people have it confused.
The architecture is composed to three sections: the IRC Bot, the PHP bit, and the Javascript client.
Sending a message from irc:
The bot listens on the irc channel irc://irc.afternet.org/#casiocalc and listens for things to happen. There are four types of messages supported at the moment: Errors (Used for displaying errors; don't occur normally, and should never be transmited), Messages (things people say), channel events (Like "Bob has joined the channel"), and actions (used with the /me command). When the bot recieves a message from the irc server, it addsd it to the queue. Once per seconds it flushes the queue, and sends it to http://api.casiocalc...entReceiver.php. The message is stored in json with the format: {message type, sender, message, timestamp}. The sha1 hash of the message is then computed. A random key is generated and attached as a get header. A predetermined key allows authentication to take place. A hash of the key, the salt, and the message's hash is included in a get header as well. This allows the php part to see if it's really the bot sending the message.
At the php end, it tests to see if the message is valid, and if it is, it adds it to the list of recent messages. The javascript portion of the client periodically (1300 ms) checks the list of recent messages to see if any new have been added. If they have, it updates the messages it displays.
Sending a message from the javascript client:
The javascript client sends the message to the php portion. The php portion adds it to its queue, and then gets the hash and sends it to the bot, in a similar fashion as before. The bot then relays it to the channel.
Note that I know a bit less about the inner workings of the php and javascript portions, as I did not write them. If you have any questions about those, please send them to 2072.
However, I did write the bot and I am planning to release its source after I add modules. This will allow stuff like incrementing (doing cheese++ will increment the score of cheese), and linking (typing ~intro may have the bot spit out a link to the introduction topic). If you want to know more about the bot, feel free to ask me in here, or poke me on irc.
The architecture is composed to three sections: the IRC Bot, the PHP bit, and the Javascript client.
Sending a message from irc:
The bot listens on the irc channel irc://irc.afternet.org/#casiocalc and listens for things to happen. There are four types of messages supported at the moment: Errors (Used for displaying errors; don't occur normally, and should never be transmited), Messages (things people say), channel events (Like "Bob has joined the channel"), and actions (used with the /me command). When the bot recieves a message from the irc server, it addsd it to the queue. Once per seconds it flushes the queue, and sends it to http://api.casiocalc...entReceiver.php. The message is stored in json with the format: {message type, sender, message, timestamp}. The sha1 hash of the message is then computed. A random key is generated and attached as a get header. A predetermined key allows authentication to take place. A hash of the key, the salt, and the message's hash is included in a get header as well. This allows the php part to see if it's really the bot sending the message.
At the php end, it tests to see if the message is valid, and if it is, it adds it to the list of recent messages. The javascript portion of the client periodically (1300 ms) checks the list of recent messages to see if any new have been added. If they have, it updates the messages it displays.
Sending a message from the javascript client:
The javascript client sends the message to the php portion. The php portion adds it to its queue, and then gets the hash and sends it to the bot, in a similar fashion as before. The bot then relays it to the channel.
Note that I know a bit less about the inner workings of the php and javascript portions, as I did not write them. If you have any questions about those, please send them to 2072.
However, I did write the bot and I am planning to release its source after I add modules. This will allow stuff like incrementing (doing cheese++ will increment the score of cheese), and linking (typing ~intro may have the bot spit out a link to the introduction topic). If you want to know more about the bot, feel free to ask me in here, or poke me on irc.
#3
Posted 07 April 2012 - 11:31 AM
I first wanted to post this to the announcement topic, then I thought I should keep there clean.
A way of maximizing the chat widget to fill the entire screen and also a way to make it floating and move it everywhere (as you scroll) will be useful too.
Forty-Two, you've mentioned modules will be implemented in the future, what are they and how they're made? Are they user-creatable plugins?
A way of maximizing the chat widget to fill the entire screen and also a way to make it floating and move it everywhere (as you scroll) will be useful too.
Forty-Two, you've mentioned modules will be implemented in the future, what are they and how they're made? Are they user-creatable plugins?
#4
Posted 07 April 2012 - 12:57 PM
I first wanted to post this to the announcement topic, then I thought I should keep there clean.
A way of maximizing the chat widget to fill the entire screen and also a way to make it floating and move it everywhere (as you scroll) will be useful too.
Forty-Two, you've mentioned modules will be implemented in the future, what are they and how they're made? Are they user-creatable plugins?
When I say modules, I'm talking about the bot end. They are basically just additional handlers that get called whenever I get a new message; for example:
@Override public void onMessage(String channel, String sender, String login, String hostname, String message) { if(!(channel.equals(talkChannel))) return; //Don't do anything if we aren't forwarding to this channel if(sender.equals(getName())) return; //Don't do anything if it's us that's talking logger.trace(channel+" "+sender+" "+login+" "+hostname+" "+message); //Logging for(MessageHandler handler: handlers) handler.handleSay(sender, message); //Calls the handleSay method of all handlers logger.trace(">>> ["+sender+"] "+message); //Logging }
During initialization, handlers is filled with messageHandlers:
package ucfirc; /** * Interface for message handlers * @author sean */ public interface MessageHandler { /** * Handles an error * @param error The error to handle * @see UcfBot#error(java.lang.String) error */ void handleError(String error); /** * Handles a message * @param user The user the message is from * @param message The message * @see UcfBot#say(java.lang.String, java.lang.String) say */ void handleSay(String user, String message); /** * Handles a chanel event * @param user The user the event applies to * @param message The message about the user * @see UcfBot#channel(java.lang.String, java.lang.String) channel */ void handleChannel(String user, String message); /** * Handles an action * @param user The user doing the action * @param action The action performed * @see UcfBot#action(java.lang.String, java.lang.String) action */ void handleAction(String user, String action); }
The module will then preform various actions based on the content of the message. (Like incrementing a counter, or sending something to the channel)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users