5m5v-bot 中文文档教程
5M5V Bot
从 plorry/VegAssist 中分叉以转推 5 分钟 5 素食主义者寻求支持素食主义者的推文。 https://5minutes5vegans.org
这个机器人在 Twitter 的公共流中跟踪术语“素食主义者”的使用情况——以及它的翻译变体,具体取决于配置——并处理每个项目,在一系列预设短语中寻找精确匹配。 可以为同一应用程序的多个授权帐户设置此机器人,将仅匹配特定过滤器的消息转发给特定帐户。
对所有提供的 API 凭据实施全面验证,以避免潜在的麻烦。
API Credentials
访问 https://developer.twitter.com/apps 以注册您自己的应用程序并获取要使用的凭据。 要在您的应用程序下注册更多用户,请访问 https://5minutes5vegans.org/twitteroauth 以授予权限并获取他们的访问令牌。
Installing
Yarn
- Run
yarn add 5m5v-bot
to install the bot to your project - Copy the
5m5v-config.example.yaml
file innode_modules/5m5v-bot
into your own project under5m5v-config.yaml
and configure the bot - Run
yarn 5m5v-bot
in the directory of your project to run the bot
您可以使用 yarn global add 5m5v-bot
将机器人全局安装到您的系统。 从那时起,您可以从任何文件夹运行 yarn 5m5v-bot
,只要它包含配置文件即可。
Manual
- Clone this repository
- Run
yarn install
in the directory that you cloned this repository into - Copy the
5m5v-config.example.yaml
file to your own5m5v-config.yaml
and configure the bot - Run
node .
in the directory of the repository to run the bot
Configuration
配置从 5m5v-config.yaml
加载在工作目录中,这可能是克隆存储库的目录或安装节点包的项目目录。 配置格式为 YAML,其选项如下所示。
consumer_key
您可以在 Twitter 上的“密钥和令牌”下的应用程序中找到它 -> “消费者 API 密钥”。 它被列为“API 密钥”。
consumer_secret
在前一个密钥下方,列为“API 密钥”。
users
包含要转推的所有用户的列表。 列出的第一个用户将用于收听 Twitter 流。
users.access_token
- Available for your developer account underneath the last two keys under "Access token & access token secret". It's listed as "Access token".
- For other accounts this is the
oauth_token
, obtainable at either https://5minutes5vegans.org/twitteroauth or your own OAuth implementation.
users.access_token_secret
- Available for your developer account underneath the previous key, listed as "Access token secret".
- For other accounts this is the
oauth_token_secret
, obtainable at either https://5minutes5vegans.org/twitteroauth or your own OAuth implementation.
users.filters
该用户将从中转发匹配项的过滤器列表。
exclude
(optional)
关键字列表,如果在推文中找到,将排除该推文被转发。
delaytime
(optional)
找到匹配推文后延迟转推的时间。 默认为两分钟。
Running the tests
只需运行 yarn test
Disabling retweets
出于测试目的,可以使用参数 --dry-run
禁用转推,例如 node 。 --试运行。 在试运行模式下,匹配的推文将记录到控制台但不会转发。
5M5V Bot
Fork from plorry/VegAssist to retweet people looking for support going vegan for 5 Minutes 5 Vegans. https://5minutes5vegans.org
This bot tracks usage of the term "vegan" - and its translated variants depending on the config - on Twitter's public stream, and processes each item, looking for exact matches on an array of preset phrases. This bot can be setup for multiple authorised accounts for the same app, retweeting messages matching only certain filters to only certain accounts.
Implements full verification of all supplied API credentials, to avoid potential headaches.
API Credentials
Visit https://developer.twitter.com/apps to register your own app and obtain the credentials to use. To register more users under your app, visit https://5minutes5vegans.org/twitteroauth to grant permission and obtain their access tokens.
Installing
Yarn
- Run
yarn add 5m5v-bot
to install the bot to your project - Copy the
5m5v-config.example.yaml
file innode_modules/5m5v-bot
into your own project under5m5v-config.yaml
and configure the bot - Run
yarn 5m5v-bot
in the directory of your project to run the bot
You can install the bot globally to your system with yarn global add 5m5v-bot
instead. From then you can run yarn 5m5v-bot
from any folder, as long as it contains a config file.
Manual
- Clone this repository
- Run
yarn install
in the directory that you cloned this repository into - Copy the
5m5v-config.example.yaml
file to your own5m5v-config.yaml
and configure the bot - Run
node .
in the directory of the repository to run the bot
Configuration
The configuration is loaded from 5m5v-config.yaml
in the working directory, which is likely either the directory of your cloned repository or the directory of your project where you installed the node package. The configuration format is YAML, with its options listed below.
consumer_key
You find this in your app on Twitter under "Keys and tokens" -> "Consumer API keys". It's listed as "API key".
consumer_secret
Underneath the previous key, listed as "API secret key".
users
A list containing all users to retweet with. The first user listed will be used to listen to the Twitter stream with.
users.access_token
- Available for your developer account underneath the last two keys under "Access token & access token secret". It's listed as "Access token".
- For other accounts this is the
oauth_token
, obtainable at either https://5minutes5vegans.org/twitteroauth or your own OAuth implementation.
users.access_token_secret
- Available for your developer account underneath the previous key, listed as "Access token secret".
- For other accounts this is the
oauth_token_secret
, obtainable at either https://5minutes5vegans.org/twitteroauth or your own OAuth implementation.
users.filters
A list of filters that this user will be retweeting matches from.
exclude
(optional)
A list of keywords that if found in a Tweet will exclude that Tweet from being retweeted.
delaytime
(optional)
The time to delay retweets with once a matching Tweet has been found. Defaults to two minutes.
Running the tests
Simply run yarn test
Disabling retweets
Retweets can be disabled for testing purposes by using the argument --dry-run
, e.g. node . --dry-run
. In dry run mode, matching tweets will be logged to the console but not retweeted.