Repository: Yoctol/bottender
Pull request #573 (2019-12-10 04:05:13)

chore: copy readme to subpackage for npm
To avoid "Unable to find a readme for bottender@1.0.0" on npm

https://www.npmjs.com/package/bottender

codecov-io: # [Codecov](https://codecov.io/gh/Yoctol/bottender/pull/573?src=pr&el=h1) Report
> Merging [#573](https://codecov.io/gh/Yoctol/bottender/pull/573?src=pr&el=desc) into [master](https://codecov.io/gh/Yoctol/bottender/commit/487133c03b81c2562d0e6e03e7890be07ad87285?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/Yoctol/bottender/pull/573/graphs/tree.svg?width=650&token=JX3EGtxYH3&height=150&src=pr)](https://codecov.io/gh/Yoctol/bottender/pull/573?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #573   +/-   ##
=======================================
  Coverage   79.89%   79.89%           
=======================================
  Files          89       89           
  Lines        3965     3965           
  Branches      952      963   +11     
=======================================
  Hits         3168     3168           
+ Misses        762      758    -4     
- Partials       35       39    +4
```


| [Impacted Files](https://codecov.io/gh/Yoctol/bottender/pull/573?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [packages/create-bottender-app/src/shared/log.ts](https://codecov.io/gh/Yoctol/bottender/pull/573/diff?src=pr&el=tree#diff-cGFja2FnZXMvY3JlYXRlLWJvdHRlbmRlci1hcHAvc3JjL3NoYXJlZC9sb2cudHM=) | `0% <0%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Yoctol/bottender/pull/573?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Yoctol/bottender/pull/573?src=pr&el=footer). Last update [487133c...3c2b0f1](https://codecov.io/gh/Yoctol/bottender/pull/573?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/package.json b/package.json
index 589fc302..5acb66b3 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,8 @@
     "test": "yarn compile && yarn lint && yarn testonly",
     "testonly": "jest --detectOpenHandles",
     "testonly:cov": "jest --coverage --runInBand --detectOpenHandles",
-    "testonly:watch": "jest --watch"
+    "testonly:watch": "jest --watch",
+    "version": "cp README.md packages/bottender"
   },
   "devDependencies": {
     "@types/body-parser": "^1.17.1",
diff --git a/packages/bottender/README.md b/packages/bottender/README.md
new file mode 100644
index 00000000..4065c738
--- /dev/null
+++ b/packages/bottender/README.md
@@ -0,0 +1,138 @@
+# Bottender
+
+[![npm](https://img.shields.io/npm/v/bottender.svg)](https://www.npmjs.com/package/bottender)
+[![CircleCI](https://circleci.com/gh/Yoctol/bottender.svg?style=shield)](https://circleci.com/gh/Yoctol/bottender)
+[![coverage](https://codecov.io/gh/Yoctol/bottender/branch/master/graph/badge.svg)](https://codecov.io/gh/Yoctol/bottender)
+[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
+[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Yoctol/bottender#contributing)
+[![join chat](https://img.shields.io/badge/discord-join%20chat-green.svg)](https://discord.gg/apNsWBz)
+[![Follow @bottenderjs](https://img.shields.io/twitter/follow/bottenderjs.svg?label=Follow%20@bottenderjs)](https://twitter.com/intent/follow?screen_name=bottenderjs)
+
+![](https://user-images.githubusercontent.com/3382565/68366395-3080d000-016e-11ea-8bad-d9c52a215376.png)
+
+> The readme below is the documentation for the v1 (stable) version of Bottender. To view the documentation for the old Bottender version visit https://bottender.js.org/docs/0.15.17/getting-started
+
+- **Declarative** - Bottender takes care of the complexity of conversational UIs for you. Design actions for each event and state in your application, and Bottender will run accordingly. his approach makes your code more predictable and easier to debug.
+
+- **Native User Experience** - Bottender lets you create apps on every channel and never compromise on your users’ experience. You can apply progressive enhancement or graceful degradation strategy on your building blocks.
+
+- **Easy Setup** - With Bottender, you only need a few configurations to make your bot work with channels, automatic server listening, webhook setup, signature verification and so much more.
+
+- **Ready for Production** - There are thousands of bots powered by Bottender. It has been optimized for real world use cases, automatic batching request and dozens of other compelling features.
+
+Bottender is built on top of
+[Messaging APIs](https://github.com/Yoctol/messaging-apis).
+
+## Installation
+
+You can create a new Bottender app using the cli tools:
+
+```sh
+npx create-bottender-app my-app
+```
+
+Installation may fail on Windows during compilation of the native dependencies with `node-gyp`. To solve this problem, you can install [`windows-build-tools`](https://github.com/felixrieseberg/windows-build-tools#readme) or check [`node-gyp` documentation](https://github.com/nodejs/node-gyp#on-windows).
+
+## Documentation
+
+You can find the Bottender documentation [on the website](https://bottender.js.org?new).
+
+Check out the [Getting Started](https://bottender.js.org/docs/getting-started?new) page for a quick overview.
+
+## Community
+
+[![join chat](https://img.shields.io/badge/discord-join%20chat-green.svg)](https://discord.gg/unmFzmR)
+
+You can discuss anything about Bottender or chatbot development in our [Discord](https://discordapp.com/) Server. [Join now!](https://discord.gg/unmFzmR)
+
+## Examples
+
+We have a bunch of examples in the
+[examples](https://github.com/Yoctol/bottender/tree/master/examples) folder.
+Here is the first one to get you started:
+
+```js
+// index.js
+module.export = async function App(context) {
+  await context.sendText('Hello World');
+};
+```
+
+```sh
+npx bottender start --console
+```
+
+This will create and run a bot which always reply "Hello World" in the console.
+
+## Notable Features
+
+### Messenger
+
+- Messenger Profile Sync
+- Attachment Upload
+- Handover Protocol
+- Targeting Broadcast Messages
+- Built-in NLP
+- Multiple Pages
+
+### LINE
+
+- Reply, Push, Multicast
+- Imagemap
+- Rich Menu
+- Room, Group Chat
+- Beacon
+
+### Slack
+
+- Channel Chat
+- Interactive Message
+
+### Telegram
+
+- Webhook, Long Polling
+- Update, Delete Messages
+- Keyboard
+- Group Chat
+- Inline Query
+- Message Live Location
+- Payment
+
+### Viber
+
+- Subscribed, Unsubscribed Event
+- Delivered, Seen Event
+
+## Ecosystem
+
+- [bottender-compose](https://github.com/Yoctol/bottender-compose) - An utility library for Bottender and higher-order handlers.
+
+## Contributing
+
+Pull Requests and issue reports are welcome. You can follow steps below to
+submit your pull requests:
+
+Fork, then clone the repo:
+
+```sh
+git clone git@github.com:your-username/bottender.git
+```
+
+Install the dependencies:
+
+```sh
+cd bottender
+yarn
+```
+
+Make sure the tests pass (including eslint, flow checks and jest tests):
+
+```sh
+yarn test
+```
+
+Make your changes and tests, and make sure the tests pass.
+
+## License
+
+MIT © [Yoctol](https://github.com/Yoctol/bottender)
diff --git a/packages/bottender/src/telegram/TelegramContext.ts b/packages/bottender/src/telegram/TelegramContext.ts
index 2dcb7c77..5138d080 100644
--- a/packages/bottender/src/telegram/TelegramContext.ts
+++ b/packages/bottender/src/telegram/TelegramContext.ts
@@ -353,6 +353,38 @@ class TelegramContext extends Context<TelegramClient, TelegramEvent>
     });
   }
 
+  async editMessageMedia(
+    messageId: number,
+    media: Type.InputMedia,
+    options?: Type.EditMessageMediaOption
+  ): Promise<Type.Message | boolean | null> {
+    if (!this._session) {
+      warning(
+        false,
+        'editMessageMedia: should not be called in context without session'
+      );
+      return null;
+    }
+
+    this._isHandled = true;
+
+    const chatId = this._getChatId();
+
+    if (chatId === null) {
+      warning(
+        false,
+        'editMessageMedia: should not be called in context without chatId'
+      );
+      return null;
+    }
+
+    return this._client.editMessageMedia(media, {
+      chatId,
+      messageId,
+      ...options,
+    });
+  }
+
   async editMessageReplyMarkup(
     messageId: number,
     replyMarkup: Type.InlineKeyboardMarkup,
@@ -671,7 +703,7 @@ class TelegramContext extends Context<TelegramClient, TelegramEvent>
     if (!this._session) {
       warning(
         false,
-        'sendVideo: should not be called in context without session'
+        'sendAnimation: should not be called in context without session'
       );
       return null;
     }
@@ -683,7 +715,7 @@ class TelegramContext extends Context<TelegramClient, TelegramEvent>
     if (chatId === null) {
       warning(
         false,
-        'sendVideo: should not be called in context without chatId'
+        'sendAnimation: should not be called in context without chatId'
       );
       return null;
     }
@@ -861,7 +893,7 @@ class TelegramContext extends Context<TelegramClient, TelegramEvent>
     if (!this._session) {
       warning(
         false,
-        'sendContact: should not be called in context without session'
+        'sendPoll: should not be called in context without session'
       );
       return null;
     }
@@ -873,7 +905,7 @@ class TelegramContext extends Context<TelegramClient, TelegramEvent>
     if (chatId === null) {
       warning(
         false,
-        'sendContact: should not be called in context without chatId'
+        'sendPoll: should not be called in context without chatId'
       );
       return null;
     }


Test patch:
diff --git a/packages/bottender/src/telegram/__tests__/TelegramContext.spec.ts b/packages/bottender/src/telegram/__tests__/TelegramContext.spec.ts
index 11143934..bb7f52f7 100644
--- a/packages/bottender/src/telegram/__tests__/TelegramContext.spec.ts
+++ b/packages/bottender/src/telegram/__tests__/TelegramContext.spec.ts
@@ -563,6 +563,28 @@ describe('#editMessageCaption', () => {
   });
 });
 
+describe('#editMessageMedia', () => {
+  it('should to call client.editMessageMedia', async () => {
+    const { context, client } = setup();
+
+    const media = { type: 'photo', media: 'xxx.png' };
+    await context.editMessageMedia(66, media);
+
+    expect(client.editMessageMedia).toBeCalledWith(media, {
+      chatId: 427770117,
+      messageId: 66,
+    });
+  });
+
+  it('should mark context as handled', async () => {
+    const { context } = setup();
+
+    await context.editMessageMedia(66, { type: 'photo', media: 'xxx.png' });
+
+    expect(context.isHandled).toBe(true);
+  });
+});
+
 describe('#editMessageReplyMarkup', () => {
   const markup = {
     keyboard: [[{ text: 'new_button_1' }, { text: 'new_button_2' }]],