Skip to content

Instantly share code, notes, and snippets.

@devStepsize
devStepsize / botkit_hears.js
Created April 22, 2016 18:42
Using Botkit's hears function to configure event handlers based on matching specific keywords or phrases in the message text
// From https://github.com/howdyai/botkit#matching-patterns-and-keywords-with-hears
controller.hears(['keyword','^pattern$'],['message_received'],function(bot,message) {
// do something to respond to message
bot.reply(message,'You used a keyword!');
});
// 1st arg - an array or a comma separated string containing a list of regular expressions to match
// 2nd arg - an array or a comma separated string of the message events in which to look for the patterns
@devStepsize
devStepsize / botkit_facebook_example.js
Created April 22, 2016 18:27
An example Botkit Facebook bot that can be connected to your Facebook page (from https://github.com/howdyai/botkit/blob/master/facebook_bot.js)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a sample Facebook bot built with Botkit.
This bot demonstrates many of the core features of Botkit:
* Connect to Facebook's Messenger APIs
* Receive messages based on "spoken" patterns
@devStepsize
devStepsize / botkit_slack_example1.js
Last active April 27, 2018 03:26
An example Botkit Slack bot that can be connected your team (from https://github.com/howdyai/botkit/blob/master/slack_bot.js)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a sample Slack bot built with Botkit.
This bot demonstrates many of the core features of Botkit:
* Connect to Slack using the real time API
* Receive messages based on "spoken" patterns
@devStepsize
devStepsize / botkit_hello.js
Last active April 22, 2016 18:33
Basic Botkit hello world example
// From https://github.com/howdyai/botkit#basic-usage
var Botkit = require('botkit');
var controller = Botkit.slackbot({
debug: false
//include "log: false" to disable logging
//or a "logLevel" integer from 0 to 7 to adjust logging verbosity
});
// connect the bot to a stream of messages
@devStepsize
devStepsize / twitter_image.js
Last active April 22, 2016 17:42
Send a new tweet with an image using the node-twitter library
// Load your image
var data = require('fs').readFileSync('image.jpg');
// Make post request on media endpoint. Pass file data as media parameter
client.post('media/upload', {media: data}, function(error, media, response){
if (!error) {
// If successful, a media object will be returned.
console.log(media);
@devStepsize
devStepsize / twitter_favourites.js
Created April 22, 2016 17:36
Get favourited tweets for the authenticated user using the node-twitter library
client.get('favorites/list', function(error, tweets, response){
if (!error) {
console.log(tweets);
}
});
@devStepsize
devStepsize / twitter_search.js
Created April 22, 2016 17:30
Search for tweets matching a query using the node-twitter library
client.get('search/tweets', {q: 'node.js'}, function(error, tweets, response){
console.log(tweets);
});
@devStepsize
devStepsize / twitter_retweet.js
Created April 22, 2016 17:29
Retweet a given tweet using the node-twitter library
var tweetId = 'XXXXX';
client.post('statuses/retweet/' + tweetId, function(error, tweet, response){
if (!error) {
console.log(tweet);
}
});
@devStepsize
devStepsize / emoji_heart_unicode.py
Created April 22, 2016 17:28
Unicode for the heart emoji
u'\U00002764'
@devStepsize
devStepsize / emoji_meh_unicode.py
Created April 22, 2016 17:25
Unicode for meh unicode
u'\U0001f610'