提交 95e05ee6 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

file-box in residence (#1914)

上级 6330f4d6
...@@ -350,12 +350,12 @@ const contact = await bot.Contact.find() ...@@ -350,12 +350,12 @@ const contact = await bot.Contact.find()
await bot.say(contact) await bot.say(contact)
// 3. send Image to bot itself from remote url // 3. send Image to bot itself from remote url
import { FileBox } from 'file-box' import { FileBox } from 'wechaty'
const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png')
await bot.say(fileBox) await bot.say(fileBox)
// 4. send Image to bot itself from local file // 4. send Image to bot itself from local file
import { FileBox } from 'file-box' import { FileBox } from 'wechaty'
const fileBox = FileBox.fromFile('/tmp/text.jpg') const fileBox = FileBox.fromFile('/tmp/text.jpg')
await bot.say(fileBox) await bot.say(fileBox)
...@@ -473,7 +473,7 @@ await room.say('Hello world!') ...@@ -473,7 +473,7 @@ await room.say('Hello world!')
const msg = await room.say('Hello world!') // only supported by puppet-padplus const msg = await room.say('Hello world!') // only supported by puppet-padplus
// 2. Send media file inside Room // 2. Send media file inside Room
import { FileBox } from 'file-box' import { FileBox } from 'wechaty'
const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png')
const fileBox2 = FileBox.fromLocal('/tmp/text.txt') const fileBox2 = FileBox.fromLocal('/tmp/text.txt')
await room.say(fileBox1) await room.say(fileBox1)
...@@ -983,7 +983,7 @@ const msg = await contact.say('welcome to wechaty!') // only supported by puppet ...@@ -983,7 +983,7 @@ const msg = await contact.say('welcome to wechaty!') // only supported by puppet
// 2. send media file to contact // 2. send media file to contact
import { FileBox } from 'file-box' import { FileBox } from 'wechaty'
const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png')
const fileBox2 = FileBox.fromFile('/tmp/text.txt') const fileBox2 = FileBox.fromFile('/tmp/text.txt')
await contact.say(fileBox1) await contact.say(fileBox1)
...@@ -1251,7 +1251,7 @@ bot.on('login', (user: ContactSelf) => { ...@@ -1251,7 +1251,7 @@ bot.on('login', (user: ContactSelf) => {
``` ```
**Example** *(SET the avatar for a bot)* **Example** *(SET the avatar for a bot)*
```js ```js
import { FileBox } from 'file-box' import { FileBox } from 'wechaty'
bot.on('login', (user: ContactSelf) => { bot.on('login', (user: ContactSelf) => {
console.log(`user ${user} login`) console.log(`user ${user} login`)
const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png')
...@@ -1596,7 +1596,7 @@ This function is depending on the Puppet Implementation, see [puppet-compatible- ...@@ -1596,7 +1596,7 @@ This function is depending on the Puppet Implementation, see [puppet-compatible-
**Example** **Example**
```js ```js
import { FileBox } from 'file-box' import { FileBox } from 'wechaty'
const bot = new Wechaty() const bot = new Wechaty()
bot bot
.on('message', async m => { .on('message', async m => {
......
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
*/ */
import { import {
Contact, Contact,
FileBox,
Message, Message,
ScanStatus, ScanStatus,
Wechaty, Wechaty,
} from '../src/' // from 'wechaty' } from '../src/' // from 'wechaty'
import { FileBox } from 'file-box'
import { generate } from 'qrcode-terminal' import { generate } from 'qrcode-terminal'
/** /**
......
...@@ -84,7 +84,6 @@ ...@@ -84,7 +84,6 @@
"cuid": "^2.1.1", "cuid": "^2.1.1",
"hot-import": "^0.2.1", "hot-import": "^0.2.1",
"in-gfw": "^1.2.0", "in-gfw": "^1.2.0",
"memory-card": "^0.6.9",
"npm-programmatic": "0.0.12", "npm-programmatic": "0.0.12",
"open-graph": "^0.2.4", "open-graph": "^0.2.4",
"opencollective": "^1.0.3", "opencollective": "^1.0.3",
...@@ -96,7 +95,7 @@ ...@@ -96,7 +95,7 @@
"read-pkg-up": "^7.0.0", "read-pkg-up": "^7.0.0",
"state-switch": "^0.6.2", "state-switch": "^0.6.2",
"watchdog": "^0.8.1", "watchdog": "^0.8.1",
"wechaty-puppet": "^0.19.14", "wechaty-puppet": "^0.19.17",
"wechaty-puppet-hostie": "^0.3.13", "wechaty-puppet-hostie": "^0.3.13",
"ws": "^7.0.0" "ws": "^7.0.0"
}, },
...@@ -142,7 +141,7 @@ ...@@ -142,7 +141,7 @@
"sloc": "^0.2.0", "sloc": "^0.2.0",
"tstest": "^0.4.1", "tstest": "^0.4.1",
"typedoc": "^0.15.0", "typedoc": "^0.15.0",
"wechaty-puppet-mock": "^0.17.2" "wechaty-puppet-mock": "^0.17.4"
}, },
"files_comment__whitelist_npm_publish": "http://stackoverflow.com/a/8617868/1123955", "files_comment__whitelist_npm_publish": "http://stackoverflow.com/a/8617868/1123955",
"files": [ "files": [
......
...@@ -24,7 +24,11 @@ import Raven from 'raven' ...@@ -24,7 +24,11 @@ import Raven from 'raven'
import readPkgUp from 'read-pkg-up' import readPkgUp from 'read-pkg-up'
import { log } from 'brolog' import { log } from 'brolog'
import { FileBox } from 'file-box'
import {
FileBox,
MemoryCard,
} from 'wechaty-puppet'
import { import {
PuppetModuleName, PuppetModuleName,
...@@ -173,7 +177,10 @@ export function isProduction (): boolean { ...@@ -173,7 +177,10 @@ export function isProduction (): boolean {
export { export {
log, log,
FileBox,
MemoryCard,
Raven, Raven,
VERSION, VERSION,
} }
......
export {
FileBox,
} from 'file-box'
export { export {
ScanStatus, ScanStatus,
UrlLinkPayload, UrlLinkPayload,
FileBox,
MemoryCard,
} from 'wechaty-puppet' } from 'wechaty-puppet'
export { export {
......
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
* *
* @ignore * @ignore
*/ */
import { FileBox } from 'file-box'
import { import {
FileBox,
log, log,
} from '../config' } from '../config'
...@@ -71,7 +70,7 @@ export class ContactSelf extends Contact { ...@@ -71,7 +70,7 @@ export class ContactSelf extends Contact {
* }) * })
* *
* @example <caption>SET the avatar for a bot</caption> * @example <caption>SET the avatar for a bot</caption>
* import { FileBox } from 'file-box' * import { FileBox } from 'wechaty'
* bot.on('login', (user: ContactSelf) => { * bot.on('login', (user: ContactSelf) => {
* console.log(`user ${user} login`) * console.log(`user ${user} login`)
* const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') * const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png')
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* @ignore * @ignore
*/ */
import { instanceToClass } from 'clone-class' import { instanceToClass } from 'clone-class'
import { FileBox } from 'file-box'
import { import {
ContactGender, ContactGender,
...@@ -33,6 +32,8 @@ import { ...@@ -33,6 +32,8 @@ import {
import { import {
log, log,
qrCodeForChatie, qrCodeForChatie,
FileBox,
Raven, Raven,
} from '../config' } from '../config'
import { import {
...@@ -344,7 +345,7 @@ export class Contact extends Accessory implements Sayable { ...@@ -344,7 +345,7 @@ export class Contact extends Accessory implements Sayable {
* *
* // 2. send media file to contact * // 2. send media file to contact
* *
* import { FileBox } from 'file-box' * import { FileBox } from 'wechaty'
* const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') * const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png')
* const fileBox2 = FileBox.fromFile('/tmp/text.txt') * const fileBox2 = FileBox.fromFile('/tmp/text.txt')
* await contact.say(fileBox1) * await contact.say(fileBox1)
......
import { instanceToClass } from 'clone-class' import { instanceToClass } from 'clone-class'
import { FileBox } from 'file-box'
import { ImageType } from 'wechaty-puppet' import { ImageType } from 'wechaty-puppet'
import { Accessory } from '../accessory' import { Accessory } from '../accessory'
import { log } from '../config' import {
FileBox,
log,
} from '../config'
export class Image extends Accessory { export class Image extends Accessory {
......
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
import { import {
instanceToClass, instanceToClass,
} from 'clone-class' } from 'clone-class'
import {
FileBox,
} from 'file-box'
import { import {
MessagePayload, MessagePayload,
...@@ -37,6 +34,8 @@ import { ...@@ -37,6 +34,8 @@ import {
} from '../accessory' } from '../accessory'
import { import {
AT_SEPRATOR_REGEX, AT_SEPRATOR_REGEX,
FileBox,
log, log,
Raven, Raven,
} from '../config' } from '../config'
...@@ -445,7 +444,7 @@ export class Message extends Accessory implements Sayable { ...@@ -445,7 +444,7 @@ export class Message extends Accessory implements Sayable {
* @returns {Promise<void | Message>} * @returns {Promise<void | Message>}
* *
* @example * @example
* import { FileBox } from 'file-box' * import { FileBox } from 'wechaty'
* const bot = new Wechaty() * const bot = new Wechaty()
* bot * bot
* .on('message', async m => { * .on('message', async m => {
......
...@@ -20,16 +20,14 @@ ...@@ -20,16 +20,14 @@
import { import {
instanceToClass, instanceToClass,
} from 'clone-class' } from 'clone-class'
import {
FileBox,
} from 'file-box'
import { import {
Accessory, Accessory,
} from '../accessory' } from '../accessory'
import { import {
// config,
FOUR_PER_EM_SPACE, FOUR_PER_EM_SPACE,
FileBox,
log, log,
Raven, Raven,
} from '../config' } from '../config'
...@@ -410,7 +408,7 @@ export class Room extends Accessory implements Sayable { ...@@ -410,7 +408,7 @@ export class Room extends Accessory implements Sayable {
* const msg = await room.say('Hello world!') // only supported by puppet-padplus * const msg = await room.say('Hello world!') // only supported by puppet-padplus
* *
* // 2. Send media file inside Room * // 2. Send media file inside Room
* import { FileBox } from 'file-box' * import { FileBox } from 'wechaty'
* const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') * const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png')
* const fileBox2 = FileBox.fromLocal('/tmp/text.txt') * const fileBox2 = FileBox.fromLocal('/tmp/text.txt')
* await room.say(fileBox1) * await room.say(fileBox1)
......
...@@ -25,16 +25,10 @@ import { ...@@ -25,16 +25,10 @@ import {
cloneClass, cloneClass,
// instanceToClass, // instanceToClass,
} from 'clone-class' } from 'clone-class'
import {
FileBox,
} from 'file-box'
import { import {
callerResolve, callerResolve,
hotImport, hotImport,
} from 'hot-import' } from 'hot-import'
import {
MemoryCard,
} from 'memory-card'
import { import {
StateSwitch, StateSwitch,
} from 'state-switch' } from 'state-switch'
...@@ -43,6 +37,9 @@ import { ...@@ -43,6 +37,9 @@ import {
CHAT_EVENT_DICT, CHAT_EVENT_DICT,
Puppet, Puppet,
FileBox,
MemoryCard,
PUPPET_EVENT_DICT, PUPPET_EVENT_DICT,
PuppetEventName, PuppetEventName,
PuppetOptions, PuppetOptions,
...@@ -1031,12 +1028,12 @@ export class Wechaty extends Accessory implements Sayable { ...@@ -1031,12 +1028,12 @@ export class Wechaty extends Accessory implements Sayable {
* await bot.say(contact) * await bot.say(contact)
* *
* // 3. send Image to bot itself from remote url * // 3. send Image to bot itself from remote url
* import { FileBox } from 'file-box' * import { FileBox } from 'wechaty'
* const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') * const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png')
* await bot.say(fileBox) * await bot.say(fileBox)
* *
* // 4. send Image to bot itself from local file * // 4. send Image to bot itself from local file
* import { FileBox } from 'file-box' * import { FileBox } from 'wechaty'
* const fileBox = FileBox.fromFile('/tmp/text.jpg') * const fileBox = FileBox.fromFile('/tmp/text.jpg')
* await bot.say(fileBox) * await bot.say(fileBox)
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册