This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| ______ ______ ______ __ __ __ ______ | |
| /\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\ | |
| \ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/ | |
| \ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\ | |
| \/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/ | |
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| ______ ______ ______ __ __ __ ______ | |
| /\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\ | |
| \ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/ | |
| \ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\ | |
| \/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/ | |
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| client.get('favorites/list', function(error, tweets, response){ | |
| if (!error) { | |
| console.log(tweets); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| client.get('search/tweets', {q: 'node.js'}, function(error, tweets, response){ | |
| console.log(tweets); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var tweetId = 'XXXXX'; | |
| client.post('statuses/retweet/' + tweetId, function(error, tweet, response){ | |
| if (!error) { | |
| console.log(tweet); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| u'\U00002764' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| u'\U0001f610' |