├── .gitignore ├── Procfile ├── screenshot.png ├── app.json ├── package.json ├── index.js ├── README.md └── books.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: node index.js 2 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brandonhorst/slack-bible/HEAD/screenshot.png -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BibleBot", 3 | "description": "Reply to slack messages containing bible verses", 4 | "repository": "https://github.com/brandonhorst/bible-bot", 5 | "keywords": ["slack", "bible", "biblegateway"] 6 | } 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "slack-bible", 3 | "version": "1.0.0", 4 | "description": "Post links to bible verses in Slack", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js" 8 | }, 9 | "dependencies": { 10 | "body-parser": "^1.12.3", 11 | "express": "^4.12.3", 12 | "lodash": "^3.8.0" 13 | }, 14 | "engines": { 15 | "node": "0.12.2" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/brandonhorst/slack-bible.git" 20 | }, 21 | "keywords": [ 22 | "slack", 23 | "bible", 24 | "biblegateway" 25 | ], 26 | "license": "MIT", 27 | "bugs": { 28 | "url": "https://github.com/brandonhorst/slack-bible/issues" 29 | }, 30 | "homepage": "https://github.com/brandonhorst/slack-bible", 31 | "devDependencies": {}, 32 | "author": "@brandonhorst" 33 | } 34 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var _ = require('lodash') 2 | var bodyParser = require('body-parser') 3 | var books = require('./books') 4 | var express = require('express') 5 | var app = express() 6 | 7 | app.use(bodyParser.urlencoded({extended: true})) 8 | app.set('port', (process.env.PORT || 5000)) 9 | app.use(express.static(__dirname + '/public')) 10 | 11 | var booksWithPipes = _.chain(books).values().flatten().join('|').value() 12 | var regex = new RegExp('(' + booksWithPipes + ')\\.?\\s*(\\d{1,3})(?:\\s*[\\:\\s]\\s*(\\d{1,3})(?:\\s*[\\-\\s]\\s*(\\d{1,3}))?)?', 'ig') 13 | 14 | function reverseLookup (abbr) { 15 | return _.findKey(books, function (abbrs) {return _.includes(abbrs, abbr.toLowerCase())}) 16 | } 17 | 18 | app.post('/', function(request, response) { 19 | var inputText = request.body.text 20 | 21 | var res, results = [] 22 | while ((res = regex.exec(inputText)) !== null) { 23 | var trueRef = reverseLookup(res[1]) + '+' + res[2] 24 | if (res[3]) trueRef += ':' + res[3] 25 | if (res[4]) trueRef += '-' + res[4] 26 | results.push(trueRef) 27 | } 28 | 29 | if (results.length > 0) { 30 | var attachments = _.map(results, function (result) { 31 | var title = result.replace('+', ' ') 32 | var link = 'https://biblegateway.com/bible?passage=' + result 33 | 34 | return { 35 | title: title, 36 | title_link: link, 37 | fallback: title + ' - ' + link, 38 | color: 'good' 39 | } 40 | }) 41 | 42 | response.json({text: 'Referenced verses:', attachments: attachments}) 43 | } else { 44 | response.json({}) 45 | } 46 | }) 47 | 48 | app.listen(app.get('port'), function() { 49 | console.log('Node app is running on port', app.get('port')) 50 | }) 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #bible-bot 2 | 3 | Slack bot to detect Bible Verse References in your public Slack posts, and supply links to the verses on BibleGateway. 4 | 5 | ## Usage 6 | 7 | ![Example usage screenshot](https://raw.github.com/brandonhorst/bible-bot/master/screenshot.png) 8 | 9 | ## Configuration 10 | 11 | You can download the source and host it yourself, or you can access the public, free hosted version at https://bible-bot.herokuapp.com. 12 | 13 | Create a new "Outgoing WebHooks" Slack Integration: 14 | 15 | - Either pick a `Channel` for the bot to operate on, or pick a list of `Trigger Words`. A recommended trigger word list is supplied below, which will activate if any post starts with `bible`, `bib`, `b`, or any valid bible chapter or abbreviation. 16 | - `URL`: `https://bible-bot.herokuapp.com` 17 | - `Token` is unused 18 | 19 | 20 | ### Abbreviations 21 | 22 | Taken from [here](https://www.logos.com/support/windows/L3/book_abbreviations) 23 | 24 | 25 | ### Here is a useful list of trigger words 26 | 27 | ``` 28 | bible, bib, b, 1 ch,1 chr,1 chron,1 chronicles,1 co,1 cor,1 corinthians,1 esd,1 esdr,1 esdras,1 jhn,1 jn,1 john,1 kgs,1 ki,1 kings,1 mac,1 macc,1 maccabees,1 pe,1 pet,1 peter,1 pt,1 sa,1 sam,1 samuel,1 sm,1 th,1 thess,1 thessalonians,1 ti,1 tim,1 timothy,1ch,1chr,1chron,1chronicles,1co,1cor,1corinthians,1es,1esd,1esdr,1esdras,1jhn,1jn,1jo,1joh,1john,1k,1kgs,1ki,1kin,1kings,1m,1ma,1mac,1macc,1maccabees,1pe,1pet,1peter,1pt,1s,1sa,1sam,1samuel,1st chronicles,1st corinthians,1st esdras,1st john,1st kgs,1st kings,1st maccabees,1st peter,1st samuel,1st thessalonians,1st timothy,1th,1thes,1thess,1thessalonians,1ti,1tim,1timothy,2 ch,2 chron,2 chronicles,2 co,2 cor,2 corinthians,2 esd,2 esdr,2 esdras,2 jhn,2 jn,2 john,2 kgs,2 ki,2 kings,2 mac,2 macc,2 maccabees,2 pe,2 pet,2 peter,2 pt,2 sa,2 sam,2 samuel,2 sm,2 th,2 thess,2 thessalonians,2 ti,2 tim,2 timothy,2ch,2chr,2chron,2chronicles,2co,2cor,2corinthians,2es,2esd,2esdr,2esdras,2jhn,2jn,2jo,2joh,2john,2k,2kgs,2ki,2kin,2kings,2m,2ma,2mac,2macc,2maccabees,2nd chronicles,2nd corinthians,2nd esdras,2nd john,2nd kgs,2nd kings,2nd maccabees,2nd peter,2nd samuel,2nd thessalonians,2nd timothy,2pe,2pet,2peter,2pt,2s,2sa,2sam,2samuel,2th,2thes,2thess,2thessalonians,2ti,2tim,2timothy,3 jhn,3 jn,3 john,3 mac,3 macc,3 maccabees,3jhn,3jn,3jo,3joh,3john,3ma,3mac,3macc,3rd john,3rd maccabees,4 mac,4 macc,4 maccabees,4ma,4mac,4macc,4maccabees,4th maccabees,ac,acts,add es,add esth,add ps,add psalm,addesth,additional psalm,additions to esther,aes,am,amos,azariah,bar,baruch,bel,bel and the dragon,canticle of canticles,canticles,col,colossians,da,dan,daniel,deut,deuteronomy,dn,dt,ec,ecc,eccles,ecclesiastes,ecclesiasticus,ecclus,ep laod,eph,ephes,ephesians,epist laodiceans,epistle laodiceans,epistle to laodiceans,epistle to the laodiceans,es,esth,esther,ex,exo,exod,exodus,eze,ezek,ezekiel,ezk,ezr,ezra,first chronicles,first corinthians,first esdras,first john,first kgs,first kings,first maccabees,first peter,first samuel,first thessalonians,first timothy,fourth maccabees,ga,gal,galatians,ge,gen,genesis,gn,hab,habakkuk,hag,haggai,heb,hebrews,hg,ho,hos,hosea,i ch,i chr,i chron,i chronicles,i co,i cor,i corinthians,i es,i esd,i esdr,i esdras,i jhn,i jn,i jo,i joh,i john,i kgs,i ki,i kings,i ma,i mac,i macc,i maccabees,i pe,i pet,i peter,i pt,i sa,i sam,i samuel,i th,i thes,i thess,i thessalonians,i ti,i tim,i timothy,ii ch,ii chr,ii chron,ii chronicles,ii co,ii cor,ii corinthians,ii es,ii esd,ii esdr,ii esdras,ii jhn,ii jn,ii jo,ii joh,ii john,ii kgs,ii ki,ii kings,ii ma,ii mac,ii macc,ii maccabees,ii pe,ii pet,ii peter,ii pt,ii sa,ii sam,ii samuel,ii th,ii thes,ii thess,ii thessalonians,ii ti,ii tim,ii timothy,iii jhn,iii jn,iii jo,iii joh,iii john,iii ma,iii mac,iii macc,iii maccabees,iiii maccabees,is,isa,isaiah,iv ma,iv mac,iv macc,iv maccabees,james,jas,jb,jdg,jdgs,jdt,jdth,je,jer,jeremiah,jg,jhn,jl,jm,jn,jnh,job,joe,joel,john,jon,jonah,jos,josh,joshua,jr,jsh,jth,jud,jude,judg,judges,judith,la,lam,lamentations,laod,laodiceans,le,let jer,letter of jeremiah,lev,leviticus,lje,lk,ltr jer,luk,luke,lv,mal,malachi,mark,matt,matthew,mic,micah,mk,ml,mr,mrk,mt,na,nah,nahum,nb,ne,neh,nehemiah,nm,nu,num,numbers,ob,obad,obadiah,ode,phil,philem,philemon,philippians,phm,php,pma,pr,pr az,pr man,pr of man,prayer of azariah,prayer of manasseh,prayer of manasses,prov,proverbs,prv,ps,ps sol,ps solomon,psa,psalm,psalms,psalms of solomon,psalms solomon,pslm,psm,pss,pssol,qoh,qoheleth,re,rest of esther,rev,revelation,rm,ro,rom,romans,rth,ru,ruth,second chronicles,second corinthians,second esdras,second john,second kgs,second kings,second maccabees,second peter,second samuel,second thessalonians,second timothy,sir,sirach,so,song,song of solomon,song of songs,song of the three holy children,song of thr,song of three,song of three children,song of three jews,song of three youths,song thr,sos,sus,susanna,tb,the rest of esther,the revelation,the song of the three holy children,the song of three jews,the song of three youths,third john,third maccabees,tit,titus,tob,tobit,wis,wisd of sol,wisdom,wisdom of solomon,ws,zc,zec,zech,zechariah,zep,zeph,zephaniah,zp 29 | ``` 30 | -------------------------------------------------------------------------------- /books.json: -------------------------------------------------------------------------------- 1 | { 2 | "Genesis": ["genesis", "gen", "ge", "gn"], 3 | "Exodus": ["exodus", "exo", "ex", "exod"], 4 | "Leviticus": ["leviticus", "lev", "le", "lv"], 5 | "Numbers": ["numbers", "num", "nu", "nm", "nb"], 6 | "Deuteronomy": ["deuteronomy", "deut", "dt"], 7 | "Joshua": ["joshua", "josh", "jos", "jsh"], 8 | "Judges": ["judges", "judg", "jdg", "jg", "jdgs"], 9 | "Ruth": ["ruth", "rth", "ru"], 10 | "1 Samuel": ["1 samuel", "1 sam", "1 sa", "1samuel", "1s", "i sa", "1 sm", "1sa", "i sam", "1sam", "i samuel", "1st samuel", "first samuel"], 11 | "2 Samuel": ["2 samuel", "2 sam", "2 sa", "2s", "ii sa", "2 sm", "2sa", "ii sam", "2sam", "ii samuel", "2samuel", "2nd samuel", "second samuel"], 12 | "1 Kings": ["1 kings", "1 kgs", "1 ki", "1k", "i kgs", "1kgs", "i ki", "1ki", "i kings", "1kings", "1st kgs", "1st kings", "first kings", "first kgs", "1kin"], 13 | "2 Kings": ["2 kings", "2 kgs", "2 ki", "2k", "ii kgs", "2kgs", "ii ki", "2ki", "ii kings", "2kings", "2nd kgs", "2nd kings", "second kings", "second kgs", "2kin"], 14 | "1 Chronicles": ["1 chronicles", "1 chron", "1 ch", "i ch", "1ch", "1 chr", "i chr", "1chr", "i chron", "1chron", "i chronicles", "1chronicles", "1st chronicles", "first chronicles"], 15 | "2 Chronicles": ["2 chronicles", "2 chron", "2 ch", "ii ch", "2ch", "ii chr", "2chr", "ii chron", "2chron", "ii chronicles", "2chronicles", "2nd chronicles", "second chronicles"], 16 | "Ezra": ["ezra", "ezra", "ezr"], 17 | "Nehemiah": ["nehemiah", "neh", "ne"], 18 | "Esther": ["esther", "esth", "es"], 19 | "Job": ["job", "jb"], 20 | "Psalm": ["psalm", "pslm", "ps", "psalms", "psa", "psm", "pss"], 21 | "Proverbs": ["proverbs", "prov", "pr", "prv"], 22 | "Ecclesiastes": ["ecclesiastes", "eccles", "ec", "ecc", "qoh", "qoheleth"], 23 | "Song of Solomon": ["song of solomon", "song", "so", "canticle of canticles", "canticles", "song of songs", "sos"], 24 | "Isaiah": ["isaiah", "isa", "is"], 25 | "Jeremiah": ["jeremiah", "jer", "je", "jr"], 26 | "Lamentations": ["lamentations", "lam", "la"], 27 | "Ezekiel": ["ezekiel", "ezek", "eze", "ezk"], 28 | "Daniel": ["daniel", "dan", "da", "dn"], 29 | "Hosea": ["hosea", "hos", "ho"], 30 | "Joel": ["joel", "joe", "jl"], 31 | "Amos": ["amos", "am"], 32 | "Obadiah": ["obadiah", "obad", "ob"], 33 | "Jonah": ["jonah", "jnh", "jon"], 34 | "Micah": ["micah", "mic"], 35 | "Nahum": ["nahum", "nah", "na"], 36 | "Habakkuk": ["habakkuk", "hab", "hab"], 37 | "Zephaniah": ["zephaniah", "zeph", "zep", "zp"], 38 | "Haggai": ["haggai", "hag", "hg"], 39 | "Zechariah": ["zechariah", "zech", "zec", "zc"], 40 | "Malachi": ["malachi", "mal", "mal", "ml"], 41 | "Tobit": ["tobit", "tob", "tb"], 42 | "Judith": ["judith", "jdth", "jdt", "jth"], 43 | "Additions to Esther": ["additions to esther", "add esth", "add es", "rest of esther", "the rest of esther", "aes", "addesth"], 44 | "Wisdom of Solomon": ["wisdom of solomon", "wisd of sol", "wis", "ws", "wisdom"], 45 | "Sirach": ["sirach", "sir", "ecclesiasticus", "ecclus"], 46 | "Baruch": ["baruch", "bar"], 47 | "Letter of Jeremiah": ["letter of jeremiah", "let jer", "let jer", "lje", "ltr jer"], 48 | "Song of Three Youths": ["song of three youths", "song of three", "song thr", "the song of three youths", "pr az", "prayer of azariah", "azariah", "the song of the three holy children", "the song of three jews", "song of the three holy children", "song of thr", "song of three children", "song of three jews"], 49 | "Susanna": ["susanna", "sus"], 50 | "Bel and the Dragon": ["bel and the dragon", "bel", "bel"], 51 | "1 Maccabees": ["1 maccabees", "1 macc", "1 mac", "1m", "i ma", "1ma", "i mac", "1mac", "i macc", "1macc", "i maccabees", "1maccabees", "1st maccabees", "first maccabees"], 52 | "2 Maccabees": ["2 maccabees", "2 macc", "2 mac", "2m", "ii ma", "2ma", "ii mac", "2mac", "ii macc", "2macc", "ii maccabees", "2maccabees", "2nd maccabees", "second maccabees"], 53 | "1 Esdras": ["1 esdras", "1 esdr", "1 esd", "i es", "1es", "i esd", "1esd", "i esdr", "1esdr", "i esdras", "1esdras", "1st esdras", "first esdras"], 54 | "Prayer of Manasseh": ["prayer of manasseh", "pr of man", "pr man", "pma", "prayer of manasses"], 55 | "Additional Psalm": ["additional psalm", "add psalm", "add ps"], 56 | "3 Maccabees": ["3 maccabees", "3 macc", "3 mac", "iii ma", "3ma", "iii mac", "3mac", "iii macc", "3macc", "iii maccabees", "3rd maccabees", "third maccabees"], 57 | "2 Esdras": ["2 esdras", "2 esdr", "2 esd", "ii es", "2es", "ii esd", "2esd", "ii esdr", "2esdr", "ii esdras", "2esdras", "2nd esdras", "second esdras"], 58 | "4 Maccabees": ["4 maccabees", "4 macc", "4 mac", "iv ma", "4ma", "iv mac", "4mac", "iv macc", "4macc", "iv maccabees", "iiii maccabees", "4maccabees", "4th maccabees", "fourth maccabees"], 59 | "Ode": ["ode"], 60 | "Psalms of Solomon": ["psalms of solomon", "ps solomon", "ps sol", "psalms solomon", "pssol"], 61 | "Epistle to the Laodiceans": ["epistle to the laodiceans", "laodiceans", "laod", "ep laod", "epist laodiceans", "epistle laodiceans", "epistle to laodiceans"], 62 | "Matthew": ["matthew", "matt", "mt"], 63 | "Mark": ["mark", "mrk", "mk", "mr"], 64 | "Luke": ["luke", "luk", "lk"], 65 | "John": ["john", "jn", "jhn"], 66 | "Acts": ["acts", "ac"], 67 | "Romans": ["romans", "rom", "ro", "rm"], 68 | "1 Corinthians": ["1 corinthians", "1 cor", "1 co", "i co", "1co", "i cor", "1cor", "i corinthians", "1corinthians", "1st corinthians", "first corinthians"], 69 | "2 Corinthians": ["2 corinthians", "2 cor", "2 co", "ii co", "2co", "ii cor", "2cor", "ii corinthians", "2corinthians", "2nd corinthians", "second corinthians"], 70 | "Galatians": ["galatians", "gal", "ga"], 71 | "Ephesians": ["ephesians", "ephes", "eph"], 72 | "Philippians": ["philippians", "phil", "php"], 73 | "Colossians": ["colossians", "col", "col"], 74 | "1 Thessalonians": ["1 thessalonians", "1 thess", "1 th", "i th", "1th", "i thes", "1thes", "i thess", "1thess", "i thessalonians", "1thessalonians", "1st thessalonians", "first thessalonians"], 75 | "2 Thessalonians": ["2 thessalonians", "2 thess", "2 th", "ii th", "2th", "ii thes", "2thes", "ii thess", "2thess", "ii thessalonians", "2thessalonians", "2nd thessalonians", "second thessalonians"], 76 | "1 Timothy": ["1 timothy", "1 tim", "1 ti", "i ti", "1ti", "i tim", "1tim", "i timothy", "1timothy", "1st timothy", "first timothy"], 77 | "2 Timothy": ["2 timothy", "2 tim", "2 ti", "ii ti", "2ti", "ii tim", "2tim", "ii timothy", "2timothy", "2nd timothy", "second timothy"], 78 | "Titus": ["titus", "tit"], 79 | "Philemon": ["philemon", "philem", "phm"], 80 | "Hebrews": ["hebrews", "heb"], 81 | "James": ["james", "jas", "jm"], 82 | "1 Peter": ["1 peter", "1 pet", "1 pe", "i pe", "1pe", "i pet", "1pet", "i pt", "1 pt", "1pt", "i peter", "1peter", "1st peter", "first peter"], 83 | "2 Peter": ["2 peter", "2 pet", "2 pe", "ii pe", "2pe", "ii pet", "2pet", "ii pt", "2 pt", "2pt", "ii peter", "2peter", "2nd peter", "second peter"], 84 | "1 John": ["1 john", "1 jn", "i jn", "1jn", "i jo", "1jo", "i joh", "1joh", "i jhn", "1 jhn", "1jhn", "i john", "1john", "1st john", "first john"], 85 | "2 John": ["2 john", "2 jn", "ii jn", "2jn", "ii jo", "2jo", "ii joh", "2joh", "ii jhn", "2 jhn", "2jhn", "ii john", "2john", "2nd john", "second john"], 86 | "3 John": ["3 john", "3 jn", "iii jn", "3jn", "iii jo", "3jo", "iii joh", "3joh", "iii jhn", "3 jhn", "3jhn", "iii john", "3john", "3rd john", "third john"], 87 | "Jude": ["jude", "jud"], 88 | "Revelation": ["revelation", "rev", "re", "the revelation"] 89 | } 90 | --------------------------------------------------------------------------------