# mirai-twitter-bot

> Mirai Twitter Bot

Latest version **0.3.3** (published 2020-09-04) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install mirai-twitter-bot
pnpm add mirai-twitter-bot
yarn add mirai-twitter-bot
bun add mirai-twitter-bot
```

Provides the command `mirai-twitter-bot`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2020-09-04 |
| First published | 2020-07-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 136.7 KB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 9 |
| Author | CL-Jeremy |
| Maintainers | cl_jeremy |
| Keywords | qq, qqbot, mirai, twitter |

## Links

- npm: https://www.npmjs.com/package/mirai-twitter-bot
- Repository: https://github.com/CL-Jeremy/mirai-twitter-bot
- Issues: https://github.com/CL-Jeremy/mirai-twitter-bot/issues
- npm.io page: https://npm.io/package/mirai-twitter-bot

## Dependencies (13)

- [sha1](https://npm.io/package/sha1.md) ^1.1.1
- [temp](https://npm.io/package/temp.md) ^0.9.1
- [pngjs](https://npm.io/package/pngjs.md) ^5.0.0
- [sharp](https://npm.io/package/sharp.md) ^0.25.4
- [log4js](https://npm.io/package/log4js.md) ^6.3.0
- [twitter](https://npm.io/package/twitter.md) ^1.7.1
- [mirai-ts](https://npm.io/package/mirai-ts.md) ^0.4.6
- [puppeteer](https://npm.io/package/puppeteer.md) ^2.1.0
- [typescript](https://npm.io/package/typescript.md) ^3.9.7
- [html-entities](https://npm.io/package/html-entities.md) ^1.3.1
- [read-all-stream](https://npm.io/package/read-all-stream.md) ^3.1.0
- [callable-instance](https://npm.io/package/callable-instance.md) ^2.0.0
- [command-line-usage](https://npm.io/package/command-line-usage.md) ^5.0.5

## Recent versions

- 0.3.3 (latest) — 2020-09-04
- 0.3.2 — 2020-09-04
- 0.3.1 — 2020-08-31
- 0.3.0 — 2020-08-22
- 0.2.9 — 2020-08-20
- 0.2.8 — 2020-08-20
- 0.2.7 — 2020-08-19
- 0.2.6 — 2020-08-05
- 0.2.5 — 2020-08-05
- 0.2.0 — 2020-07-28
- 0.1.3 — 2020-07-26
- 0.1.2 — 2020-07-25
- 0.1.0 — 2020-07-25

## README

# Mirai Twitter Bot

修改自：[rikakomoe/cqhttp-twitter-bot](https://github.com/rikakomoe/cqhttp-twitter-bot)

使用 API：[YunYouJun/mirai-ts](https://github.com/YunYouJun/mirai-ts)

## 主要区别

- 去除了 Redis
- 支持通过列表 ID 订阅列表，和网页端体验一致
- 处理订阅链接时大小写不敏感，新订阅链接时先检查是否存在
- 支持直接查看指定的推文链接，或（在没有其他用户订阅该用户时）从最新推文回溯到该条推文，由新到旧显示
- 图片使用 [sharp](https://github.com/lovell/sharp) 压缩为 JPEG
- 视频使用 [gifski](https://github.com/ImageOptim/gifski) 压缩为 GIF（请务必下载并放到 `PATH` 下，推荐[这里](https://github.com/CL-Jeremy/gifski/releases/tag/1.0.1-unofficial)的最新修改版，注意从包管理器安装依赖）
- 机器人的 QQ 号码必须手动填写
- Puppeteer 不再自动启动，请手动开启并监听本地 9222 端口（这种方式可以使用 Chrome 或是远程 WebSocket 代理服务器）

## 配置

它会从命令传入的 JSON 配置文件里读取配置，配置说明如下

| 配置项 | 说明 | 默认 |
| --- | --- | --- |
| mirai_access_token | Mirai HTTP API authKey（需与插件一致，插件若未<br />配置本项会在 console 显示生成值，请将其填入） | （必填） |
| mirai_http_host | Mirai HTTP API 插件服务端地址 | 127.0.0.1 |
| mirai_http_port | Mirai HTTP API 插件服务端口 | 8080 |
| mirai_bot_qq | Mirai HTTP API 登录的目标机器人 QQ 号 | 10000（示例值，必填） |
| twitter_consumer_key | Twitter App consumer_key | （必填） |
| twitter_consumer_secret |  Twitter App consumer_secret | （必填） |
| twitter_access_token_key | Twitter App access_token_key | （必填） |
| twitter_access_token_secret | Twitter App access_token_secret | （必填） |
| mode | 工作模式，0 为图文模式，1 为纯文本模式，2 为文<br />本附图模式 | 0 |
| resume_on_start | 是否在启动时从退出时的进度继续（拉取本应用非活<br />动时期错过的推文） | false |
| work_interval | 对单个订阅两次拉取更新的最少间隔时间（秒） | 60 |
| webshot_delay | 抓取网页截图时等待网页加载的延迟时长（毫秒） | 10000 |
| lockfile | 本地保存订阅信息以便下次启动时恢复 | subscriber.lock |
| loglevel | 日志调试等级 | info |

示例文件在 [`config.example.json`](./config.example.json)

## Bug

- 好友消息的图片有可能会失效或直接无法接收（后者会被转换为 `[失败的图片：<地址>]` 格式，然后整条消息会以纯文本模式重发）
- 视频为实验性功能，可能会有各种问题，比如超过大小后会被服务器二压，暂时请酌情自行处理

## Todo

- 重新实现基于 hash 的文件缓存和转推媒体去重
- 添加选项对时间线进行过滤

---
_Source: https://npm.io/package/mirai-twitter-bot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
