Comparing version 1.1.4 to 1.2.0
@@ -20,3 +20,3 @@ const request = require('request') | ||
} | ||
}) | ||
}, () => {}) | ||
} | ||
@@ -23,0 +23,0 @@ |
@@ -22,3 +22,3 @@ const request = require('request') | ||
oauth, form | ||
}) | ||
}, () => {}) | ||
} else { | ||
@@ -28,3 +28,3 @@ request.post('https://api.twitter.com/1.1/statuses/update.json', { | ||
form: {status, possibly_sensitive, in_reply_to_status_id} | ||
}) | ||
}, () => {}) | ||
} | ||
@@ -31,0 +31,0 @@ } |
{ | ||
"name": "mews", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"description": "trust your output to a mews", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "npm link tape && tape test/*.js" | ||
"test": "npm link tape && tape test/*.js", | ||
"node": "node -i -e \"const $ = require('.')\"" | ||
}, | ||
@@ -9,0 +10,0 @@ "repository": { |
@@ -7,3 +7,3 @@ # mews | ||
mews are intended to make sending messages on Telegram and Twitter as easy as using `console.log`. | ||
mews are intended to make sending messages on [Slack](#slack), [Telegram](#telegram), and [Twitter](#twitter) as easy as using `console.log`. | ||
@@ -17,6 +17,5 @@ ```js | ||
[More information about supported services](#available-mews) is available below. | ||
[More information about supported services](#log) is available below. | ||
## Using mews | ||
This package is a collection of mews (though I've actually only written two so far). You start by plucking the mew that you want to use off of the mews module: | ||
@@ -46,3 +45,2 @@ | ||
### Building mews | ||
Each mew is actually a curried function. Officially, [curried functions](https://en.wikipedia.org/wiki/Currying) are weird monstrosities made of lots of little functions, but as far as we're concerned, they're just really lenient functions that are okay with not getting enough arguments. Where most functions will kick and scream at you, these just give you new functions that remember the arguments you've already provided. | ||
@@ -82,3 +80,2 @@ | ||
### Configuring mews | ||
If you want to do more complicated things, mews are also configurable. For example, the `log` mew usually outputs messages to STDOUT, but you can use the `.err` simple property to switch over to STDERR: | ||
@@ -117,14 +114,15 @@ | ||
If all this configuration stuff is too confusing, don't worry about it! You can use mews without worrying about configuring anything at all. | ||
If all this configuration stuff is too confusing, don't worry about it! You can use mews without worrying about configuring anything at all. Most of the time they're just there for completeness. | ||
## Available mews | ||
As stated above, all mews are curried, so function calls always return a partially applied mew remembering provided arguments other than the ones in `...output`. | ||
## Log | ||
Please note that this and all other mews are curried functions, as stated above. Calls always return a partially applied mew remembering provided arguments other than the ones in `...output`. | ||
### mew = mews.log(...output) | ||
Proof of concept mew that just calls `console.log`. May be worth noting that this function is four characters shorter than `console.log`. | ||
```js | ||
mew = mews.log(...output) | ||
``` | ||
Proof of concept mew that just calls `console.log`. | ||
* `...output` Desired output. | ||
#### log configuration | ||
### Configuration | ||
* `mew.err` *toggle*. Print output to STDERR instead of STDOUT. | ||
@@ -139,3 +137,30 @@ * `mew.error` *alias*. `mew.err` | ||
### mew = mews.telegram(botToken, chatID, ...output) | ||
## Slack | ||
```js | ||
mew = mews.slack(apiToken, details, ...output) | ||
``` | ||
Sends a message over Slack. The simplest way to use this is simply providing a channel name as `details`. | ||
* `apiToken` *string*. A Slack API token. Only tested with the ones provided by [Slack Bots](https://my.slack.com/apps/A0F7YS25R-bots), but any other Slack API Token will probably work too. | ||
* `details` This can be an object or string. | ||
- *string*. A shortcut for setting the `channel` property below. | ||
- *object*. The only required property is `channel`. See below for interactions between properties. | ||
- `channel` *string*. The channel you would like to send your message to. Include a `@` before usernames to send a DM. You may optionally include a `#` before channel names. This is required. | ||
- `name` *string*. A sender name for your message. | ||
- `icon` *string*. A url to an image file to be used as your message's icon. | ||
- `emoji` *string*. A Slack emoji to be used as your message's icon. Colons are required. | ||
* `...output` Desired output. | ||
Providing a string as `details` is equivalent to providing an object with only a `channel` property. If you do this, your bot (or whatever entity your API token corresponds to) must be in the channel specified. If you specify any of the other properties, this is *not* required. | ||
### Configuration | ||
* `mew.noParse` *toggle*. *Disables* the `full` parse mode. This allows you to use [Slack's formatting spec](https://api.slack.com/docs/message-formatting). | ||
* `mew.link_names` *toggle*. Enables channel and username auto-linking. This is only useful when used with `noParse`, because the `full` parse mode does this by default. | ||
* `mew.attachments = ''` *string*. A json string following [Slack's attachment spec](https://api.slack.com/docs/message-attachments). | ||
* `mew.noPreview` *toggle*. Disables all link previews. | ||
## Telegram | ||
```js | ||
mew = mews.telegram(botToken, chatID, ...output) | ||
``` | ||
Send a message to the account with `chatID` from the bot with given `botToken`. Requires the recipient to have messaged the bot at least once. | ||
@@ -147,4 +172,3 @@ | ||
#### telegram configuration | ||
### Configuration | ||
* `mew.markdown` *toggle*. Switch on markdown parsing mode. Please note that the "markdown" supported by this mode is simplified from normal markdown: `*bold* _italic_` | ||
@@ -169,3 +193,6 @@ * `mew.html` *toggle*. Switch on HTML parsing mode, which supports a subset of tags: `<b> <i> <a href=""> <code> <pre>` | ||
### mew = mews.twitter(consumer\_key, consumer\_secret, token, token_secret, ...output) | ||
```js | ||
mew = mews.twitter(consumer_key, consumer_secret, token, token_secret, ...output) | ||
``` | ||
Send a tweet on twitter with the provided app and account details. You can grab some from Twitter's [Application Management site](https://apps.twitter.com). | ||
@@ -179,4 +206,3 @@ | ||
#### twitter configuration | ||
### Configuration | ||
* `mew.sensitive` *toggle*. Flags your tweet as potentially containing sensitive content. | ||
@@ -183,0 +209,0 @@ * `mew.replyTo = ''` *string*. The ID of a tweet you would like to reply to. This doesn't do anything unless your tweet text contains `@username`, where `username` is the username of the account that tweeted the tweet. |
19306
8
217
211