Skip to content

Commit

Permalink
Merge branch 'master' into cabal-web
Browse files Browse the repository at this point in the history
  • Loading branch information
cblgh authored Oct 23, 2021
2 parents 78733e1 + 201fee5 commit 704bcce
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 13 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog

## [7.0.0] - 2021-09-26

_The updated version of `cabal-core` indirectly contains major changes to the underlying protocol. See the release of [`cabal-core@14.0.0`](https://github.com/cabal-club/cabal-core/blob/master/CHANGELOG.md#1400---2021-05-18) for more detailed information._

### Changed

- **Breaking:** upgrade `cabal-core` to `14.x` ([#79](https://github.com/cabal-club/cabal-client/issues/79)) (Lars-Magnus Skog)

## [6.3.2] - 2021-05-01

_This is not the first version, but the first version in this changelog to save some time._

[7.0.0]: https://github.com/cabal-club/cabal-client/compare/v6.3.2...v7.0.0

[6.3.2]: https://github.com/cabal-club/cabal-client/releases/tag/v6.3.2
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@

# cabal-client

`cabal-client` is a new type of client library for cabal chat clients.

New chat clients can be implemented using _only_ this library, without having
to mess around with [`cabal-core`](https://github.com/cabal-club/cabal-core/)
anymore.

Some of its features:
* consolidates logic common to all chat clients
* leaving and joining of channels
* virtual messages (such as status messages) and virtual channels (currently only the `!status` channel)
* handling multiple cabal instances
* receiving unread notifications and mentions for channels
* resolving of DNS shortnames (cabal.chat) to cabal keys

- consolidates logic common to all chat clients
- leaving and joining of channels
- virtual messages (such as status messages) and virtual channels (currently only the `!status` channel)
- handling multiple cabal instances
- receiving unread notifications and mentions for channels
- resolving of DNS shortnames (cabal.chat) to cabal keys

For a couple of brief examples, see the [`examples/`](examples/) directory.

## Usage

See [`cabal-cli`](https://github.com/cabal-club/cabal-cli/) for an example client implementation.

[Read the API documentation](./api.md)
Expand Down
6 changes: 6 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ Create a client instance from which to manage multiple
**Params**

- *opts* <code>object</code>
- aliases <code>object</code> - key/value pairs of `alias` -> `command name`
- commands <code>object</code> - key/value pairs of `command name` -> `command object`, which has the following properties:
- call <code>function</code> - command function with the following signature `command.call(cabal, res, arg)`
- help <code>function</code> - return the help string for this command
- category <code>Array.&lt;string&gt;</code> - a list of categories this commands belongs to
- alias <code>Array.&lt;string&gt;</code> - a list of command aliases
- config <code>object</code>
- temp <code>boolean</code> - if `temp` is true no data is persisted to disk.
- *dbdir* <code>string</code> - the directory to store the cabal data
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cabal-client",
"description": "helper module for cabal clients",
"author": "Cabal Club",
"version": "6.3.1",
"version": "7.0.0",
"repository": {
"url": "git://github.com/cabal-club/cabal-client.git"
},
Expand All @@ -18,6 +18,10 @@
"lint": "standard",
"doc": "jsdoc2md --files src/client.js src/cabal-details.js --param-list-format list --separators --partial doc-gen/scope.hbs --helper doc-gen/helpers.js > api.md",
"build": "browserify index.js --standalone CabalClient > bundle.js"
"changelog:patch": "hallmark bump patch -i api.md",
"changelog:minor": "hallmark bump minor -i api.md",
"changelog:major": "hallmark bump major -i api.md",
"markdown:fix": "hallmark --fix README.md CHANGELOG.md"
},
"keywords": [],
"dependencies": {
Expand All @@ -40,6 +44,7 @@
},
"devDependencies": {
"browserify": "^17.0.0",
"hallmark": "^3.1.0",
"jsdoc-to-markdown": "^5.0.2",
"rimraf": "^3.0.2",
"standard": "~12.0.0",
Expand Down
5 changes: 2 additions & 3 deletions src/cabal-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,9 @@ class CabalDetails extends EventEmitter {
const details = this.channels[channel]
if (!details) {
this.channels[channel] = new ChannelDetails(cabal, channel)
// note: only add listener if we don't have a channel registered (=> prevent duplicate listeners)
cabal.messages.events.on(channel, this.messageListener.bind(this))
}
// TODO: only do this for our joined channels, instead of all channels
// Calls fn with every new message that arrives in channel.
cabal.messages.events.on(channel, this.messageListener.bind(this))
this._emitUpdate('new-channel', { channel })
})
}
Expand Down
6 changes: 6 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class Client {
* [`cabal-core`](https://github.com/cabal-club/cabal-core/) instances.
* @constructor
* @param {object} [opts]
* @param {object} opts.aliases key/value pairs of `alias` -> `command name`
* @param {object} opts.commands key/value pairs of `command name` -> `command object`, which has the following properties:
* @param {function} opts.commands[].call command function with the following signature `command.call(cabal, res, arg)`
* @param {function} opts.commands[].help return the help string for this command
* @param {string[]} opts.commands[].category a list of categories this commands belongs to
* @param {string[]} opts.commands[].alias a list of command aliases
* @param {object} opts.config
* @param {boolean} opts.config.temp if `temp` is true no data is persisted to disk.
* @param {string} [opts.config.dbdir] the directory to store the cabal data
Expand Down
5 changes: 3 additions & 2 deletions src/initialization-callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ module.exports.getArchivesCallback = function (err, archivedChannels) {
const details = this.channels[channel]
if (!details) {
this.channels[channel] = new ChannelDetails(cabal, channel)
// listen for updates that happen within the channel
// note: only add listener if we don't have a channel registered (=> prevent duplicate listeners)
cabal.messages.events.on(channel, this.messageListener.bind(this))
}
// mark archived channels as such
if (archivedChannels.indexOf(channel) >= 0) {
this.channels[channel].archive()
}
// listen for updates that happen within the channel
cabal.messages.events.on(channel, this.messageListener.bind(this))

// add all users joined to a channel
cabal.memberships.getUsers(channel, (err, users) => {
Expand Down

0 comments on commit 704bcce

Please sign in to comment.