https://github.com/hugovk/randomsentencebot
Tweet a random line from a text file.
https://github.com/hugovk/randomsentencebot
bot project-gutenberg python random sentence six-word-story twitterbot words
Last synced: 6 months ago
JSON representation
Tweet a random line from a text file.
- Host: GitHub
- URL: https://github.com/hugovk/randomsentencebot
- Owner: hugovk
- Created: 2015-02-22T20:13:56.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-10-30T17:08:40.000Z (almost 5 years ago)
- Last Synced: 2025-03-28T17:47:51.810Z (7 months ago)
- Topics: bot, project-gutenberg, python, random, sentence, six-word-story, twitterbot, words
- Language: Python
- Homepage: https://twitter.com/sixworderbot
- Size: 950 KB
- Stars: 6
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# randomsentencebot
[](https://travis-ci.org/hugovk/randomsentencebot)
[](https://www.python.org/downloads/)
[](https://github.com/psf/black)Tweet a random line from a text file. Use this to make your own Twitter bots.
For example,
**[Six-Worder Bot](https://twitter.com/sixworderbot)** is tweeting six-word stories picked at random from a text file of six-word sentences taken from the [Project Gutenberg August 2003 CD](http://www.gutenberg.org/wiki/Gutenberg:The_CD_and_DVD_Project). Think along the lines of "For Sale, Baby Shoes, Never Worn" ([probably not by Ernest Hemingway](http://quoteinvestigator.com/2013/01/28/baby-shoes/)). See the [archive](https://hugovk.github.io/randomsentencebot/).In [@sixworderbot](https://twitter.com/sixworderbot)'s case, the text file was generated using [gutengrep](https://github.com/hugovk/gutengrep) something like this:
```bash
gutengrep.py "^\W*([a-zA-ZåäöÅÄÖàéÉÈ횊]+['[a-zA-Z]+]?[- :;,.¿?\!]+){6}\W*$" --correct --cache > /tmp/1.txt# Remove blanks and duplicates:
sort /tmp/1.txt | uniq > six-word-sentences.txt #
```## Setup
Before you can use this script you will need to get API credentials from Twitter.
Go to https://developer.twitter.com/en/apps and create a new app. Once approved you will be able to access the credentials below.
consumer_key: TODO_ENTER_YOURS
consumer_secret: TODO_ENTER_YOURS
access_token: TODO_ENTER_YOURS
access_token_secret: TODO_ENTER_YOURSCopy `randomsentencebot_example.yaml` to `randomsentencebot.yaml`, then open `randomsentencebot.yaml` and replace each `TODO_ENTER_YOURS` with the value from your Twitter app.