commit 99ccc692baf18969a788d14596909715287d08ef Author: kts Date: Thu May 14 05:46:42 2015 -0700 Initial commit of TwittMUD, yo. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d344ba6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.json diff --git a/background_1500x500.png b/background_1500x500.png new file mode 100644 index 0000000..0ca5aff Binary files /dev/null and b/background_1500x500.png differ diff --git a/background_96x32.png b/background_96x32.png new file mode 100644 index 0000000..2704cb3 Binary files /dev/null and b/background_96x32.png differ diff --git a/config.json b/config.json new file mode 100644 index 0000000..4a63f4a --- /dev/null +++ b/config.json @@ -0,0 +1,6 @@ +{ + "consumer_key": "", + "consumer_secret": "", + "access_token": "", + "access_token_secret": "" +} diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..2c62f66 Binary files /dev/null and b/icon.png differ diff --git a/icon_400x400.png b/icon_400x400.png new file mode 100644 index 0000000..fd6d557 Binary files /dev/null and b/icon_400x400.png differ diff --git a/index.js b/index.js new file mode 100644 index 0000000..3b2f0aa --- /dev/null +++ b/index.js @@ -0,0 +1,95 @@ +/* TwittMUD - Twitter Multi-User Dungeon +```````````````````````````````````````````````````````````````````````````````` +This is a weird program that runs a MUD from a Twitter account. + +Tweet limit: 123 characters, due to 140 (max) - 17 ('@' + name max + ' ') + +Tweet Transaction example: + a: You are in a white room. There is a painting. There are exits: north, east, west, south + b: @TwittMUD examine painting + a: The painting is by Rembrant, it looks expensive. + b: @TwittMUD take painting + a: You take the painting. + b: @TwittMUD south + a: You are on a balcony overlooking the ocean. There is a lighthouse. There are exits: north +*/ +var Twit = require('twit'); +var fs = require('fs'); +/* ================ Core Program Data ================ */ +var config = {}; +var client = null; +var stream = null; + +var vol = { + last_tweet_id: 0 +}; +/* ================ Main ================ */ +var gogogo = function() { + try { + config = JSON.parse(fs.readFileSync("./config.json", "utf8")); + } catch(e) { + console.log(e); + return 1; + } + client = new Twit({ + consumer_key: config.consumer_key, + consumer_secret: config.consumer_secret, + access_token: config.access_token, + access_token_secret: config.access_token_secret + }); + stream = client.stream('user', {with: 'user'}); + stream.on('follow', handleFollow); + stream.on('unfollow', handleUnfollow); + stream.on('tweet', handleTweet); + stream.on('error', handleError); +}; +/* ================ Handler Functions (events, tweets, etc.) ================ */ +/* handleTweet +Called on each tweet to this Twitter account. +*/ +var handleTweet = function(tweet) { + vol.last_tweet_id = tweet.id; + // does the response match + var user = tweet.text.split + console.log(tweet); + return true; +}; +/* handleFollow +This function is called whenever the stream receives a 'follow' user event. This will trigger the activateUser for the given user_id. +*/ +var handleFollow = function(event) { + console.log(event); +}; +/* handleUnfollow +*/ +var handleUnfollow = function(event) { + console.log(event); +}; +/* handleError +*/ +var handleError = function(event) { + console.log(err); +}; +/* ================ Activity Functions (tweeting, etc.) ================ */ +var tweetAt = function(user_id, tweet) { + +}; +var replyTweet = function(tweet_id, user_id, tweet) { +}; +/* ================ User Activate/Deactivate Functions ================ */ +/* activateUser +Removes the given user from the "Inactive Players" list and adds them to the "Active Players" list, thereby making them available for gameplay commands. +*/ +var activateUser = function(user) { +}; +/* deactivateUser +Removes the given user from the "Active Players" list and adds them to the "Inactive Players" list, thereby making them unavailable for gameplay commands. The user may still provide the "deactivate" or "restart" commands. +*/ +var deactivateUser = function(user) { +}; +/* deleteUser +Removes all user information - this is only ever emitted when the user unfollows @TwittMUD. +*/ +var deleteUser = function(user) { +}; +gogogo(); diff --git a/package.json b/package.json new file mode 100644 index 0000000..a3c606b --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "TwittMUD", + "version": "0.0.0", + "description": "A multi-user dungeon system written for Twitter", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "MUD", + "twitter", + "server", + "engine" + ], + "author": "kts of kettek (https://kettek.net/)", + "license": "GPLv3" +}