Repository: Yoctol/bottender
Pull request #551 (2019-11-30 16:44:12)

chore: put channel stuff into separate folder
In this PR, I created following folders and put related files into them:

- messenger
- line
- slack
- telegram
- viber

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

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

```diff
@@           Coverage Diff           @@
##           master     #551   +/-   ##
=======================================
  Coverage   82.01%   82.01%           
=======================================
  Files          97       97           
  Lines        3954     3954           
  Branches      949      958    +9     
=======================================
  Hits         3243     3243           
+ Misses        677      673    -4     
- Partials       34       38    +4
```


| [Impacted Files](https://codecov.io/gh/Yoctol/bottender/pull/551?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [packages/bottender/src/messenger/MessengerEvent.ts](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9tZXNzZW5nZXIvTWVzc2VuZ2VyRXZlbnQudHM=) | `98.34% <ø> (ø)` | |
| [packages/bottender/src/slack/SlackEvent.ts](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9zbGFjay9TbGFja0V2ZW50LnRz) | `97.36% <ø> (ø)` | |
| [packages/bottender/src/line/LineEvent.ts](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9saW5lL0xpbmVFdmVudC50cw==) | `100% <ø> (ø)` | |
| [packages/bottender/src/viber/ViberEvent.ts](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy92aWJlci9WaWJlckV2ZW50LnRz) | `100% <ø> (ø)` | |
| [packages/bottender/src/console/ConsoleEvent.ts](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9jb25zb2xlL0NvbnNvbGVFdmVudC50cw==) | `100% <ø> (ø)` | |
| [packages/bottender/src/telegram/TelegramEvent.ts](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy90ZWxlZ3JhbS9UZWxlZ3JhbUV2ZW50LnRz) | `100% <ø> (ø)` | |
| [packages/bottender/src/types.ts](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy90eXBlcy50cw==) | `100% <ø> (ø)` | :arrow_up: |
| [packages/bottender/src/line/LineBot.ts](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9saW5lL0xpbmVCb3QudHM=) | `100% <100%> (ø)` | |
| [packages/bottender/src/line/LineConnector.ts](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9saW5lL0xpbmVDb25uZWN0b3IudHM=) | `92.63% <100%> (ø)` | |
| [...ages/bottender/src/messenger/MessengerConnector.ts](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9tZXNzZW5nZXIvTWVzc2VuZ2VyQ29ubmVjdG9yLnRz) | `92.62% <100%> (ø)` | |
| ... and [19 more](https://codecov.io/gh/Yoctol/bottender/pull/551/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Yoctol/bottender/pull/551?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/551?src=pr&el=footer). Last update [6fa9c80...e5c194f](https://codecov.io/gh/Yoctol/bottender/pull/551?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/packages/bottender/src/browser.ts b/packages/bottender/src/browser.ts
index 32f5c9c3..ce94db4c 100644
--- a/packages/bottender/src/browser.ts
+++ b/packages/bottender/src/browser.ts
@@ -1,9 +1,11 @@
+/* Core */
+export { default as Bot } from './bot/Bot';
+export { default as Context } from './context/Context';
+
+/* Action */
 export { default as chain } from './chain';
 export { default as withProps } from './withProps';
 
-/* Bot */
-export { default as Bot } from './bot/Bot';
-
 /* Cache */
 export { default as MemoryCacheStore } from './cache/MemoryCacheStore';
 
@@ -15,8 +17,5 @@ export { default as MemorySessionStore } from './session/MemorySessionStore';
  * Private Exports (unstable)
  */
 
-/* Context */
-export { default as Context } from './context/Context';
-
 /* Plugins */
 export { default as withTyping } from './plugins/withTyping';
diff --git a/packages/bottender/src/bot/ConsoleBot.ts b/packages/bottender/src/console/ConsoleBot.ts
similarity index 93%
rename from packages/bottender/src/bot/ConsoleBot.ts
rename to packages/bottender/src/console/ConsoleBot.ts
index 84ee1e24..8a921bd1 100644
--- a/packages/bottender/src/bot/ConsoleBot.ts
+++ b/packages/bottender/src/console/ConsoleBot.ts
@@ -1,12 +1,12 @@
 import readline from 'readline';
 
-import ConsoleEvent, { ConsoleRawEvent } from '../context/ConsoleEvent';
+import Bot from '../bot/Bot';
 import Session from '../session/Session';
 import SessionStore from '../session/SessionStore';
-import { ConsoleClient } from '../context/ConsoleClient';
 
-import Bot from './Bot';
 import ConsoleConnector from './ConsoleConnector';
+import ConsoleEvent, { ConsoleRawEvent } from './ConsoleEvent';
+import { ConsoleClient } from './ConsoleClient';
 
 export default class ConsoleBot extends Bot<
   ConsoleRawEvent,
diff --git a/packages/bottender/src/context/ConsoleClient.ts b/packages/bottender/src/console/ConsoleClient.ts
similarity index 100%
rename from packages/bottender/src/context/ConsoleClient.ts
rename to packages/bottender/src/console/ConsoleClient.ts
diff --git a/packages/bottender/src/bot/ConsoleConnector.ts b/packages/bottender/src/console/ConsoleConnector.ts
similarity index 89%
rename from packages/bottender/src/bot/ConsoleConnector.ts
rename to packages/bottender/src/console/ConsoleConnector.ts
index 487b6fd2..292678fb 100644
--- a/packages/bottender/src/bot/ConsoleConnector.ts
+++ b/packages/bottender/src/console/ConsoleConnector.ts
@@ -1,12 +1,12 @@
 import EventEmitter from 'events';
 
-import ConsoleContext from '../context/ConsoleContext';
-import ConsoleEvent, { ConsoleRawEvent } from '../context/ConsoleEvent';
 import Session from '../session/Session';
-import { ConsoleClient } from '../context/ConsoleClient';
+import { Connector } from '../bot/Connector';
 import { RequestContext } from '../types';
 
-import { Connector } from './Connector';
+import ConsoleContext from './ConsoleContext';
+import ConsoleEvent, { ConsoleRawEvent } from './ConsoleEvent';
+import { ConsoleClient } from './ConsoleClient';
 
 type ConsoleRequestBody = ConsoleRawEvent;
 
diff --git a/packages/bottender/src/context/ConsoleContext.ts b/packages/bottender/src/console/ConsoleContext.ts
similarity index 95%
rename from packages/bottender/src/context/ConsoleContext.ts
rename to packages/bottender/src/console/ConsoleContext.ts
index 444c8a1f..68d97b35 100644
--- a/packages/bottender/src/context/ConsoleContext.ts
+++ b/packages/bottender/src/console/ConsoleContext.ts
@@ -2,13 +2,13 @@ import EventEmitter from 'events';
 
 import sleep from 'delay';
 
+import Context from '../context/Context';
 import Session from '../session/Session';
+import { PlatformContext } from '../context/PlatformContext';
 import { RequestContext } from '../types';
 
 import ConsoleEvent from './ConsoleEvent';
-import Context from './Context';
 import { ConsoleClient } from './ConsoleClient';
-import { PlatformContext } from './PlatformContext';
 
 type Options = {
   client: ConsoleClient;
diff --git a/packages/bottender/src/context/ConsoleEvent.ts b/packages/bottender/src/console/ConsoleEvent.ts
similarity index 97%
rename from packages/bottender/src/context/ConsoleEvent.ts
rename to packages/bottender/src/console/ConsoleEvent.ts
index 6b13d9c5..a850076a 100644
--- a/packages/bottender/src/context/ConsoleEvent.ts
+++ b/packages/bottender/src/console/ConsoleEvent.ts
@@ -1,4 +1,4 @@
-import { Event } from './Event';
+import { Event } from '../context/Event';
 
 type Message = {
   text: string;
diff --git a/packages/bottender/src/index.ts b/packages/bottender/src/index.ts
index 88d3b151..e7859b52 100644
--- a/packages/bottender/src/index.ts
+++ b/packages/bottender/src/index.ts
@@ -1,25 +1,13 @@
 export { createServer } from '@bottender/express';
 
+/* Core */
+export { default as Bot } from './bot/Bot';
+export { default as Context } from './context/Context';
+
+/* Action */
 export { default as chain } from './chain';
 export { default as withProps } from './withProps';
 
-/* Bot */
-export { default as Bot } from './bot/Bot';
-export { default as ConsoleBot } from './bot/ConsoleBot';
-export { default as MessengerBot } from './bot/MessengerBot';
-export { default as LineBot } from './bot/LineBot';
-export { default as SlackBot } from './bot/SlackBot';
-export { default as TelegramBot } from './bot/TelegramBot';
-export { default as ViberBot } from './bot/ViberBot';
-
-/* Connector */
-export { default as ConsoleConnector } from './bot/ConsoleConnector';
-export { default as MessengerConnector } from './bot/MessengerConnector';
-export { default as LineConnector } from './bot/LineConnector';
-export { default as SlackConnector } from './bot/SlackConnector';
-export { default as TelegramConnector } from './bot/TelegramConnector';
-export { default as ViberConnector } from './bot/ViberConnector';
-
 /* Cache */
 export { default as MemoryCacheStore } from './cache/MemoryCacheStore';
 export { default as RedisCacheStore } from './cache/RedisCacheStore';
@@ -31,6 +19,42 @@ export { default as RedisSessionStore } from './session/RedisSessionStore';
 export { default as FileSessionStore } from './session/FileSessionStore';
 export { default as MongoSessionStore } from './session/MongoSessionStore';
 
+/* Console */
+export { default as ConsoleBot } from './console/ConsoleBot';
+export { default as ConsoleConnector } from './console/ConsoleConnector';
+export { default as ConsoleContext } from './console/ConsoleContext';
+export { default as ConsoleEvent } from './console/ConsoleEvent';
+
+/* Messenger */
+export { default as MessengerBot } from './messenger/MessengerBot';
+export { default as MessengerConnector } from './messenger/MessengerConnector';
+export { default as MessengerContext } from './messenger/MessengerContext';
+export { default as MessengerEvent } from './messenger/MessengerEvent';
+
+/* LINE */
+export { default as LineBot } from './line/LineBot';
+export { default as LineConnector } from './line/LineConnector';
+export { default as LineContext } from './line/LineContext';
+export { default as LineEvent } from './line/LineEvent';
+
+/* Slack */
+export { default as SlackBot } from './slack/SlackBot';
+export { default as SlackConnector } from './slack/SlackConnector';
+export { default as SlackContext } from './slack/SlackContext';
+export { default as SlackEvent } from './slack/SlackEvent';
+
+/* Telegram */
+export { default as TelegramBot } from './telegram/TelegramBot';
+export { default as TelegramConnector } from './telegram/TelegramConnector';
+export { default as TelegramContext } from './telegram/TelegramContext';
+export { default as TelegramEvent } from './telegram/TelegramEvent';
+
+/* Viber */
+export { default as ViberBot } from './viber/ViberBot';
+export { default as ViberConnector } from './viber/ViberConnector';
+export { default as ViberContext } from './viber/ViberContext';
+export { default as ViberEvent } from './viber/ViberEvent';
+
 /**
  * Private Exports (unstable)
  */
@@ -38,21 +62,4 @@ export { default as MongoSessionStore } from './session/MongoSessionStore';
 /* Plugins */
 export { default as withTyping } from './plugins/withTyping';
 
-/* Context */
-export { default as Context } from './context/Context';
-export { default as ConsoleContext } from './context/ConsoleContext';
-export { default as MessengerContext } from './context/MessengerContext';
-export { default as LineContext } from './context/LineContext';
-export { default as SlackContext } from './context/SlackContext';
-export { default as TelegramContext } from './context/TelegramContext';
-export { default as ViberContext } from './context/ViberContext';
-
-/* Event */
-export { default as ConsoleEvent } from './context/ConsoleEvent';
-export { default as MessengerEvent } from './context/MessengerEvent';
-export { default as LineEvent } from './context/LineEvent';
-export { default as SlackEvent } from './context/SlackEvent';
-export { default as TelegramEvent } from './context/TelegramEvent';
-export { default as ViberEvent } from './context/ViberEvent';
-
 export { default as initializeServer } from './initializeServer';
diff --git a/packages/bottender/src/initializeServer.ts b/packages/bottender/src/initializeServer.ts
index 690f4a2e..234464df 100644
--- a/packages/bottender/src/initializeServer.ts
+++ b/packages/bottender/src/initializeServer.ts
@@ -5,11 +5,11 @@ import merge from 'lodash/merge';
 import { createServer, registerRoutes } from '@bottender/express';
 
 import Bot from './bot/Bot';
-import LineBot from './bot/LineBot';
-import MessengerBot from './bot/MessengerBot';
-import SlackBot from './bot/SlackBot';
-import TelegramBot from './bot/TelegramBot';
-import ViberBot from './bot/ViberBot';
+import LineBot from './line/LineBot';
+import MessengerBot from './messenger/MessengerBot';
+import SlackBot from './slack/SlackBot';
+import TelegramBot from './telegram/TelegramBot';
+import ViberBot from './viber/ViberBot';
 import getBottenderConfig from './shared/getBottenderConfig';
 import { Action, BottenderConfig, Channel, Plugin } from './types';
 
@@ -87,7 +87,7 @@ function initializeServer({
   }
 
   if (isConsole) {
-    const ConsoleBot = require('./bot/ConsoleBot').default;
+    const ConsoleBot = require('./console/ConsoleBot').default;
 
     const bot = new ConsoleBot({
       fallbackMethods: true,
diff --git a/packages/bottender/src/bot/LineBot.ts b/packages/bottender/src/line/LineBot.ts
similarity index 93%
rename from packages/bottender/src/bot/LineBot.ts
rename to packages/bottender/src/line/LineBot.ts
index d8f12d0f..59a18bf4 100644
--- a/packages/bottender/src/bot/LineBot.ts
+++ b/packages/bottender/src/line/LineBot.ts
@@ -1,11 +1,10 @@
 import { LineClient } from 'messaging-api-line';
 
+import Bot from '../bot/Bot';
 import SessionStore from '../session/SessionStore';
 
-import Bot from './Bot';
 import LineConnector, { LineRequestBody } from './LineConnector';
-
-import { LineEvent } from '..';
+import LineEvent from './LineEvent';
 
 export default class LineBot extends Bot<
   LineRequestBody,
diff --git a/packages/bottender/src/bot/LineConnector.ts b/packages/bottender/src/line/LineConnector.ts
similarity index 98%
rename from packages/bottender/src/bot/LineConnector.ts
rename to packages/bottender/src/line/LineConnector.ts
index ae6a1849..25506a1f 100644
--- a/packages/bottender/src/bot/LineConnector.ts
+++ b/packages/bottender/src/line/LineConnector.ts
@@ -4,12 +4,12 @@ import crypto from 'crypto';
 import warning from 'warning';
 import { LineClient } from 'messaging-api-line';
 
-import LineContext from '../context/LineContext';
-import LineEvent, { LineRawEvent } from '../context/LineEvent';
 import Session from '../session/Session';
+import { Connector } from '../bot/Connector';
 import { RequestContext } from '../types';
 
-import { Connector } from './Connector';
+import LineContext from './LineContext';
+import LineEvent, { LineRawEvent } from './LineEvent';
 
 export type LineRequestBody = {
   destination: string;
diff --git a/packages/bottender/src/context/LineContext.ts b/packages/bottender/src/line/LineContext.ts
similarity index 99%
rename from packages/bottender/src/context/LineContext.ts
rename to packages/bottender/src/line/LineContext.ts
index 4f694e4f..6a4128e5 100644
--- a/packages/bottender/src/context/LineContext.ts
+++ b/packages/bottender/src/line/LineContext.ts
@@ -6,12 +6,12 @@ import sleep from 'delay';
 import warning from 'warning';
 import { Line, LineClient, LineTypes } from 'messaging-api-line';
 
+import Context from '../context/Context';
 import Session from '../session/Session';
+import { PlatformContext } from '../context/PlatformContext';
 import { RequestContext } from '../types';
 
-import Context from './Context';
 import LineEvent from './LineEvent';
-import { PlatformContext } from './PlatformContext';
 
 type Options = {
   client: LineClient;
diff --git a/packages/bottender/src/context/LineEvent.ts b/packages/bottender/src/line/LineEvent.ts
similarity index 99%
rename from packages/bottender/src/context/LineEvent.ts
rename to packages/bottender/src/line/LineEvent.ts
index 45fd9997..6ce0d731 100644
--- a/packages/bottender/src/context/LineEvent.ts
+++ b/packages/bottender/src/line/LineEvent.ts
@@ -1,4 +1,4 @@
-import { Event } from './Event';
+import { Event } from '../context/Event';
 
 type UserSource = {
   type: 'user';
diff --git a/packages/bottender/src/context/__tests__/LineContext.spec.ts b/packages/bottender/src/line/__tests__/LineContext.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/LineContext.spec.ts
rename to packages/bottender/src/line/__tests__/LineContext.spec.ts
diff --git a/packages/bottender/src/context/__tests__/LineEvent.spec.ts b/packages/bottender/src/line/__tests__/LineEvent.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/LineEvent.spec.ts
rename to packages/bottender/src/line/__tests__/LineEvent.spec.ts
diff --git a/packages/bottender/src/bot/MessengerBot.ts b/packages/bottender/src/messenger/MessengerBot.ts
similarity index 93%
rename from packages/bottender/src/bot/MessengerBot.ts
rename to packages/bottender/src/messenger/MessengerBot.ts
index b96ed557..e495ecd7 100644
--- a/packages/bottender/src/bot/MessengerBot.ts
+++ b/packages/bottender/src/messenger/MessengerBot.ts
@@ -1,11 +1,10 @@
 import { MessengerClient } from 'messaging-api-messenger';
 
+import Bot from '../bot/Bot';
 import SessionStore from '../session/SessionStore';
 
-import Bot from './Bot';
 import MessengerConnector, { MessengerRequestBody } from './MessengerConnector';
-
-import { MessengerEvent } from '..';
+import MessengerEvent from './MessengerEvent';
 
 export default class MessengerBot extends Bot<
   MessengerRequestBody,
diff --git a/packages/bottender/src/bot/MessengerConnector.ts b/packages/bottender/src/messenger/MessengerConnector.ts
similarity index 98%
rename from packages/bottender/src/bot/MessengerConnector.ts
rename to packages/bottender/src/messenger/MessengerConnector.ts
index f84319a7..fcddbe4b 100644
--- a/packages/bottender/src/bot/MessengerConnector.ts
+++ b/packages/bottender/src/messenger/MessengerConnector.ts
@@ -9,7 +9,11 @@ import warning from 'warning';
 import { MessengerBatchQueue } from 'messenger-batch';
 import { MessengerClient } from 'messaging-api-messenger';
 
-import MessengerContext from '../context/MessengerContext';
+import Session from '../session/Session';
+import { Connector } from '../bot/Connector';
+import { RequestContext } from '../types';
+
+import MessengerContext from './MessengerContext';
 import MessengerEvent, {
   AppRoles,
   Message,
@@ -20,11 +24,7 @@ import MessengerEvent, {
   Recipient,
   Sender,
   TakeThreadControl,
-} from '../context/MessengerEvent';
-import Session from '../session/Session';
-import { RequestContext } from '../types';
-
-import { Connector } from './Connector';
+} from './MessengerEvent';
 
 type Entry = {
   [key in 'messaging' | 'standby' | 'changes']: {
diff --git a/packages/bottender/src/context/MessengerContext.ts b/packages/bottender/src/messenger/MessengerContext.ts
similarity index 99%
rename from packages/bottender/src/context/MessengerContext.ts
rename to packages/bottender/src/messenger/MessengerContext.ts
index 1a84b57e..15788369 100644
--- a/packages/bottender/src/context/MessengerContext.ts
+++ b/packages/bottender/src/messenger/MessengerContext.ts
@@ -5,12 +5,12 @@ import sleep from 'delay';
 import warning from 'warning';
 import { MessengerBatch, MessengerClient } from 'messaging-api-messenger';
 
+import Context from '../context/Context';
 import Session from '../session/Session';
+import { PlatformContext } from '../context/PlatformContext';
 import { RequestContext } from '../types';
 
-import Context from './Context';
 import MessengerEvent from './MessengerEvent';
-import { PlatformContext } from './PlatformContext';
 
 type Options = {
   appId?: string;
diff --git a/packages/bottender/src/context/MessengerEvent.ts b/packages/bottender/src/messenger/MessengerEvent.ts
similarity index 99%
rename from packages/bottender/src/context/MessengerEvent.ts
rename to packages/bottender/src/messenger/MessengerEvent.ts
index ef15e98b..007620c4 100644
--- a/packages/bottender/src/context/MessengerEvent.ts
+++ b/packages/bottender/src/messenger/MessengerEvent.ts
@@ -1,6 +1,6 @@
 import { camelcaseKeysDeep } from 'messaging-api-common';
 
-import { Event } from './Event';
+import { Event } from '../context/Event';
 
 export type Sender = {
   id: string;
diff --git a/packages/bottender/src/context/__tests__/MessengerContext-send.spec.ts b/packages/bottender/src/messenger/__tests__/MessengerContext-send.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/MessengerContext-send.spec.ts
rename to packages/bottender/src/messenger/__tests__/MessengerContext-send.spec.ts
diff --git a/packages/bottender/src/context/__tests__/MessengerContext-sendTemplate.spec.ts b/packages/bottender/src/messenger/__tests__/MessengerContext-sendTemplate.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/MessengerContext-sendTemplate.spec.ts
rename to packages/bottender/src/messenger/__tests__/MessengerContext-sendTemplate.spec.ts
diff --git a/packages/bottender/src/context/__tests__/MessengerContext.spec.ts b/packages/bottender/src/messenger/__tests__/MessengerContext.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/MessengerContext.spec.ts
rename to packages/bottender/src/messenger/__tests__/MessengerContext.spec.ts
diff --git a/packages/bottender/src/context/__tests__/MessengerEvent.spec.ts b/packages/bottender/src/messenger/__tests__/MessengerEvent.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/MessengerEvent.spec.ts
rename to packages/bottender/src/messenger/__tests__/MessengerEvent.spec.ts
diff --git a/packages/bottender/src/bot/SlackBot.ts b/packages/bottender/src/slack/SlackBot.ts
similarity index 93%
rename from packages/bottender/src/bot/SlackBot.ts
rename to packages/bottender/src/slack/SlackBot.ts
index bb0dfcf5..29ba7554 100644
--- a/packages/bottender/src/bot/SlackBot.ts
+++ b/packages/bottender/src/slack/SlackBot.ts
@@ -1,12 +1,11 @@
 import { RTMClient } from '@slack/rtm-api';
 import { SlackOAuthClient } from 'messaging-api-slack';
 
+import Bot from '../bot/Bot';
 import SessionStore from '../session/SessionStore';
 
-import Bot from './Bot';
 import SlackConnector, { SlackRequestBody } from './SlackConnector';
-
-import { SlackEvent } from '..';
+import SlackEvent from './SlackEvent';
 
 export default class SlackBot extends Bot<
   SlackRequestBody,
diff --git a/packages/bottender/src/bot/SlackConnector.ts b/packages/bottender/src/slack/SlackConnector.ts
similarity index 98%
rename from packages/bottender/src/bot/SlackConnector.ts
rename to packages/bottender/src/slack/SlackConnector.ts
index 4b90e7b4..ca6ac5c5 100644
--- a/packages/bottender/src/bot/SlackConnector.ts
+++ b/packages/bottender/src/slack/SlackConnector.ts
@@ -6,17 +6,17 @@ import warning from 'warning';
 import { SlackOAuthClient } from 'messaging-api-slack';
 
 import Session from '../session/Session';
-import SlackContext from '../context/SlackContext';
+import { Connector } from '../bot/Connector';
+import { RequestContext } from '../types';
+
+import SlackContext from './SlackContext';
 import SlackEvent, {
   BlockActionEvent,
   EventAPITypes,
   InteractiveMessageEvent,
   Message,
   SlackRawEvent,
-} from '../context/SlackEvent';
-import { RequestContext } from '../types';
-
-import { Connector } from './Connector';
+} from './SlackEvent';
 
 // FIXME
 export type SlackUser = {
diff --git a/packages/bottender/src/context/SlackContext.ts b/packages/bottender/src/slack/SlackContext.ts
similarity index 96%
rename from packages/bottender/src/context/SlackContext.ts
rename to packages/bottender/src/slack/SlackContext.ts
index 90c90c11..2412ef25 100644
--- a/packages/bottender/src/context/SlackContext.ts
+++ b/packages/bottender/src/slack/SlackContext.ts
@@ -2,9 +2,10 @@ import sleep from 'delay';
 import warning from 'warning';
 import { SlackOAuthClient, SlackTypes } from 'messaging-api-slack';
 
-import Context from './Context';
+import Context from '../context/Context';
+import { PlatformContext } from '../context/PlatformContext';
+
 import SlackEvent from './SlackEvent';
-import { PlatformContext } from './PlatformContext';
 
 export default class SlackContext extends Context<SlackOAuthClient, SlackEvent>
   implements PlatformContext {
diff --git a/packages/bottender/src/context/SlackEvent.ts b/packages/bottender/src/slack/SlackEvent.ts
similarity index 99%
rename from packages/bottender/src/context/SlackEvent.ts
rename to packages/bottender/src/slack/SlackEvent.ts
index c0e15028..afdb3280 100644
--- a/packages/bottender/src/context/SlackEvent.ts
+++ b/packages/bottender/src/slack/SlackEvent.ts
@@ -1,6 +1,6 @@
 import pascalCase from 'pascal-case';
 
-import { Event } from './Event';
+import { Event } from '../context/Event';
 
 export type EventAPITypes =
   | 'message'
diff --git a/packages/bottender/src/context/__tests__/SlackContext.spec.ts b/packages/bottender/src/slack/__tests__/SlackContext.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/SlackContext.spec.ts
rename to packages/bottender/src/slack/__tests__/SlackContext.spec.ts
diff --git a/packages/bottender/src/context/__tests__/SlackEvent.spec.ts b/packages/bottender/src/slack/__tests__/SlackEvent.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/SlackEvent.spec.ts
rename to packages/bottender/src/slack/__tests__/SlackEvent.spec.ts
diff --git a/packages/bottender/src/bot/TelegramBot.ts b/packages/bottender/src/telegram/TelegramBot.ts
similarity index 96%
rename from packages/bottender/src/bot/TelegramBot.ts
rename to packages/bottender/src/telegram/TelegramBot.ts
index 921fb78d..90176b85 100644
--- a/packages/bottender/src/bot/TelegramBot.ts
+++ b/packages/bottender/src/telegram/TelegramBot.ts
@@ -1,11 +1,10 @@
 import { TelegramClient } from 'messaging-api-telegram';
 
+import Bot from '../bot/Bot';
 import SessionStore from '../session/SessionStore';
 
-import Bot from './Bot';
 import TelegramConnector, { TelegramRequestBody } from './TelegramConnector';
-
-import { TelegramEvent } from '..';
+import TelegramEvent from './TelegramEvent';
 
 type PollingOptions = {
   offset?: number;
diff --git a/packages/bottender/src/bot/TelegramConnector.ts b/packages/bottender/src/telegram/TelegramConnector.ts
similarity index 96%
rename from packages/bottender/src/bot/TelegramConnector.ts
rename to packages/bottender/src/telegram/TelegramConnector.ts
index 4fad1202..61e08772 100644
--- a/packages/bottender/src/bot/TelegramConnector.ts
+++ b/packages/bottender/src/telegram/TelegramConnector.ts
@@ -3,11 +3,11 @@ import EventEmitter from 'events';
 import { TelegramClient } from 'messaging-api-telegram';
 
 import Session from '../session/Session';
-import TelegramContext from '../context/TelegramContext';
-import TelegramEvent, { TelegramRawEvent } from '../context/TelegramEvent';
+import { Connector } from '../bot/Connector';
 import { RequestContext } from '../types';
 
-import { Connector } from './Connector';
+import TelegramContext from './TelegramContext';
+import TelegramEvent, { TelegramRawEvent } from './TelegramEvent';
 
 export type TelegramRequestBody = TelegramRawEvent;
 
diff --git a/packages/bottender/src/context/TelegramContext.ts b/packages/bottender/src/telegram/TelegramContext.ts
similarity index 99%
rename from packages/bottender/src/context/TelegramContext.ts
rename to packages/bottender/src/telegram/TelegramContext.ts
index 4b75f54a..99081f8c 100644
--- a/packages/bottender/src/context/TelegramContext.ts
+++ b/packages/bottender/src/telegram/TelegramContext.ts
@@ -2,9 +2,10 @@ import sleep from 'delay';
 import warning from 'warning';
 import { TelegramClient, TelegramTypes as Type } from 'messaging-api-telegram';
 
-import Context from './Context';
+import Context from '../context/Context';
+import { PlatformContext } from '../context/PlatformContext';
+
 import TelegramEvent from './TelegramEvent';
-import { PlatformContext } from './PlatformContext';
 
 class TelegramContext extends Context<TelegramClient, TelegramEvent>
   implements PlatformContext {
diff --git a/packages/bottender/src/context/TelegramEvent.ts b/packages/bottender/src/telegram/TelegramEvent.ts
similarity index 99%
rename from packages/bottender/src/context/TelegramEvent.ts
rename to packages/bottender/src/telegram/TelegramEvent.ts
index 409b26b6..dad0a7b0 100644
--- a/packages/bottender/src/context/TelegramEvent.ts
+++ b/packages/bottender/src/telegram/TelegramEvent.ts
@@ -1,4 +1,4 @@
-import { Event } from './Event';
+import { Event } from '../context/Event';
 
 type TelegramUser = {
   id: number;
diff --git a/packages/bottender/src/context/__tests__/TelegramContext.spec.ts b/packages/bottender/src/telegram/__tests__/TelegramContext.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/TelegramContext.spec.ts
rename to packages/bottender/src/telegram/__tests__/TelegramContext.spec.ts
diff --git a/packages/bottender/src/context/__tests__/TelegramEvent.spec.ts b/packages/bottender/src/telegram/__tests__/TelegramEvent.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/TelegramEvent.spec.ts
rename to packages/bottender/src/telegram/__tests__/TelegramEvent.spec.ts
diff --git a/packages/bottender/src/types.ts b/packages/bottender/src/types.ts
index 62c532b8..2a95bd77 100644
--- a/packages/bottender/src/types.ts
+++ b/packages/bottender/src/types.ts
@@ -4,19 +4,19 @@ import { SlackOAuthClient } from 'messaging-api-slack';
 import { TelegramClient } from 'messaging-api-telegram';
 import { ViberClient } from 'messaging-api-viber';
 
-import ConsoleEvent, { ConsoleRawEvent } from './context/ConsoleEvent';
+import ConsoleEvent, { ConsoleRawEvent } from './console/ConsoleEvent';
 import Context from './context/Context';
-import LineEvent from './context/LineEvent';
-import MessengerEvent from './context/MessengerEvent';
-import SlackEvent from './context/SlackEvent';
-import TelegramEvent from './context/TelegramEvent';
-import ViberEvent from './context/ViberEvent';
-import { ConsoleClient } from './context/ConsoleClient';
-import { LineRequestBody } from './bot/LineConnector';
-import { MessengerRequestBody } from './bot/MessengerConnector';
-import { SlackRequestBody } from './bot/SlackConnector';
-import { TelegramRequestBody } from './bot/TelegramConnector';
-import { ViberRequestBody } from './bot/ViberConnector';
+import LineEvent from './line/LineEvent';
+import MessengerEvent from './messenger/MessengerEvent';
+import SlackEvent from './slack/SlackEvent';
+import TelegramEvent from './telegram/TelegramEvent';
+import ViberEvent from './viber/ViberEvent';
+import { ConsoleClient } from './console/ConsoleClient';
+import { LineRequestBody } from './line/LineConnector';
+import { MessengerRequestBody } from './messenger/MessengerConnector';
+import { SlackRequestBody } from './slack/SlackConnector';
+import { TelegramRequestBody } from './telegram/TelegramConnector';
+import { ViberRequestBody } from './viber/ViberConnector';
 
 export type Client =
   | ConsoleClient
diff --git a/packages/bottender/src/bot/ViberBot.ts b/packages/bottender/src/viber/ViberBot.ts
similarity index 90%
rename from packages/bottender/src/bot/ViberBot.ts
rename to packages/bottender/src/viber/ViberBot.ts
index bd5a6747..ee2c3404 100644
--- a/packages/bottender/src/bot/ViberBot.ts
+++ b/packages/bottender/src/viber/ViberBot.ts
@@ -1,11 +1,10 @@
 import { ViberClient, ViberTypes } from 'messaging-api-viber';
 
+import Bot from '../bot/Bot';
 import SessionStore from '../session/SessionStore';
 
-import Bot from './Bot';
 import ViberConnector, { ViberRequestBody } from './ViberConnector';
-
-import { ViberEvent } from '..';
+import ViberEvent from './ViberEvent';
 
 export default class ViberBot extends Bot<
   ViberRequestBody,
diff --git a/packages/bottender/src/bot/ViberConnector.ts b/packages/bottender/src/viber/ViberConnector.ts
similarity index 96%
rename from packages/bottender/src/bot/ViberConnector.ts
rename to packages/bottender/src/viber/ViberConnector.ts
index 74afa4bc..0f52a046 100644
--- a/packages/bottender/src/bot/ViberConnector.ts
+++ b/packages/bottender/src/viber/ViberConnector.ts
@@ -5,11 +5,11 @@ import { ViberClient, ViberTypes } from 'messaging-api-viber';
 import { addedDiff } from 'deep-object-diff';
 
 import Session from '../session/Session';
-import ViberContext from '../context/ViberContext';
-import ViberEvent, { ViberRawEvent } from '../context/ViberEvent';
+import { Connector } from '../bot/Connector';
 import { RequestContext } from '../types';
 
-import { Connector } from './Connector';
+import ViberContext from './ViberContext';
+import ViberEvent, { ViberRawEvent } from './ViberEvent';
 
 export type ViberRequestBody = ViberRawEvent;
 
diff --git a/packages/bottender/src/context/ViberContext.ts b/packages/bottender/src/viber/ViberContext.ts
similarity index 98%
rename from packages/bottender/src/context/ViberContext.ts
rename to packages/bottender/src/viber/ViberContext.ts
index 0abdd768..1af52b41 100644
--- a/packages/bottender/src/context/ViberContext.ts
+++ b/packages/bottender/src/viber/ViberContext.ts
@@ -2,9 +2,10 @@ import sleep from 'delay';
 import warning from 'warning';
 import { ViberClient, ViberTypes } from 'messaging-api-viber';
 
-import Context from './Context';
+import Context from '../context/Context';
+import { PlatformContext } from '../context/PlatformContext';
+
 import ViberEvent from './ViberEvent';
-import { PlatformContext } from './PlatformContext';
 
 class ViberContext extends Context<ViberClient, ViberEvent>
   implements PlatformContext {
diff --git a/packages/bottender/src/context/ViberEvent.ts b/packages/bottender/src/viber/ViberEvent.ts
similarity index 99%
rename from packages/bottender/src/context/ViberEvent.ts
rename to packages/bottender/src/viber/ViberEvent.ts
index 2038171a..4bf1d966 100644
--- a/packages/bottender/src/context/ViberEvent.ts
+++ b/packages/bottender/src/viber/ViberEvent.ts
@@ -1,4 +1,4 @@
-import { Event } from './Event';
+import { Event } from '../context/Event';
 
 type ViberUser = {
   id: string;


Test patch:
diff --git a/packages/bottender/src/bot/__tests__/ConsoleBot.spec.ts b/packages/bottender/src/console/__tests__/ConsoleBot.spec.ts
similarity index 100%
rename from packages/bottender/src/bot/__tests__/ConsoleBot.spec.ts
rename to packages/bottender/src/console/__tests__/ConsoleBot.spec.ts
diff --git a/packages/bottender/src/bot/__tests__/ConsoleConnector.spec.ts b/packages/bottender/src/console/__tests__/ConsoleConnector.spec.ts
similarity index 95%
rename from packages/bottender/src/bot/__tests__/ConsoleConnector.spec.ts
rename to packages/bottender/src/console/__tests__/ConsoleConnector.spec.ts
index b270b47b..2044b838 100644
--- a/packages/bottender/src/bot/__tests__/ConsoleConnector.spec.ts
+++ b/packages/bottender/src/console/__tests__/ConsoleConnector.spec.ts
@@ -1,6 +1,6 @@
 import ConsoleConnector from '../ConsoleConnector';
-import ConsoleContext from '../../context/ConsoleContext';
-import ConsoleEvent from '../../context/ConsoleEvent';
+import ConsoleContext from '../ConsoleContext';
+import ConsoleEvent from '../ConsoleEvent';
 
 const request = {
   message: {
diff --git a/packages/bottender/src/context/__tests__/ConsoleContext.spec.ts b/packages/bottender/src/console/__tests__/ConsoleContext.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/ConsoleContext.spec.ts
rename to packages/bottender/src/console/__tests__/ConsoleContext.spec.ts
diff --git a/packages/bottender/src/context/__tests__/ConsoleEvent.spec.ts b/packages/bottender/src/console/__tests__/ConsoleEvent.spec.ts
similarity index 100%
rename from packages/bottender/src/context/__tests__/ConsoleEvent.spec.ts
rename to packages/bottender/src/console/__tests__/ConsoleEvent.spec.ts
diff --git a/packages/bottender/src/context/__tests__/Context.spec.ts b/packages/bottender/src/console/__tests__/Context.spec.ts
similarity index 98%
rename from packages/bottender/src/context/__tests__/Context.spec.ts
rename to packages/bottender/src/console/__tests__/Context.spec.ts
index 0b87df0a..04acd0f9 100644
--- a/packages/bottender/src/context/__tests__/Context.spec.ts
+++ b/packages/bottender/src/console/__tests__/Context.spec.ts
@@ -6,7 +6,7 @@ let Context;
 beforeEach(() => {
   /* eslint-disable global-require */
   warning = require('warning');
-  Context = require('../Context').default;
+  Context = require('../../context/Context').default;
   /* eslint-enable global-require */
 });
 
diff --git a/packages/bottender/src/bot/__tests__/LineBot.spec.ts b/packages/bottender/src/line/__tests__/LineBot.spec.ts
similarity index 100%
rename from packages/bottender/src/bot/__tests__/LineBot.spec.ts
rename to packages/bottender/src/line/__tests__/LineBot.spec.ts
diff --git a/packages/bottender/src/bot/__tests__/LineConnector.spec.ts b/packages/bottender/src/line/__tests__/LineConnector.spec.ts
similarity index 99%
rename from packages/bottender/src/bot/__tests__/LineConnector.spec.ts
rename to packages/bottender/src/line/__tests__/LineConnector.spec.ts
index e1459e72..a4ebb3cf 100644
--- a/packages/bottender/src/bot/__tests__/LineConnector.spec.ts
+++ b/packages/bottender/src/line/__tests__/LineConnector.spec.ts
@@ -2,8 +2,8 @@ import warning from 'warning';
 import { LineClient } from 'messaging-api-line';
 
 import LineConnector from '../LineConnector';
-import LineContext from '../../context/LineContext';
-import LineEvent from '../../context/LineEvent';
+import LineContext from '../LineContext';
+import LineEvent from '../LineEvent';
 
 jest.mock('messaging-api-line');
 jest.mock('warning');
diff --git a/packages/bottender/src/bot/__tests__/MessengerBot.spec.ts b/packages/bottender/src/messenger/__tests__/MessengerBot.spec.ts
similarity index 100%
rename from packages/bottender/src/bot/__tests__/MessengerBot.spec.ts
rename to packages/bottender/src/messenger/__tests__/MessengerBot.spec.ts
diff --git a/packages/bottender/src/bot/__tests__/MessengerConnector.spec.ts b/packages/bottender/src/messenger/__tests__/MessengerConnector.spec.ts
similarity index 99%
rename from packages/bottender/src/bot/__tests__/MessengerConnector.spec.ts
rename to packages/bottender/src/messenger/__tests__/MessengerConnector.spec.ts
index 77aba36c..b2b446da 100644
--- a/packages/bottender/src/bot/__tests__/MessengerConnector.spec.ts
+++ b/packages/bottender/src/messenger/__tests__/MessengerConnector.spec.ts
@@ -2,8 +2,8 @@ import warning from 'warning';
 import { MessengerClient } from 'messaging-api-messenger';
 
 import MessengerConnector from '../MessengerConnector';
-import MessengerContext from '../../context/MessengerContext';
-import MessengerEvent from '../../context/MessengerEvent';
+import MessengerContext from '../MessengerContext';
+import MessengerEvent from '../MessengerEvent';
 
 jest.mock('messaging-api-messenger');
 jest.mock('warning');
diff --git a/packages/bottender/src/bot/__tests__/SlackBot.spec.ts b/packages/bottender/src/slack/__tests__/SlackBot.spec.ts
similarity index 100%
rename from packages/bottender/src/bot/__tests__/SlackBot.spec.ts
rename to packages/bottender/src/slack/__tests__/SlackBot.spec.ts
diff --git a/packages/bottender/src/bot/__tests__/SlackConnector.spec.ts b/packages/bottender/src/slack/__tests__/SlackConnector.spec.ts
similarity index 99%
rename from packages/bottender/src/bot/__tests__/SlackConnector.spec.ts
rename to packages/bottender/src/slack/__tests__/SlackConnector.spec.ts
index 6cde01d7..19647578 100644
--- a/packages/bottender/src/bot/__tests__/SlackConnector.spec.ts
+++ b/packages/bottender/src/slack/__tests__/SlackConnector.spec.ts
@@ -1,8 +1,8 @@
 import { SlackOAuthClient } from 'messaging-api-slack';
 
 import SlackConnector from '../SlackConnector';
-import SlackContext from '../../context/SlackContext';
-import SlackEvent from '../../context/SlackEvent';
+import SlackContext from '../SlackContext';
+import SlackEvent from '../SlackEvent';
 
 jest.mock('messaging-api-slack');
 jest.mock('warning');
diff --git a/packages/bottender/src/bot/__tests__/TelegramBot.spec.ts b/packages/bottender/src/telegram/__tests__/TelegramBot.spec.ts
similarity index 100%
rename from packages/bottender/src/bot/__tests__/TelegramBot.spec.ts
rename to packages/bottender/src/telegram/__tests__/TelegramBot.spec.ts
diff --git a/packages/bottender/src/bot/__tests__/TelegramConnector.spec.ts b/packages/bottender/src/telegram/__tests__/TelegramConnector.spec.ts
similarity index 99%
rename from packages/bottender/src/bot/__tests__/TelegramConnector.spec.ts
rename to packages/bottender/src/telegram/__tests__/TelegramConnector.spec.ts
index 1f82001e..cc080936 100644
--- a/packages/bottender/src/bot/__tests__/TelegramConnector.spec.ts
+++ b/packages/bottender/src/telegram/__tests__/TelegramConnector.spec.ts
@@ -1,8 +1,8 @@
 import { TelegramClient } from 'messaging-api-telegram';
 
 import TelegramConnector from '../TelegramConnector';
-import TelegramContext from '../../context/TelegramContext';
-import TelegramEvent from '../../context/TelegramEvent';
+import TelegramContext from '../TelegramContext';
+import TelegramEvent from '../TelegramEvent';
 
 jest.mock('messaging-api-telegram');
 
diff --git a/packages/bottender/src/bot/__tests__/ViberBot.spec.ts b/packages/bottender/src/viber/__tests__/ViberBot.spec.ts
similarity index 100%
rename from packages/bottender/src/bot/__tests__/ViberBot.spec.ts
rename to packages/bottender/src/viber/__tests__/ViberBot.spec.ts
diff --git a/packages/bottender/src/bot/__tests__/ViberConnector.spec.ts b/packages/bottender/src/viber/__tests__/ViberConnector.spec.ts
similarity index 99%
rename from packages/bottender/src/bot/__tests__/ViberConnector.spec.ts
rename to packages/bottender/src/viber/__tests__/ViberConnector.spec.ts
index b11d5d97..ca0a276b 100644
--- a/packages/bottender/src/bot/__tests__/ViberConnector.spec.ts
+++ b/packages/bottender/src/viber/__tests__/ViberConnector.spec.ts
@@ -1,8 +1,8 @@
 import { ViberClient } from 'messaging-api-viber';
 
 import ViberConnector from '../ViberConnector';
-import ViberContext from '../../context/ViberContext';
-import ViberEvent from '../../context/ViberEvent';
+import ViberContext from '../ViberContext';
+import ViberEvent from '../ViberEvent';
 
 jest.unmock('messaging-api-viber');