Jabbergram

Published 01-01-0001 00:00:00

Installing Jabbergram on Gentoo

Installing packages

~ # emerge -av dev-python/pip dev-python/virtualenv dev-python/virtualenvwrapper

Creating a user with a home directory

~ # useradd -m -g users -G wheel,audio -s /bin/bash kronoz

Creating an isolated environment

~ $ echo "export WORKON_HOME=~/.virtualenvs" >> ~/.bashrc
~ $ echo "source /usr/bin/virtualenvwrapper.sh" >> ~/.bashrc
~ $ source ~/.bashrc
~ $ mkvirtualenv -p python3.4 jabbergram

Installing python packages

~ $ pip install jabbergram dnspython pip-review

Updating an isolated environment

~ $ pip install --upgrade pip
~ $ pip-review --local --interactive

Creating an account in telegram for bot and setting up

The first step: in the client, open a window with a meta-bot

@BotFather

The second step: add it to the roster

/start

The third step: initiate the process of creating an account for your bot

/newbot

The fourth step: enter a name for your bot

Jabber

The fifth step: enter the user name for your bot after completing the creation process and save the received token

USSRxmppbot

Step Six: Change Privacy Mode

/setprivacy

Creating an account in a jabber for a bot

Example for Prosody Server

~ # prosodyctl adduser jabbergram@ussr.win

Example for Ejabberd Server

TODO

Example for Openfire Server

TODO

Creating a configuration file

~ $ nano ~/.virtualenvs/jabbergram/config.ini
[config]
jid = jabbergram@ussr.win
password = пароль
muc_room = public@conference.ussr.win revkom@conference.ussr.win
nick = Telegram
token = ваш:токен
group = идентификатор_группы_1 идентификатор_группы_2

Adding the bot’s Jabbergram to startup

Variant via local.d

Installing Console Screen Multiplexer

~ # emerge -av app-misc/screen
~ # nano /etc/local.d/jabbergram.start
#!/bin/bash

su -c "screen -d -m -S jabbergram ~/.virtualenvs/jabbergram/bin/jabbergram.py ~/.virtualenvs/jabbergram/config.ini" kronoz
~ # chmod +x /etc/local.d/jabbergram.start

Variant via init.d

~ # nano /etc/init.d/jabbergram
#!/sbin/openrc-run

DIR=/home/ussr/.virtualenvs/jabbergram/bin
USER=ussr
CONFIG=/home/ussr/.virtualenvs/jabbergram/config.ini

start_stop_daemon_args="--user ${USER} --chdir ${DIR}"
command="${DIR}/jabbergram.py"
command_args="${CONFIG}"
command_background=yes
pidfile=/var/run/jabbergram.pid

depend()
{
    need net
}
~ # chmod +x /etc/init.d/jabbergram && rc-update add jabbergram default

Running the Jabbergram bot

Variant via local.d

~ $ ~ # /etc/local.d/jabbergram.start

Variant via init.d

~ # /etc/init.d/jabbergram start