A Telegram bot that send NBA related tweets from ESPN Stats & Info, hosted as a https://webtask.io webtask.
When given a tweet ID (e.g. with a webhook) checkes whether the tweet or the photos matches certain keywords and sends it to a specific Telegram chat.
| @nba_stats | |
|---|---|
| /r/NBAStatsTelegram |
-
Keyswords go inside
main.jsas the parametersplayersKeywords,coachesKeywords,mvpsKeywords,teamsKeywords,draftKeywordsandwordsKeywords.
Each keyword list is aPromised array of strings.
Keywords are case-insensitive. -
Blacklist entries go inside
main.jsas the parameterblacklistPromise.
The blacklist parameter is aPromised array of Objects.
Each Object is of the form{ is_accepted_because: "Hawks",blacklist: "Black Hawks"}. This means that if the bot will findHawksas a keyword but alsoBlack Hawks, then it won't considerHawksas a keyword for this tweet. Blacklist Keywords are case-insensitive. -
Create
secrets.txtfor API keys.
telegram_chat_id=<YOUR_TELEGRAM_CHAT_ID (get at @get_id_bot)>
telegram_bot_key=<YOUR_TELEGRAM_BOT_KEY>
twitter_consumer_key=<get at https://apps.twitter.com/app/XXXXXXXX/keys>
twitter_consumer_secret=<get at https://apps.twitter.com/app/XXXXXXXX/keys>
twitter_access_token_key=<get at https://apps.twitter.com/app/XXXXXXXX/keys>
twitter_access_token_secret=<get at https://apps.twitter.com/app/XXXXXXXX/keys>
ocr_space_api_key=<get at https://ocr.space/ocrapi>
- Create a new https://webtask.io webtask.
wt create --name <NAME> --secrets-file secrets.txt main.js(npm modules will be added automatically because of the package.json file.)
- On https://ifttt.com create an applet from https://ifttt.com/create/if-new-tweet-by-a-specific-user?sid=2 to https://ifttt.com/create/if-new-tweet-by-a-specific-user-then-make-a-web-request?sid=6.
On the webhook url give your webtask url and append
?tweet_url={{LinkToTweet}}
wt update <NAME> main.js
Create the file config_test.json along side main.js
{
"telegram": {
"chat_id": "<YOUR_TELEGRAM_CHAT_ID (get at @get_id_bot)>",
"bot_key": "<YOUR_TELEGRAM_BOT_KEY>"
},
"twitter": {
"consumer_key": "<get at https://apps.twitter.com/app/XXXXXXXX/keys>",
"consumer_secret": "<get at https://apps.twitter.com/app/XXXXXXXX/keys>",
"access_token_key": "<get at https://apps.twitter.com/app/XXXXXXXX/keys>",
"access_token_secret": "<get at https://apps.twitter.com/app/XXXXXXXX/keys>"
},
"ocr_space_api_key": "<get at https://ocr.space/ocrapi>"
}npm test / yarn test
node main.js debug