Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "mews", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "trust your output to a mews", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -16,2 +16,3 @@ # mews | ||
[More information about supported services](#available-mews) is available below. | ||
@@ -39,7 +40,7 @@ ## Using mews | ||
// continued from above | ||
mew('%s: Detected %d new cuties!', Date(), cutieData.count, cutieData) | ||
mew('%s: Found %d new cuties!', Date(), count) | ||
``` | ||
## Building mews | ||
### Building mews | ||
@@ -53,3 +54,3 @@ 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. | ||
```js | ||
let mew = mews.telegram(apiToken, chatID, 'A message, nyan~') | ||
let mew = mews.telegram(apiToken, chatID, 'Nyan~') | ||
``` | ||
@@ -59,3 +60,3 @@ | ||
let mew = mews.telegram(apiToken) | ||
mew = mew(chatID, 'A message, nyan~') | ||
mew = mew(chatID, 'Nyan~') | ||
``` | ||
@@ -66,3 +67,3 @@ | ||
mew = mew(chatID) | ||
mew('A message, nyan~') | ||
mew('Nyan~') | ||
``` | ||
@@ -82,9 +83,9 @@ | ||
## Configuring mews | ||
### Configuring mews | ||
If you want to do more complicated things, mews are also configurable. For example, Telegram's api allows you to decide whether or not your message should be parsed as Markdown. The `telegram` mew exposes this choice to you via the `.markdown` simple property: | ||
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: | ||
```js | ||
let mew = mews.telegram(apiToken, chatID) | ||
mew.markdown("[Here's a link, nya~](https://www.npmjs.com/package/mews)") | ||
let mew = mews.log | ||
mew.err("Error error! Time to panic nyow!") | ||
``` | ||
@@ -95,5 +96,5 @@ | ||
```js | ||
let mew = mews.telegram.noNotify | ||
mew = mew.noNotify(apiToken) | ||
mew = mew(chatID).noNotify | ||
let mew = mews.telegram.noNotify // noNotify on | ||
mew = mew.noNotify(apiToken) // noNotify off | ||
mew = mew(chatID).noNotify // noNotify on | ||
mew("Psst! You won't get notified about this message.") | ||
@@ -120,1 +121,48 @@ ``` | ||
If all this configuration stuff is too confusing, don't worry about it! You can use mews without worrying about configuring anything at all. | ||
## 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`. | ||
### 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`. | ||
* `...output` Desired output. | ||
#### log configuration | ||
* `mew.err` *toggle*. Print output to STDERR instead of STDOUT. | ||
* `mew.error` *alias*. `mew.err` | ||
```js | ||
let mew = mews.log | ||
mew('Normal log message') // STDOUT | ||
mew.err('Error message') // STDERR | ||
``` | ||
### 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. | ||
* `botToken` *string*. Your telegram bot's API token. You get this when you create your bot, and can ask BotFather for it again with the `/token` command. | ||
* `chatID` *string*. Your recipient's chat ID, which is usually a positive integer for users, a negative integer for groups, or a name for channels. | ||
* `...output` Desired output. | ||
#### telegram 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_` | ||
* `mew.html` *toggle*. Switch on HTML parsing mode, which supports a subset of tags: `<b> <i> <a href=""> <code> <pre>` | ||
* `mew.noPreview` *toggle*. Disable link previews. | ||
* `mew.noNotify` *toggle*. Disable notifications for message. | ||
* `mew.reply_markup =` *string*. Configure `reply_markup` request variable, typically for controlling how a user would reply to your message. | ||
* `mew.disable_web_page_preview` *alias*. `mew.noPreview` | ||
* `mew.disable_notification` *alias*. `mew.noNotify` | ||
* `mew.parse_mode =` *string*. Actual `parse_mode` variable as sent in request to Telegram. `mew.markdown` and `mew.html` modify this variable for you so you don't have to. | ||
```js | ||
let mew = mews.telegram(botToken, chatID) | ||
let mdn = mew.markdown('[With preview](https://npm.im/nyaa)') // Markdown | ||
mdn.noPreview('[No preview](https://npm.im/mews)') // Markdown & noPreview | ||
let rpy = mdn() // Clone mdn => rpy | ||
rpy.reply_markup = JSON.stringify({force_reply: true}) // Modify rpy | ||
rpy(`_Meow_ you're in reply mode!`) // Markdown & force_reply | ||
``` |
13713
161