RouxRC / gazouilleur

IRC bot for collaborative use and monitoring of Twitter
GNU Affero General Public License v3.0
19 stars 13 forks source link

Gazouilleur

Gazouilleur is an IRC bot offering Twitter interactions on multiple channels in order to:

Inspired by La Quadrature du Net's IRC bot UnGarage developped by Bram, Gazouilleur was developped for the daily organisational and collaborative needs of Regards Citoyens.

More functionalities include:

See the list of all available IRC commands in LIST_COMMANDS.md

Easy Install using Docker

For an easy install either on Linux, Mac OS X or Windows, the best solution is to rely on Docker.

1. Install Docker

First, you should deploy Docker on your machine following its official installation instructions.

Once you've got Docker installed and running, you will need Docker Compose to set up and orchestrate Hyphe services in a single line. Docker Compose is already installed along with Docker on Windows and Mac OS X, but you may need to install it for Linux.

2. Download Gazouilleur

Collect Gazouilleur's sourcecode from this git repository, then enter the resulting directory:

git clone https://github.com/RouxRC/gazouilleur.git gazouilleur
cd gazouilleur

3. Configure

Then, copy the default configuration files and edit them to adjust the settings to your needs:

# use "copy" instead of "cp" under Windows powershell
cp docker-config.env.example docker-config.env

Then edit docker-config.env file to configure the bot following gazouilleur/config.py.example's explanations. Do not put quotes around variables values and use only one line per variable, even for json formatted ones.

4. Prepare the Docker containers

You have two options: either collect, or build Gazouilleur's Docker container.

Pulling should be faster, but it will still take a few minutes to download or build everything either way.

5. Start the bot

Finally, start Gazouilleur with the following command, which will run it and display all of its logs in the console until stopped by pressing Ctrl+C.

docker-compose up

Or run the containers as a background daemon (for instance for production on a server):

docker-compose up -d

Regular Install (Debian/Ubuntu)

First download the repository:

 git clone https://github.com/RouxRC/gazouilleur.git
 cd gazouilleur

For an easy install on Debian and CentOS like distributions, you can try running bash bin/install.sh or follow step by step the installation script readable here.

After dependencies are installed, you will need to edit your configuration in gazouilleur/config.py, then run bash bin/configureDB.sh to prepare your Mongo database.

Depending on the desired options, the configuration will require to get Twitter and/or Identi.ca API rights (see below).

You can also scroll down to the detailed installation instructions below.

Note: There currently is no packaged version of Gazouilleur, but you can set it up as a system service thanks to Lunar^ by:

Run Gazouilleur

Installing with legacy dependencies

If you're running this bot after Jan 1th, 2020, you will need to use PyEnv to manage a Python2.7 environnement. To do that, the instructions are as follows ;

Installing PyEnv

Please follow the instructions here : https://pyenv.run/

Setting up the environnement

Type the following commands in your terminal ;

export PYENV_VIRTUALENV_DISABLE_PROMPT=1

eval "$(pyenv init --path)"

source $(which virtualenvwrapper.sh) || ( echo "Error: You must install virtualenvwrapper to use this starter: sudo pip -q install virtualenvwrapper" && exit 1 )

export PATH="$PYENV_ROOT/bin:$PATH"

eval "$(pyenv init -)"

eval "$(pyenv virtualenv-init -)"

export PYENV_ROOT="$HOME/.pyenv"

Theses commands indicate to PyEnv how to setup the virtual environnement.

Installing Python 2.7.18

Type the following commands in your terminal ;

pyenv install 2.7.18

pyenv virtualenv 2.7.18 gazouilleur

pip install -r requirements.txt

_NB : You might run into an issue while installing Twisted. You can install it directly from git like this pip install https://github.com/twisted/twisted/archive/refs/tags/twisted-15.1.0.zip. Run the command above again if needed. Also check your Python and Pip versions.

cd gazouilleur

pwd > ~/.pyenv/versions/gazouilleur/lib/python2.7/site-packages/gazouilleur.path

Run Gazouilleur

You should be able to launch Gazouilleur with the bin/gazouilleur start command, but in case it does no work, you can try with : twistd --pidfile gazouilleur.pid -y gazouilleur/bot.py.

Good luck !

Getting Twitter & Identi.ca API rights for a channel

Why create a Twitter API application?

In order to send tweets from IRC, each channel needs to be associated with a distinct Twitter account and its API tokens with "Read, Write, and Direct Messages" rights.

"Read only" rights can be sufficient if and only if "FORBID_POST" option is set for the channel : this case allows one to use Twitter's streaming and search API for monitoring keywords or accounts without wanting to send tweets.

Such monitoring is also permitted, with less accuracy, for configs without any Twitter account, by parsing IceRocket.com or Topy.com's HTML search results, but the accuracy and completeness is seriously impacted.

How to create a Twitter API application?

Getting Identi.ca API rights for a channel

Detailed Installation Instructions

(These instuctions are meant for GNU/Linux Debian/Ubuntu-like and CentOS-like distributions. Experiences on other distribs welcome!)

Requirements

Download the code

 git clone https://github.com/RouxRC/gazouilleur.git
 cd gazouilleur

Dependencies: MongoDB

Note: MongoDB being limited to 2Go databases on 32bit systems, it is recommanded to install Gazouilleur on a 64bit machine for extreme use of the Twitter keyword tracking functionnality.

Note2: MongoDB Version 2.2 at least is required to get the aggregate functions to work properly. Everything will work with older versions except for the "!tweetswith" command.

Edit your apt sources.list file to include the following line:

deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

Install the GPG key for this repository, update apt lists and install MongoDB:

curl -s http://docs.mongodb.org/10gen-gpg-key.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install mongodb-10gen
sudo service mongodb restart

You can configure the MongoDB server by editing /etc/mongodb.conf.

    echo "[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1" > mongodb.repo.tmp
    sudo mv mongodb.repo.tmp /etc/yum.repos.d/mongodb.repo
    # Then update yum's source list and install:
    sudo yum check-update
    sudo yum install mongo-10gen mongo-10gen-server
    sudo chkconfig mongod on
    sudo service mongod restart

Admin use: RockMongo is a nice PhpMyAdmin-like web tool to examine a MongoDB.

Prepare the Python environment

Configuration

How to update to the latests code modifications?

Run the following script:

 bin/update.sh

Then check your configuration file against gazouilleur/config.py.example to add any new possible option.

To use an Identi.ca account since the Pump.io migration, the following commands must also be ran after setting IDENTICA's USER in gazouilleur/config.py:

 source /usr/local/bin/virtualenvwrapper.sh
 workon gazouilleur
 python bin/auth_identica.py
 deactivate

Come over see the bot in action and ask any question on Regards Citoyens's IRC channel on Freenode! (irc://irc.freenode.net:#RegardsCitoyens)