├── README.md ├── HBot.js └── LICENSE.txt /README.md: -------------------------------------------------------------------------------- 1 | # HBot.js 2 | A Simple and Lightweight Javascript AI Chatter/Helper Bot Library. Documentations at http://www.oyedelehammed.ml/HBot.html 3 | -------------------------------------------------------------------------------- /HBot.js: -------------------------------------------------------------------------------- 1 | /** HBot.js | JavaScript AI Library 2 | * @author Oyedele Hammed Horlah 3 | * @version 1.0 4 | * @since October 12, 2017 5 | * @see http://www.oyedelehammed.ml/HBot.html 6 | */ 7 | 8 | function HBot( db, msg, defaultReply ) { 9 | for ( var key in db ) { 10 | if ( !db.hasOwnProperty( key ) ) continue; 11 | var regex = RegExp( key, 'i' ); 12 | if ( regex.test( msg ) ) { 13 | return db[key]( regex.exec( msg ) ); 14 | } 15 | } 16 | return defaultReply || 'I have no reply for that'; 17 | } -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 - Current 4 | Oyedele Hammed Horlah, http://www.oyedelehammed.ml 5 | 6 | 7 | All rights reserved. 8 | 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining 11 | a copy 12 | 13 | of this software and associated documentation files (the 14 | "Software"), to deal 15 | 16 | in the Software without restriction, including 17 | without limitation the rights to use, copy, modify, merge, publish, 18 | distribute, sublicense, and/or sell 19 | 20 | copies of the Software, and to 21 | permit persons to whom the Software is furnished to do so, subject to 22 | the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be 25 | included in all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 28 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 29 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 30 | NONINFRINGEMENT. 31 | 32 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 33 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 34 | OF CONTRACT, TORT OR 35 | 36 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 37 | WITH THE SOFTWARE OR 38 | THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------