Skip to content

Instantly share code, notes, and snippets.

@shstkvch
Created April 22, 2012 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shstkvch/2466121 to your computer and use it in GitHub Desktop.
Save shstkvch/2466121 to your computer and use it in GitHub Desktop.
Facebook Scripting Concept
// Facebook User Scripting
// A (conceptual) scripting interface for Facebook (by David Hewitson, if it matters.)
var people_who_think_i_rock = 0;
me.onWallPost(function(post) {
// someone's posted on my wall!
if(post.message == 'You rock!') {
// someone thinks I rock!
post.like(); // like the post
people_who_think_i_rock++; // increment the rockometer
// send them a nice reply on their own wall
post.sender.wall.post('You rock too! (: <3 xoxoxo');
} else {
// do nothing
}
});
me.onChatMessage(function(message, chat) {
// someone's sent me a chat message!
if(message.text.toLowerCase() == 'hello') {
// someone said hello! say hello back...
chat.send_message('yo! did you know ' + people_who_think_i_rock + ' people think I rock?');
}
});
me.onFriendRequest(function(request) {
// zomfg new friend!
var new_friend = request.sender;
if(new_friend.sex == 'female' && new_friend.age >= 18) {
if(new_friend.can_message === true) { // can we send her a message?
new_friend.send_message('Hey there, ' + new_friend.name +
'! I\'m accepting your friend request because I like the ladieees!');
request.accept() // accept the request!
people_who_think_i_rock++; // I must seriously rock today
var ross = me.friends.get('36103013900913');
ross.send_message('DUDE! this girl added me: ' + new_friend.profile_url + '!');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment