December 31, 2012

How to install your very own UnBot

As you may know, UnBot is the eXtensible Wikimedia Bot. Its code is hosted at GitHub, and Launchpad provides its bug tracker, blueprints and other nice tools. Of course, the bot is done by the same clever cat who owns this blog.

The bot is done in Python for the Spanish Wikipedia channel, at Freenode (#wikipedia-es). But I tried to make it a bit configurable, so let's download it and put it working on your channel! Note that this is done with the UnBot Shiva 13.04 Beta version, released the 1st of January of 2013. Of course, I'm the developer and I have it before its release :)



First Step: Install Git

I hope you do this on Linux. If you don't, go away! Really, I don't care about Windows Git users :P
To install Git, it's easy. Just run the following command on a Terminal:
$ sudo apt-get install git -y
Enter your password, and voilà!

Second Step: Download Last UnBot Version

Now that you have installed Git, it's the time to download your very own version of UnBot. Of course, as the Git repositories have also the last version, you'll always download the last version. That's rolling-release-ish ;)
Run this commands to create a directory and install UnBot on it.
$ mkdir ~/unbot
$ cd ~/unbot
$ git init
$ git pull https://github.com/unbot/unrar.git
That's it! You'll have downloaded the stable branch of the project, which is already Shiva. But if you want another branch, like "master" (old-stable), run this:
$ git checkout master

 Third Step: Configure It

Now let's open the shiva.py file. I'll paste you the things you can edit.
#############
#  CONFIGS           #
#############

# Red
network = 'irc.freenode.net' # Replace it with the network you want to connect, e.g. irc.spotchat.org
# Puerto
port = 6667 #Replace it with the port
# Nick
nick = 'unbot' # Replace it with the nickname
# Realname
realname = 'Shiva 13.04 Beta' # Replace it with the realname
# Ident
ident = 'shiva' # Replace it with the ident
# Contraseña de nickserv
npass = 'openaccess' # Replace it with the NickServ password, if any
# Canal principal
chan = '#wikipedia-es' # Replace it with the main channel
# Canales a entrar
chans = ["#sandyd", "#undb", "#undb-es", "#wikipedia-es-bots", "##bots-debug"] # You can add or remove the autojoin channels here
# Dueño
owner = "wikimedia/unrar" # Cloak or IP of the owner (*!*@this)
# Mensaje de error de permisos
perror = "¿Pero quién eres? ¡No estás autorizado a usar este comando!" # Error message when somebody who's not the owner uses some owner-ish command like &quit
# Prefijos y sus respectivas URLS base
projects = {'wikt': 'https://es.wiktionary.org', 'b': 'https://es.wikibooks.org', 'n': 'https://es.wikinews.org', 'commons': 'https://commons.wikimedia.org', 'meta': 'https://meta.wikimedia.org', 'q': 'https://es.wikiquote.org', 's': 'https://es.wikisource.org', 'v': 'https://es.wikiversity.org', 'species': 'https://es.wikispecies.org', 'wikimedia': 'https://wikimediafoundation.org', 'incubator': 'https://incubator.wikimedia.org', 'mw': 'https://mediawiki.org'}
# Códigos de lenguaje
langs = ['es', 'en', 'ca']
# Idioma por defecto
deflang = 'es'
# Nombres de los meses
mname = {'01': 'enero', '02': 'febrero', '03': 'marzo', '04': 'abril', '05': 'mayo', '06': 'junio', '07': 'julio', '08': 'agosto', '09': 'septiembre', '10': 'octubre', '11': 'noviembre', '12': 'diciembre'} # Replace the names with the names in your language
# Descripcion de los comandos
descs = {'join': 'Entra a un canal. Solo para administradores.', 'part': 'Sale de un canal. Solo para administradores.', 'ping': 'Te responde con pong.', 'nas': 'Sin parámetros, te muestra los nicks asignados a tu cuenta. Si especificas una cuenta como parámetro, añade tu nick a ella (si no está asignado ya a otra).', 'ip': 'Muestra información sobre una IP.', 'gatos': 'Muestra las categorías de un artículo.', 'cats': 'Muestra las categorías de un artículo.', 'awiki': 'Muestra la URL de un enlace wiki.', 'info': 'Con parámetros, muestra información del nick dado. Sin parámetros, muestra la de tu nick. Si el nick tiene una cuenta asociada, muestra su información.', 'quit': 'Sale del IRC. Sólo para administradores.'} # Replace it with the help of the commands
# Uso de los comandos
usos = {'join': '&join <#canal>', 'part': '&part <#canal>', 'ping': '&ping', 'nas': '&nas [cuenta]', 'awiki': '&awiki [idioma:][proyecto:]<artículo>', 'cats': '&cats [idioma:][proyecto:]<artículo>', 'gatos': '&gatos [idioma:][proyecto:]<artículo>', 'info': '&info [[idioma:][proyecto:]<nick>]', 'ip': '&ip xxx.xxx.xxx.xxx', 'quit': '&quit'} # Replace it with the usage of the commands

It may look a bit tricky because it's on Spanish, but it's easy to configure. The last thing you can do is edit all the messages in your language.

Fourth Step: Run It

To run it, just type:
$ python shiva.py
Or, if you want to run it on the background:
$ nohup python shiva.py &

Fifth Step: Meow

Just join #wikipedia-es or #ubuntuforums or #undb to meow me!


No comments:

Post a Comment