Skip to main content

Twitter bot for sci-com and policy-com

Project description

drawingViewsOnDrugsBotdrawing

A bot application sharing scientific publications and educated opinions on psychedelic research, harm reduction and drug policy issues. A collaboration with: #mybrainmychoice

drawing

What it does:

  • Reads and parses a list of RSS feeds (i.e. PubMed) Tweets an article's title, link, abstract, and authors as a 5/5 thread :thread:.
  • Retweets older RSS post after a given time.
  • Retweets the most retweeted and up-voted post from:
    • a global search for specified keywords or hashtags defined on Settings.add_hashtag.
    • a search result from a given distribution Twitter list defined on Settings.mylist_id.
  • Interacts with users by faving posts from the above.
  • Schedule jobs for any of the above.
  • Send automated debug reports via Telegram.

All functions can be used independently.

Install

  1. Download or git clone Twitterbot:
    • git clone https://github.com/franasal/science_bot.git
  2. Run:
    • cd scibot
    • pip install . --user
  3. Create a Twitter application, and generate keys, tokens etc.
  4. Create a Telegram bot for post and debugging notifications.
  5. Modify the settings in the source code.
    • Modify feed_urls list to add the RSS feeds of your choice. Here you can find a description on how to set an RSS search.
    • Modify the variables in the example.env file and add keys, tokens etc. for connecting to your Twitter app and save it as .env in your home directory.
    • Modify retweet_include_words for keywords you want to search and retweet, and retweet_exclude_words for keywords you would like to exclude from retweeting. For example retweet_include_words = ["foo"] and retweet_exclude_words = ["bar"] will include any tweet with the word "foo", as long as the word "bar" is absent. This list can also be left empty, i.e. retweet_exclude_words = [].
    • Modify or add jobs to the scheduled_job() function.

Requirements

  • Python 3+
  • Twitter account
  • Telegram account

Usage

Read the RSS feeds and post a thread to Twitter account:

$ scibot rss

Search globally for tweets and retweet them:

$ scibot rtg

Search for tweets within a Twitter list and retweet them:

$ scibot rtl

Retweet last own tweet:

$ scibot rto

Deploy:

Here you can learn how set-up tasks for the the scheduled_job() function

There are some good free cloud solutions such as pythonanywhere, where you can deploy the bot, to do that just run:

$ scibot sch

:hibiscus:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scienceBot-0.1.1.tar.gz (13.4 kB view hashes)

Uploaded Source

Built Distribution

scienceBot-0.1.1-py3-none-any.whl (12.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page