This bot for @basicbishoujo@mastodon.art
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Alex Huddleston c030bd9f1a Small hotfix to hardcode data path for renaming files. 1 year ago
config Initial commit. I should never have tried to commit already working code as an 'initial commit' but here we are. 1 year ago
data Initial commit. I should never have tried to commit already working code as an 'initial commit' but here we are. 1 year ago
lib Ignoring the backup directtory, hotfix to ensure files are uploaded in numerical order by filename suffix. 1 year ago
.gitignore Ignoring the backup directtory, hotfix to ensure files are uploaded in numerical order by filename suffix. 1 year ago
Dockerfile Initial commit. I should never have tried to commit already working code as an 'initial commit' but here we are. 1 year ago
Pipfile Initial commit. I should never have tried to commit already working code as an 'initial commit' but here we are. 1 year ago
README.md Initial commit. I should never have tried to commit already working code as an 'initial commit' but here we are. 1 year ago
docker-compose.yml Initial commit. I should never have tried to commit already working code as an 'initial commit' but here we are. 1 year ago
rename_media_files.py Small hotfix to hardcode data path for renaming files. 1 year ago
twitter_bot.py Initial commit. I should never have tried to commit already working code as an 'initial commit' but here we are. 1 year ago

README.md

Twitter Bot @basicbishoujo@mastodon.art

I made this for @basicbishoujo@mastodon.art to post things every day for them.

Requirements

You will need Python3 and the pipenv package. Optionally, you can install docker and docker-compose and follow the docker instructions.

Installation

Python Native

In order to install the necessary python packages needed for the bot, run a pipenv install as usual.

pipenv install

Docker / docker-compose

You should be able to build the container with a single docker-compose command:

docker-compose up --build --no-start

Additionally, you may need to set the permissions for the data/ directory to write for guest in order to allow the container to write to a .tmp_counter file used to keep track of which file to upload.

sudo chmod 777 -R data/

NOTE: Be very careful with doing this, it may be safer to simply sudo chown 991:991 -R data/ instead in order to keep an entire directory from being able to be written to by any system user. However, this comes with the downside of needing to sudo cp every file you want to have uploaded in data/

Configuration

In order to run the bot, you will need to copy the template_config.json to config.json and fill the required fields:

  • *api_key
  • *api_key_secret
  • *acccess_token
  • *acccess_token_secret
  • valid_file_formats
  • timezone
  • post_time

* These can be found by creating an app at https://developer.twitter.com.

valid_file_formats is used to help the bot filter out what kinds of file formats you are attempting to upload. I don't recommend changing this much, as there are only so many file formats officially supported by Twitter in the first place.

timezone should follow your preferred timzone for when you want the bot to post each day, and post_time should be in 24-hour time format an integer representing the time each day you want to post, for example: 1530 would have the bot post at 3:30 PM.

Usage

Python

You should be able to start the bot by issuing the following command:

pipenv run python twitter_bot.py

Docker / docker-compose

You should be able to start the container by issuing the following command:

docker-compose start

Functionality

This bot will take whatever is in the data/ directory that is a valid media file format and upload one media file to Twitter on the authenticated user account each day at a certain time, iterating through each item.

Once the bot finishes iterating through the available files, it will loop back to the beginning.

Contact

If you have any questions or need help setting up (or want to report a bug), you can contact me in the following places most effectively:

Discord: shadow8t4#8276

Telegram: @shadow8t4

Matrix: @shadow8t4:matrix.werefox.dev