-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5fe1c3
commit a2aaf2e
Showing
14 changed files
with
347 additions
and
101 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,8 @@ HEALTHCHECK_ROUTE="/" | |
# Metadata route, defaults to "/botcommons" | ||
BOTCOMMONS_ROUTE="/botcommons" | ||
|
||
|
||
# Uncomment to use Redis storage | ||
# for local dev | ||
#REDIS_URL="redis://127.0.0.1:6379" | ||
# example for Heroku Redis | ||
#REDIS_URL="redis://h:[email protected]:60109" |
This file contains 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 file contains 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 file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This place is your chance to customize your bot configuration. | ||
|
||
Place here extra Botkit components you want to add, these will be loaded in alphabetical order. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Copyright (c) 2017 Cisco Systems | ||
// Licensed under the MIT License | ||
// | ||
|
||
/** | ||
* Adds a persistent storage to Redis to BotKit configuration | ||
* | ||
* Setup instructions: | ||
* - add a REDIS_URL env variable pointing to the redis instance | ||
* - add a project dependency to the 'botkit-storage-redis' module, aka "npm install botkit-storage-redis" | ||
* - [optional] customize the configuration below | ||
*/ | ||
module.exports = function (configuration) { | ||
|
||
if (process.env.REDIS_URL) { | ||
|
||
// Initialize Redis storage | ||
var redisConfig = { | ||
// for local dev: redis://127.0.0.1:6379 | ||
// if on heroku : redis://h:PASSWORD@ec2-54-86-77-126.compute-1.amazonaws.com:60109 | ||
url: process.env.REDIS_URL | ||
|
||
// uncomment to add extra global key spaces to store data, example: | ||
//, methods: ['activities'] | ||
|
||
// uncomment to override the Redis namespace prefix, Defaults to 'botkit:store', example: | ||
//, namespace: 'cisco:devnet' | ||
}; | ||
|
||
// Create Redis storage for BotKit | ||
try { | ||
var redisStorage = require('botkit-storage-redis')(redisConfig); | ||
|
||
configuration.storage = redisStorage; | ||
console.log("Redis storage successfully initialized"); | ||
|
||
// Note that we did not ping'ed Redis yet | ||
// then a 'ECONNREFUSED' error will be thrown if the Redis can be ping'ed later in the initialization process | ||
// which is fine in a "Fail Fast" strategy | ||
} | ||
catch (err) { | ||
console.log("Could not initialise Redis storage, check the provided Redis URL, err: " + err.message); | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// | ||
// Copyright (c) 2017 Cisco Systems | ||
// Licensed under the MIT License | ||
// | ||
|
||
module.exports = function (configuration) { | ||
|
||
// Botkit sends stats to the cloud by default | ||
// Uncomment to stop sending | ||
//configuration["stats_optout"] = true; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Place in this directory the extensions to be loaded into the bot spawned from BotKit controller. | ||
|
||
This is your opportunity to enrich the interactions with Cisco Spark. | ||
by adding extra properties and functions to the `bot` object passed to your skills. | ||
|
||
Examples: | ||
- appendMention utility: append the bot name to a command if the current room is a 'Group' space |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// Copyright (c) 2017 Cisco Systems | ||
// Licensed under the MIT License | ||
// | ||
|
||
/* | ||
* Utility to add mentions if Bot is in a 'Group' space | ||
* | ||
*/ | ||
module.exports = function (bot) { | ||
|
||
// Utility to add mentions if Bot is in a 'Group' space | ||
bot.appendMention = function (message, command) { | ||
|
||
// if the message is a raw message (from a post message callback such as bot.say()) | ||
if (message.roomType && (message.roomType == "group")) { | ||
var botName = bot.botkit.identity.displayName; | ||
return "`@" + botName + " " + command + "`"; | ||
} | ||
|
||
// if the message is a Botkit message | ||
if (message.raw_message && (message.raw_message.data.roomType == "group")) { | ||
var botName = bot.botkit.identity.displayName; | ||
return "`@" + botName + " " + command + "`"; | ||
} | ||
|
||
return "`" + command + "`"; | ||
} | ||
} |
This file contains 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
Oops, something went wrong.