All Projects β†’ takuti β†’ Twitter Bot

takuti / Twitter Bot

Licence: mit
πŸ‘» Markov chain-based Japanese twitter bot

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Twitter Bot

Hate Speech And Offensive Language
Repository for the paper "Automated Hate Speech Detection and the Problem of Offensive Language", ICWSM 2017
Stars: ✭ 543 (+4425%)
Mutual labels:  natural-language-processing, twitter
Stocksight
Stock market analyzer and predictor using Elasticsearch, Twitter, News headlines and Python natural language processing and sentiment analysis
Stars: ✭ 1,037 (+8541.67%)
Mutual labels:  natural-language-processing, twitter
Ultimate Metatags
A large snippet for your page's <head> that includes all the meta tags you'll need for OPTIMAL sharing and SEO. Extensive work has been put into ensuring you have the optimal images for the most important social media platforms.
Stars: ✭ 24 (+100%)
Mutual labels:  twitter
Language
Shared repository for open-sourced projects from the Google AI Language team.
Stars: ✭ 860 (+7066.67%)
Mutual labels:  natural-language-processing
Social Listener
Python project used to collect tweets and social-network data from Social's API
Stars: ✭ 9 (-25%)
Mutual labels:  twitter
Fix Twitter
Browser extension to fix dumb things about Twitter and TweetDeck (hidden β€œreplying to”, t.co links)
Stars: ✭ 25 (+108.33%)
Mutual labels:  twitter
Knowledge Graphs
A collection of research on knowledge graphs
Stars: ✭ 845 (+6941.67%)
Mutual labels:  natural-language-processing
Remote Dev Jobs Streamer
Match Tweets containing remote developer jobs using Filtered Stream and Tweet Annotations
Stars: ✭ 24 (+100%)
Mutual labels:  twitter
Guffer
Guffer tweets based on a daily schedule
Stars: ✭ 12 (+0%)
Mutual labels:  twitter
Syntree2vec
An algorithm to augment syntactic hierarchy into word embeddings
Stars: ✭ 9 (-25%)
Mutual labels:  natural-language-processing
Pke
Python Keyphrase Extraction module
Stars: ✭ 855 (+7025%)
Mutual labels:  natural-language-processing
Share on twitter
Simplest browser extension for Twitter users.
Stars: ✭ 8 (-33.33%)
Mutual labels:  twitter
Drl4nlp.scratchpad
Notes on Deep Reinforcement Learning for Natural Language Processing papers
Stars: ✭ 26 (+116.67%)
Mutual labels:  natural-language-processing
Spago
Self-contained Machine Learning and Natural Language Processing library in Go
Stars: ✭ 854 (+7016.67%)
Mutual labels:  natural-language-processing
Slimsocial For Twitter
Light version of Twitter. Light not only in weight but also in the use.
Stars: ✭ 24 (+100%)
Mutual labels:  twitter
Tweety
.NET Standard Library to help in managing Twitter Webhook APIs.
Stars: ✭ 11 (-8.33%)
Mutual labels:  twitter
Twitter sentiment analysis word2vec convnet
Twitter Sentiment Analysis with Gensim Word2Vec and Keras Convolutional Network
Stars: ✭ 24 (+100%)
Mutual labels:  twitter
Tweets
🐦 Tweet every 24 pull request
Stars: ✭ 8 (-33.33%)
Mutual labels:  twitter
Social ids
Get user ids from social network handlers
Stars: ✭ 9 (-25%)
Mutual labels:  twitter
Node Api.ai
[DEPRECATED] Ultimate Node.JS SDK for api.ai
Stars: ✭ 12 (+0%)
Mutual labels:  natural-language-processing

Markov-Chain-Based Japanese Twitter Bot

Build Status

Since this project is strongly optimized for Japanese, other languages are not supported 🍣

Description

Installation

If you want to host this bot directly on your local or server machine, you first need to install Ruby gems:

$ gem install bundle
$ bundle install

Note that this application specially depends on kusari, a gem for Japanese Markov chain.

Next, you should generate a directory ipadic/, the IPA dictionary for Japanese tokenization, as described in the Igo documentation.

Additionally, in order to connect to a Twitter account, the following environment variables need to be appropriately set:

export SCREEN_NAME=yootakuti

export CONSUMER_KEY=foo
export CONSUMER_SECRET=bar
export OAUTH_TOKEN=hoge
export OAUTH_TOKEN_SECRET=piyo

FYI: we can use direnv to flexibly configure project-specific environment variables:

$ brew install direnv
$ touch .envrc # and write the above `export` statements
$ direnv allow

Usage

Before enjoying this bot, you must download your tweet history from the Twitter setting page. The downloaded folder must be placed under /path/to/twitter-bot/data/, and the bot will use text column of data/tweets/tweets.csv. Note that this repository contains sample tweets.csv file.

Post on Twitter

After setting the environment variables, we can generate and post a markov tweet as:

$ ruby lib/post_tweet.rb

If you just want to check if a markov tweet is generated correctly, dry-run option is available.

$ ruby lib/post_tweet.rb dry-run

Hourly post by cron

Set your crontab as:

$ echo "01 * * * * /usr/local/rvm/wrappers/ruby-2.2.3/ruby /path/to/twitter-bot/lib/post_tweet.rb" > cron.txt
$ crontab cron.txt

For more detail of RVM+cron setting: RVM: Ruby Version Manager - Using Cron with RVM

Build API server

This repository implements a tiny Sinatra-based API server.

Run:

$ bundle exec foreman start # PORT=5000 by default

Eventually, http://localhost:5000/ and http://localhost:5000/tweet respectively execute lib/post_tweet.rb dry-run and lib/post_tweet.rb.

In case that you publicly build this API server, scheduling a request to /tweet would be an alternative choice to periodically post Markov-chain-based tweet.

Reply daemon

reply_daemon tracks tweets which contain SCREEN_NAME of your bot and replies to all of them:

$ ruby lib/reply_daemon.rb start

Stop the process:

$ ruby lib/reply_daemon.rb stop

Docker

You can easily setup this application as a Docker image:

$ docker build -t takuti/twitter-bot

Once the image has been created, running the scripts in container is straightforward:

$ docker run -it takuti/twitter-bot /bin/sh -c "ruby lib/post_tweet.rb"
$ docker run -it takuti/twitter-bot /bin/sh -c "ruby lib/post_tweet.rb dry-run"

By default, container automatically launches the API sever on port 5000 via bundle exec foreman start, so you can get access to http://localhost:5000/ once a container started running:

$ docker run -it -d -p 5000:5000 takuti/twitter-bot

Notice that, as long as the required environmental variables are properly set in container, http://localhost:5000/tweet also works as we expected.

Deploy on Heroku

Our Docker image enables us to make the API server public on Heroku:

$ heroku create takuti-twitter-bot
$ heroku container:push web

See https://takuti-twitter-bot.herokuapp.com/, for example.

While https://takuti-twitter-bot.herokuapp.com/tweet currently returns an error, you can make it available by configuration of variables.

Deploy on Dokku

Dokku is a Docker-powered OSS PaaS which enables you to build mini-Heroku-like platform on your own server. Similarly to the deployment on Heroku, once you have set up a server with Dokku, the API server can be easily deployed as a Docker image.

Server:

$ dokku apps:create twitter-bot
$ dokku config:set twitter-bot DOKKU_DOCKERFILE_START_CMD="bundle exec foreman start"

Note that setting a way to start running a container to DOKKU_DOCKERFILE_START_CMD is important, because Dokku directly executes a task defined as the web process in Procfile by default. Consequently, your container launches differently from what CMD defines in Dockerfile.

Local:

$ cd /path/to/takuti/twitter-bot
$ git remote add dokku [email protected]:twitter-bot
$ git push dokku master

Eventually, an "Application deployed" message shows up on your local screen with corresponding URL, and you can get access to the API server.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].