Skip to content

Commit

Permalink
Merge pull request #275 from SockDrawer/integration
Browse files Browse the repository at this point in the history
Feature extended help
  • Loading branch information
AccaliaDeElementia committed Jan 26, 2016
2 parents 44ad8bd + 4bcb4fa commit 50e670a
Show file tree
Hide file tree
Showing 25 changed files with 613 additions and 80 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ node_js:
- iojs
- '0.11'
- '0.12'
- '4.0'
- '4.1'
- '4.2'
- '5.3'
before_script:
- rm -rf ./coverage
- git config credential.helper "store --file=.git/credentials"
Expand Down
15 changes: 14 additions & 1 deletion docs/api/external/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ for details.
* [~onNotification(type, handler)](#module_SockEvents..onNotification) ⇒ <code>SockEvents</code>
* [~removeNotification(type, handler)](#module_SockEvents..removeNotification) ⇒ <code>SockEvents</code>
* [~onCommand(type, helpstring, handler)](#module_SockEvents..onCommand) ⇒ <code>SockEvents</code>
* [~registerHelp(command, helptext)](#module_SockEvents..registerHelp) ⇒ <code>SockEvents</code>
* [~removeCommand(command, handler)](#module_SockEvents..removeCommand) ⇒ <code>SockEvents</code>
* [~command](#module_SockEvents..command) : <code>object</code>
* [~messageHandler](#module_SockEvents..messageHandler)
Expand Down Expand Up @@ -85,7 +86,7 @@ Remove a notification listener

<a name="module_SockEvents..onCommand"></a>
### SockEvents~onCommand(type, helpstring, handler) ⇒ <code>SockEvents</code>
Add a notification listener
Add a command listener

**Kind**: inner method of <code>[SockEvents](#module_SockEvents)</code>
**Returns**: <code>SockEvents</code> - SockEvents for chaining calls
Expand All @@ -96,6 +97,18 @@ Add a notification listener
| helpstring | <code>string</code> | Short help text for command |
| handler | <code>commandHandler</code> | Command handler |

<a name="module_SockEvents..registerHelp"></a>
### SockEvents~registerHelp(command, helptext) ⇒ <code>SockEvents</code>
Add Extended help for a command or topic

**Kind**: inner method of <code>[SockEvents](#module_SockEvents)</code>
**Returns**: <code>SockEvents</code> - SockEvents for chaining calls

| Param | Type | Description |
| --- | --- | --- |
| command | <code>string</code> | Command or topic to register help for |
| helptext | <code>string</code> | Extended help text |

<a name="module_SockEvents..removeCommand"></a>
### SockEvents~removeCommand(command, handler) ⇒ <code>SockEvents</code>
Remove a command listener
Expand Down
13 changes: 13 additions & 0 deletions docs/api/lib/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Webbrowser abstraction for communicating with discourse
* [~login(callback)](#module_browser..login)
* [~messageBus(channels, clientId, callback)](#module_browser..messageBus)
* [~getNotifications(callback)](#module_browser..getNotifications)
* [~setNotificationLevel(topicId, level, callback)](#module_browser..setNotificationLevel)
* [~setPostUrl(post)](#module_browser..setPostUrl) ⇒ <code>external.module_posts.CleanedPost</code>
* [~setTrustLevel(post)](#module_browser..setTrustLevel) ⇒ <code>external.module_posts.CleanedPost</code>
* [~cleanPostRaw(post)](#module_browser..cleanPostRaw) ⇒ <code>external.module_posts.CleanedPost</code>
Expand Down Expand Up @@ -381,6 +382,18 @@ Poll for notifications
| --- | --- | --- |
| callback | <code>notificationsCallback</code> | Completion callback |

<a name="module_browser..setNotificationLevel"></a>
### browser~setNotificationLevel(topicId, level, callback)
Set Notification level

**Kind**: inner method of <code>[browser](#module_browser)</code>

| Param | Type | Description |
| --- | --- | --- |
| topicId | <code>number</code> | Topic to alter notification level |
| level | <code>number</code> | Notification level to set (0=muted, 3=watching) |
| callback | <code>function</code> | Completion callback |

<a name="module_browser..setPostUrl"></a>
### browser~setPostUrl(post) ⇒ <code>external.module_posts.CleanedPost</code>
construct direct post link and direct in reply to link
Expand Down
18 changes: 17 additions & 1 deletion docs/api/lib/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Command Parser for SockBot2.0
* [~cmdShutUp(command)](#module_commands..cmdShutUp)
* [~cmdHelp(command)](#module_commands..cmdHelp)
* [~registerCommand(command, helpstring, handler, callback)](#module_commands..registerCommand) ⇒ <code>undefined</code>
* [~registerHelp(command, helptext, callback)](#module_commands..registerHelp) ⇒ <code>undefined</code>
* [~commandProtect(event, handler)](#module_commands..commandProtect) ⇒ <code>boolean</code>
* [~command](#module_commands..command) : <code>object</code>
* [~completedCallback](#module_commands..completedCallback)
Expand Down Expand Up @@ -110,7 +111,7 @@ Shut the bot up until manually restarted

<a name="module_commands..cmdHelp"></a>
### commands~cmdHelp(command)
Reply with help test top the command !help
Reply with help to the command !help

**Kind**: inner method of <code>[commands](#module_commands)</code>

Expand All @@ -134,6 +135,21 @@ will be added to core EventEmitter as .onCommand()
| handler | <code>commandHandler</code> | Function to handle the command |
| callback | <code>completedCallback</code> | Completion callback |

<a name="module_commands..registerHelp"></a>
### commands~registerHelp(command, helptext, callback) ⇒ <code>undefined</code>
Register extended help

will be added to core EventEmitter as .registerHelp()

**Kind**: inner method of <code>[commands](#module_commands)</code>
**Returns**: <code>undefined</code> - No return value

| Param | Type | Description |
| --- | --- | --- |
| command | <code>string</code> | Command or topic to register help for |
| helptext | <code>string</code> | Extended help text |
| callback | <code>completedCallback</code> | Completion callback |

<a name="module_commands..commandProtect"></a>
### commands~commandProtect(event, handler) ⇒ <code>boolean</code>
Watch for unauthorized commands and reject them
Expand Down
56 changes: 56 additions & 0 deletions docs/api/lib/commands/notifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<a name="module_status"></a>
## status
Notification level commands

**Author:** AccaliaDeElementia
**License**: MIT

* [status](#module_status)
* [.unmute](#module_status.unmute)
* [.prepare(events, callback)](#module_status.prepare)
* [.mute(command)](#module_status.mute)
* [.watch(command)](#module_status.watch)

<a name="module_status.unmute"></a>
### status.unmute
Unwatch the current thread

**Kind**: static property of <code>[status](#module_status)</code>

| Param | Type | Description |
| --- | --- | --- |
| command | <code>command</code> | the unwatch command |

<a name="module_status.prepare"></a>
### status.prepare(events, callback)
Prepare the command parser

Needs to be called to set the internals of the parser after reading config file.

**Kind**: static method of <code>[status](#module_status)</code>

| Param | Type | Description |
| --- | --- | --- |
| events | <code>EventEmitter</code> | EventEmitter that will be core comms for SockBot |
| callback | <code>completedCallback</code> | Completion callback |

<a name="module_status.mute"></a>
### status.mute(command)
Mute the current Thread

**Kind**: static method of <code>[status](#module_status)</code>

| Param | Type | Description |
| --- | --- | --- |
| command | <code>command</code> | the mute command |

<a name="module_status.watch"></a>
### status.watch(command)
Watch the current thread

**Kind**: static method of <code>[status](#module_status)</code>

| Param | Type | Description |
| --- | --- | --- |
| command | <code>command</code> | the watch command |

7 changes: 7 additions & 0 deletions docs/api/plugins/autoreader.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Automatically read posts older than the configured interval.
* [.config](#module_autoreader..internals.config) : <code>object</code>
* [.timer](#module_autoreader..internals.timer) : <code>object</code>
* [.events](#module_autoreader..internals.events) : <code>externals.events.SockEvents</code>
* [.extendedHelp](#module_autoreader..internals.extendedHelp)

<a name="module_autoreader.prepare"></a>
### autoreader.prepare(plugConfig, config, events, browser)
Expand Down Expand Up @@ -98,6 +99,7 @@ Internal status store
* [.config](#module_autoreader..internals.config) : <code>object</code>
* [.timer](#module_autoreader..internals.timer) : <code>object</code>
* [.events](#module_autoreader..internals.events) : <code>externals.events.SockEvents</code>
* [.extendedHelp](#module_autoreader..internals.extendedHelp)

<a name="module_autoreader..internals.browser"></a>
#### internals.browser : <code>Browser</code>
Expand All @@ -119,3 +121,8 @@ Used to stop the autoreading when the plugin is stopped
EventEmitter used for internal communication

**Kind**: static property of <code>[internals](#module_autoreader..internals)</code>
<a name="module_autoreader..internals.extendedHelp"></a>
#### internals.extendedHelp
Extended help message

**Kind**: static property of <code>[internals](#module_autoreader..internals)</code>
6 changes: 6 additions & 0 deletions docs/api/plugins/echo.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ Example plugin, echos your words back at you.
**License**: MIT

* [echo](#module_echo)
* [.extendedHelp](#module_echo.extendedHelp)
* [.prepare(plugConfig, config, events, browser)](#module_echo.prepare)
* [.start()](#module_echo.start)
* [.stop()](#module_echo.stop)
* [.handler(notification, topic, post)](#module_echo.handler)

<a name="module_echo.extendedHelp"></a>
### echo.extendedHelp
Extended help message

**Kind**: static property of <code>[echo](#module_echo)</code>
<a name="module_echo.prepare"></a>
### echo.prepare(plugConfig, config, events, browser)
Prepare Plugin prior to login
Expand Down
7 changes: 7 additions & 0 deletions docs/api/plugins/likes.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Watches threads for new posts and likes them, includes "binge" functionality to
* [.bingeInterval](#module_likes..internals.bingeInterval) : <code>\*</code>
* [.likeCount](#module_likes..internals.likeCount) : <code>number</code>
* [.events](#module_likes..internals.events) : <code>externals.events.SockEvents</code>
* [.extendedHelp](#module_likes..internals.extendedHelp)
* [~completionCallback](#module_likes..completionCallback)

<a name="module_likes.prepare"></a>
Expand Down Expand Up @@ -165,6 +166,7 @@ Internal status store
* [.bingeInterval](#module_likes..internals.bingeInterval) : <code>\*</code>
* [.likeCount](#module_likes..internals.likeCount) : <code>number</code>
* [.events](#module_likes..internals.events) : <code>externals.events.SockEvents</code>
* [.extendedHelp](#module_likes..internals.extendedHelp)

<a name="module_likes..internals.browser"></a>
#### internals.browser : <code>Browser</code>
Expand All @@ -190,6 +192,11 @@ Count of likes handed out during latest binge
#### internals.events : <code>externals.events.SockEvents</code>
EventEmitter used for internal communication

**Kind**: static property of <code>[internals](#module_likes..internals)</code>
<a name="module_likes..internals.extendedHelp"></a>
#### internals.extendedHelp
Extended help message

**Kind**: static property of <code>[internals](#module_likes..internals)</code>
<a name="module_likes..completionCallback"></a>
### likes~completionCallback
Expand Down
7 changes: 7 additions & 0 deletions docs/api/plugins/summoner.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Watches for @mentions and replies with a canned response
* [.defaultConfig](#module_summoner.defaultConfig)
* [.cooldown](#module_summoner.defaultConfig.cooldown) : <code>Number</code>
* [.messages](#module_summoner.defaultConfig.messages) : <code>Array.&lt;string&gt;</code>
* [.extendedHelp](#module_summoner.defaultConfig.extendedHelp)
* [.mentionHandler(_, topic, post)](#module_summoner.mentionHandler)
* [.prepare(plugConfig, config, events, browser)](#module_summoner.prepare)
* [.start()](#module_summoner.start)
Expand All @@ -25,6 +26,7 @@ Default plugin configuration
* [.defaultConfig](#module_summoner.defaultConfig)
* [.cooldown](#module_summoner.defaultConfig.cooldown) : <code>Number</code>
* [.messages](#module_summoner.defaultConfig.messages) : <code>Array.&lt;string&gt;</code>
* [.extendedHelp](#module_summoner.defaultConfig.extendedHelp)

<a name="module_summoner.defaultConfig.cooldown"></a>
#### defaultConfig.cooldown : <code>Number</code>
Expand All @@ -37,6 +39,11 @@ Messages to select reply from.

**Kind**: static property of <code>[defaultConfig](#module_summoner.defaultConfig)</code>
**Default**: <code>[&quot;@%username% has summoned me, and so I appear.&quot;,&quot;Yes master %name%, I shall appear as summoned.&quot;,&quot;Yes mistress %name%, I shall appear as summoned.&quot;]</code>
<a name="module_summoner.defaultConfig.extendedHelp"></a>
#### defaultConfig.extendedHelp
Extended help message

**Kind**: static property of <code>[defaultConfig](#module_summoner.defaultConfig)</code>
<a name="module_summoner.mentionHandler"></a>
### summoner.mentionHandler(_, topic, post)
Respond to @mentions
Expand Down
12 changes: 11 additions & 1 deletion external/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
*/

/**
* Add a notification listener
* Add a command listener
*
* @function
* @name onCommand
Expand All @@ -131,6 +131,16 @@
* @returns {SockEvents} SockEvents for chaining calls
*/

/**
* Add Extended help for a command or topic
*
* @function
* @name registerHelp
* @param {string} command Command or topic to register help for
* @param {string} helptext Extended help text
* @returns {SockEvents} SockEvents for chaining calls
*/

/**
* Remove a command listener
*
Expand Down
2 changes: 0 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const gulp = require('gulp'),
gulpJsdoc2md = require('gulp-jsdoc-to-markdown'),
rename = require('gulp-rename'),
istanbul = require('gulp-istanbul'),
istanbulHarmony = require('istanbul-harmony'),
mocha = require('gulp-mocha'),
eslint = require('gulp-eslint'),
git = require('gulp-git');
Expand Down Expand Up @@ -152,7 +151,6 @@ gulp.task('test', ['lintCore', 'lintTests'], (done) => {
gulp.src(sockFiles)
// Instrument code files with istanbulHarmony
.pipe(istanbul({
instrumenter: istanbulHarmony.Instrumenter,
includeUntested: true
}))
// hook require function for complete code coverage
Expand Down
Loading

0 comments on commit 50e670a

Please sign in to comment.