This Twitter bot is designed to consume specific top-headlines from https://newsapi.org and to post them periodically on Twitter. The bot itself is very configurable. Parameters like posting time period, language of the post, topic etc. can be configured via environment variables described bellow.
The showcase example can be found here: https://twitter.com/crypto_topics
I recommend you to setup and install this bot in Heroku like I did it, but of course you can do it on Google Cloud or AWS. In case you want to test it or just run it locally or in your personal evironment, python3.7.* and PIP must be installed.
git clone https://github.com/fmiskovic/woodpecker-twitter-bot.git
or download this repository.
pip3 install -r requirements.txt
First you need to register at Twitter Developer and News API in order to generate keys and access tokens which must be added to the following environment variables:
NEWS_API_KEY
CONSUMER_KEY
CONSUMER_SECRET
ACCESS_KEY
ACCESS_SECRET
BOT_SLEEP_TIME
- specifies how for long the bot will be inactive in seconds - default value is 7200.
BOT_COUNTRY
- specifies country of the news source, for example: us
, pl
, gb
etc.
BOT_CATEGORY
- specifies category of the news source, examples: entertainment
, sports
, health
, technology
etc.
BOT_LANGUAGE
- specifies language of the news source, default is: en
.
BOT_HASHTAG
- specifies which hashtags to add in a twitter post, default is #cryptocurrencynews
.
BOT_QUERIES
- specifies key words for searching the news, for example: bitcoin
, basketball
, kardashian
or anything else.
BOT_BLACKLISTED_SOURCES
- specifies blacklisted news sources that you don't want to consume.
For more details check: https://newsapi.org/docs/endpoints/top-headlines
Open terminal and run:
python3 bot.py
That is it. If you need my support, do not hesitate to contact me via fmiskovic@yandex.com.