initial commit
This commit is contained in:
commit
ae4b9b3c94
|
@ -0,0 +1,7 @@
|
|||
*.ini
|
||||
.dir-locals.el
|
||||
dist
|
||||
MANIFEST
|
||||
*.egg-info
|
||||
__pycache__
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
<div id="table-of-contents">
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents">
|
||||
<ul>
|
||||
<li><a href="#orgheadline13">1. jabbergram</a>
|
||||
<ul>
|
||||
<li><a href="#orgheadline6">1.1. English</a>
|
||||
<ul>
|
||||
<li><a href="#orgheadline1">1.1.1. About</a></li>
|
||||
<li><a href="#orgheadline2">1.1.2. Installation</a></li>
|
||||
<li><a href="#orgheadline3">1.1.3. Configuration</a></li>
|
||||
<li><a href="#orgheadline4">1.1.4. Usage</a></li>
|
||||
<li><a href="#orgheadline5">1.1.5. License</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgheadline12">1.2. Castellano</a>
|
||||
<ul>
|
||||
<li><a href="#orgheadline7">1.2.1. Acerca de</a></li>
|
||||
<li><a href="#orgheadline8">1.2.2. Instalación</a></li>
|
||||
<li><a href="#orgheadline9">1.2.3. Configuración</a></li>
|
||||
<li><a href="#orgheadline10">1.2.4. Uso</a></li>
|
||||
<li><a href="#orgheadline11">1.2.5. Licencia</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
# jabbergram<a id="orgheadline13"></a>
|
||||
|
||||
## English<a id="orgheadline6"></a>
|
||||
|
||||
### About<a id="orgheadline1"></a>
|
||||
|
||||
With this program, it's possible to use a MuC `XMPP` room to talk to a group on `Telegram` and vice versa. The aim of this program is to be just a simple gateway, just pass text from one way to the other. Once it's stable, it probably won't have more improvements, since I don't need them.
|
||||
|
||||
### Installation<a id="orgheadline2"></a>
|
||||
|
||||
As with any program that uses python, it should be used a virtual environment (virtualenv), but that is user selectable. It's possible to use one of the next installation methods:
|
||||
|
||||
Install via pip:
|
||||
|
||||
$ su -c "pip3 install jabbergram"
|
||||
|
||||
Clone the repository:
|
||||
|
||||
$ git clone git://daemons.cf/jabbergram
|
||||
$ cd jabbergram
|
||||
$ su -c "pip3 install -r requirements.txt"
|
||||
$ su -c "python3 setup.py install"
|
||||
|
||||
### Configuration<a id="orgheadline3"></a>
|
||||
|
||||
This program is simple, it even doesn't have a `help` menu. First thing you need to do is to create `Telegram` Bot. To do so, you must have a telegram account and talk to [BotFather](https://telegram.me/botfather). Then, execute:
|
||||
|
||||
/start
|
||||
/newbot
|
||||
YourNameBot # ended in bot, always
|
||||
# then it will show your bot token, save it
|
||||
/setprivacy
|
||||
YourNameBot
|
||||
# now press Disable
|
||||
|
||||
The `/setprivacy` option is to make the bot read all what it's said to him, not only when using commands. It's necessary to make `jabbergram` work. More info on creating `Telegram` bots at their [webpage](https://core.telegram.org/bots).
|
||||
|
||||
Then, you will have to create a config file. We'll call it `config.ini`. In that file, enter the next parameters:
|
||||
|
||||
[config]
|
||||
jid = exampleJid@nope.org
|
||||
password = difficultPassword
|
||||
muc_room = exampleMuc@muc.nope.org
|
||||
nick = jabbergram
|
||||
token = jabbergramBotTokken
|
||||
group = -10293943920
|
||||
|
||||
The only thing worth mentioning is the `token` section, which is said to you when creating the bot, and the `group`, that is the `Telegram` group ID.
|
||||
|
||||
There's no easy way to see this from telegram, so you can use the separate utility called `seeIdGroups.py`. To execute it, you only need to set the `token` parameter in the config file. You will need that somebody invite the bot to the group. Also, people on that group must send some messages, so the utility can grab it's id. It may take a couple. When you have the group ID you want, just press Ctrl-c, copy it to the config file (even the minus symbol), and the configuration will be done.
|
||||
|
||||
### Usage<a id="orgheadline4"></a>
|
||||
|
||||
You can create all config files you want. You will only need to pass it as parameter, but if you don't it will try to grab `config.ini` by default, and it will fail if it doesn't exist:
|
||||
|
||||
# it's advisable to use tmux or screen to execute the next order
|
||||
$ jabbergram.py example.ini
|
||||
|
||||
### License<a id="orgheadline5"></a>
|
||||
|
||||
This program is free software: you can redistribute it and / or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, Either version 3 of the License, or
|
||||
(At your option) any later version.
|
||||
|
||||
This program is distributed in the hope That it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
Along With This Program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
## Castellano<a id="orgheadline12"></a>
|
||||
|
||||
### Acerca de<a id="orgheadline7"></a>
|
||||
|
||||
Con este programa, es posible utilizar una sala `XMPP` para hablar con un grupo de `Telegram` y viceversa. El objetivo de este programa es el de ser sólo una pasarela sencilla, sólo tiene que pasar el texto de un lado al otro. Una vez que sea estable, probablemente no tendrá más mejoras, ya que yo no las necesito.
|
||||
|
||||
### Instalación<a id="orgheadline8"></a>
|
||||
|
||||
Como con cualquier programa escrito en `Python`, deberia ser usado en un entorno virtual (virtualenv), pero eso queda a la elección del usuario. Es posible utilizar uno de los siguientes métodos de instalación:
|
||||
|
||||
Instalar a través de `pip`:
|
||||
|
||||
$ su -c "pip3 instalar jabbergram"
|
||||
|
||||
Clonar el repositorio:
|
||||
|
||||
$ git clone git: //daemons.cf/jabbergram
|
||||
$ cd jabbergram
|
||||
$ su -c "pip3 instalar requirements.txt -r"
|
||||
$ su -c "python3 setup.py instalar"
|
||||
|
||||
### Configuración<a id="orgheadline9"></a>
|
||||
|
||||
Este programa es simple, no tiene ni un menú de `ayuda`. Lo primero que hay que hacer es crear el bot de `Telegrama`. Para ello, hay que tener una cuenta de `Telegram` y hablar con [BotFather](https://telegram.me/botfather). A continuación, ejecuta:
|
||||
|
||||
/comienzo
|
||||
/newbot
|
||||
NombreDelBot # terminado en bot, siempre
|
||||
# A continuación, se mostrará el token del bot, hay que guardarlo
|
||||
/setprivacy
|
||||
NombreDelBot
|
||||
# Ahora hay que pulsar desactivar
|
||||
|
||||
La opción `/setprivacy` es para hacer que el robot pueda leer todo lo que se dice en el grupo, no sólo cuando se utilizan los comandos. Es necesario para hacer que `jabbergram` funcione. Más información sobre la creación los bots de `Telegrama` en su [página web](https://core.telegram.org/bots).
|
||||
|
||||
A continuación, hay que crear un archivo de configuración, que llamaremos `config.ini`. En ese archivo, introduce los siguientes parámetros:
|
||||
|
||||
[Config]
|
||||
JID = exampleJid@nope.org
|
||||
password = difficultPassword
|
||||
muc_room = exampleMuc@muc.nope.org
|
||||
nick = jabbergram
|
||||
token = jabbergramBotTokken
|
||||
group = -10,293,943,920
|
||||
|
||||
La única cosa que vale la pena mencionar es la sección del `token` (que es la que nos da cuando se crea el robot) y el `group`, que es ID del grupo de `Telegram`.
|
||||
|
||||
No hay manera fácil de ver el ID desde `Telegram`, por lo que se puede utilizar el programa llamado `seeIdGroups.py`. Para ejecutarlo sólo es necesario establecer el parámetro `token` del archivo de configuración. Necesitarás que alguien invite al bot al grupo. Además, las personas de ese grupo deben enviar algunos mensajes, para que el programa pueda coger su ID. Puede llevar unos segundos el que aparezcan los mensajes. Cuando se tenga el ID de grupo que se quiere, sólo hay que pulsar Ctrl-c, copiarlo en el archivo de configuración (incluido el simbolo menos), y la configuración estará terminada.
|
||||
|
||||
### Uso<a id="orgheadline10"></a>
|
||||
|
||||
Se pueden crear todos los archivos de configuración que se deseen. Sólo tendrás que pasarlo como parámetro al programa, si no se hace se intentará coger el archivo `config.ini` por defecto, y se producirá un error si no existe:
|
||||
|
||||
# Es recomendable utilizar tmux o la pantalla para ejecutar la siguiente orden
|
||||
$ Jabbergram.py example.ini
|
||||
|
||||
### Licencia<a id="orgheadline11"></a>
|
||||
|
||||
This program is free software: you can redistribute it and / or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, Either version 3 of the License, or
|
||||
(At your option) any later version.
|
||||
|
||||
This program is distributed in the hope That it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
Along With This Program. If not, see <http://www.gnu.org/licenses/>.
|
|
@ -0,0 +1,141 @@
|
|||
* jabbergram
|
||||
** English
|
||||
*** About
|
||||
With this program, it's possible to use a MuC =XMPP= room to talk to a group on =Telegram= and vice versa. The aim of this program is to be just a simple gateway, just pass text from one way to the other. Once it's stable, it probably won't have more improvements, since I don't need them.
|
||||
*** Installation
|
||||
As with any program that uses python, it should be used a virtual environment (virtualenv), but that is user selectable. It's possible to use one of the next installation methods:
|
||||
|
||||
Install via pip:
|
||||
#+BEGIN_SRC sh
|
||||
$ su -c "pip3 install jabbergram"
|
||||
#+END_SRC
|
||||
|
||||
Clone the repository:
|
||||
#+BEGIN_SRC sh
|
||||
$ git clone git://daemons.cf/jabbergram
|
||||
$ cd jabbergram
|
||||
$ su -c "pip3 install -r requirements.txt"
|
||||
$ su -c "python3 setup.py install"
|
||||
#+END_SRC
|
||||
*** Configuration
|
||||
This program is simple, it even doesn't have a =help= menu. First thing you need to do is to create =Telegram= Bot. To do so, you must have a telegram account and talk to [[https://telegram.me/botfather][BotFather]]. Then, execute:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
/start
|
||||
/newbot
|
||||
YourNameBot # ended in bot, always
|
||||
# then it will show your bot token, save it
|
||||
/setprivacy
|
||||
YourNameBot
|
||||
# now press Disable
|
||||
#+END_SRC
|
||||
|
||||
The =/setprivacy= option is to make the bot read all what it's said to him, not only when using commands. It's necessary to make =jabbergram= work. More info on creating =Telegram= bots at their [[https://core.telegram.org/bots][webpage]].
|
||||
|
||||
Then, you will have to create a config file. We'll call it =config.ini=. In that file, enter the next parameters:
|
||||
|
||||
#+BEGIN_SRC text
|
||||
[config]
|
||||
jid = exampleJid@nope.org
|
||||
password = difficultPassword
|
||||
muc_room = exampleMuc@muc.nope.org
|
||||
nick = jabbergram
|
||||
token = jabbergramBotTokken
|
||||
group = -10293943920
|
||||
#+END_SRC
|
||||
|
||||
The only thing worth mentioning is the =token= section, which is said to you when creating the bot, and the =group=, that is the =Telegram= group ID.
|
||||
|
||||
There's no easy way to see this from telegram, so you can use the separate utility called =seeIdGroups.py=. To execute it, you only need to set the =token= parameter in the config file. You will need that somebody invite the bot to the group. Also, people on that group must send some messages, so the utility can grab it's id. It may take a couple. When you have the group ID you want, just press Ctrl-c, copy it to the config file (even the minus symbol), and the configuration will be done.
|
||||
*** Usage
|
||||
You can create all config files you want. You will only need to pass it as parameter, but if you don't it will try to grab =config.ini= by default, and it will fail if it doesn't exist:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
# it's advisable to use tmux or screen to execute the next order
|
||||
$ jabbergram.py example.ini
|
||||
#+END_SRC
|
||||
*** License
|
||||
#+BEGIN_SRC text
|
||||
This program is free software: you can redistribute it and / or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, Either version 3 of the License, or
|
||||
(At your option) any later version.
|
||||
|
||||
This program is distributed in the hope That it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
Along With This Program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#+END_SRC
|
||||
** Castellano
|
||||
*** Acerca de
|
||||
Con este programa es posible utilizar una sala =XMPP= para hablar con un grupo de =Telegram= y viceversa. El objetivo de este programa es el de ser sólo una pasarela sencilla, sólo tiene que pasar el texto de un lado al otro. Una vez que sea estable, probablemente no tendrá más mejoras, ya que yo no las necesito.
|
||||
*** Instalación
|
||||
Como con cualquier programa escrito en =Python=, deberia ser usado en un entorno virtual (virtualenv), pero eso queda a la elección del usuario. Es posible utilizar uno de los siguientes métodos de instalación:
|
||||
|
||||
Instalar a través de =pip=:
|
||||
#+BEGIN_SRC sh
|
||||
$ su -c "pip3 instalar jabbergram"
|
||||
#+END_SRC
|
||||
|
||||
Clonar el repositorio:
|
||||
#+BEGIN_SRC sh
|
||||
$ git clone git://daemons.cf/jabbergram
|
||||
$ cd jabbergram
|
||||
$ su -c "pip3 instalar requirements.txt -r"
|
||||
$ su -c "python3 setup.py instalar"
|
||||
#+END_SRC
|
||||
*** Configuración
|
||||
Este programa es simple, no tiene ni un menú de =ayuda=. Lo primero que hay que hacer es crear el bot de =Telegrama=. Para ello, hay que tener una cuenta de =Telegram= y hablar con [[https://telegram.me/botfather][BotFather]]. A continuación, ejecuta:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
/start
|
||||
/newbot
|
||||
NombreDelBot # terminado en bot, siempre
|
||||
# A continuación, se mostrará el token del bot, hay que guardarlo
|
||||
/setprivacy
|
||||
NombreDelBot
|
||||
# Ahora hay que pulsar desactivar
|
||||
#+END_SRC
|
||||
|
||||
La opción =/setprivacy= es para hacer que el robot pueda leer todo lo que se dice en el grupo, no sólo cuando se utilizan los comandos. Es necesario para hacer que =jabbergram= funcione. Más información sobre la creación los bots de =Telegrama= en su [[https://core.telegram.org/bots][página web]].
|
||||
|
||||
A continuación, hay que crear un archivo de configuración, que llamaremos =config.ini=. En ese archivo, introduce los siguientes parámetros:
|
||||
|
||||
#+BEGIN_SRC text
|
||||
[Config]
|
||||
JID = exampleJid@nope.org
|
||||
password = difficultPassword
|
||||
muc_room = exampleMuc@muc.nope.org
|
||||
nick = jabbergram
|
||||
token = jabbergramBotTokken
|
||||
group = -10,293,943,920
|
||||
#+END_SRC
|
||||
|
||||
La única cosa que vale la pena mencionar es la sección del =token= (que es la que nos da cuando se crea el robot) y el =group=, que es ID del grupo de =Telegram=.
|
||||
|
||||
No hay manera fácil de ver el ID desde =Telegram=, por lo que se puede utilizar el programa llamado =seeIdGroups.py=. Para ejecutarlo sólo es necesario establecer el parámetro =token= del archivo de configuración. Necesitarás que alguien invite al bot al grupo. Además, las personas de ese grupo deben enviar algunos mensajes, para que el programa pueda coger su ID. Puede llevar unos segundos el que aparezcan los mensajes. Cuando se tenga el ID de grupo que se quiere, sólo hay que pulsar Ctrl-c, copiarlo en el archivo de configuración (incluido el simbolo menos), y la configuración estará terminada.
|
||||
*** Uso
|
||||
Se pueden crear todos los archivos de configuración que se deseen. Sólo tendrás que pasarlo como parámetro al programa, si no se hace se intentará coger el archivo =config.ini= por defecto, y se producirá un error si no existe:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
# Es recomendable utilizar tmux o la pantalla para ejecutar la siguiente orden
|
||||
$ jabbergram.py example.ini
|
||||
#+END_SRC
|
||||
*** Licencia
|
||||
#+BEGIN_SRC text
|
||||
This program is free software: you can redistribute it and / or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, Either version 3 of the License, or
|
||||
(At your option) any later version.
|
||||
|
||||
This program is distributed in the hope That it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
Along With This Program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#+END_SRC
|
|
@ -0,0 +1,250 @@
|
|||
- `jabbergram <#jabbergram>`__
|
||||
- `English <#english>`__
|
||||
|
||||
- `About <#about>`__
|
||||
- `Installation <#installation>`__
|
||||
- `Configuration <#configuration>`__
|
||||
- `Usage <#usage>`__
|
||||
- `License <#license>`__
|
||||
|
||||
- `Castellano <#castellano>`__
|
||||
|
||||
- `Acerca de <#acerca-de>`__
|
||||
- `Instalación <#instalación>`__
|
||||
- `Configuración <#configuración>`__
|
||||
- `Uso <#uso>`__
|
||||
- `Licencia <#licencia>`__
|
||||
|
||||
jabbergram
|
||||
==========
|
||||
|
||||
English
|
||||
-------
|
||||
|
||||
About
|
||||
~~~~~
|
||||
|
||||
With this program, it's possible to use a MuC ``XMPP`` room to talk to a
|
||||
group on ``Telegram`` and vice versa. The aim of this program is to be
|
||||
just a simple gateway, just pass text from one way to the other. Once
|
||||
it's stable, it probably won't have more improvements, since I don't
|
||||
need them.
|
||||
|
||||
Installation
|
||||
~~~~~~~~~~~~
|
||||
|
||||
As with any program that uses python, it should be used a virtual
|
||||
environment (virtualenv), but that is user selectable. It's possible to
|
||||
use one of the next installation methods:
|
||||
|
||||
Install via pip:
|
||||
|
||||
::
|
||||
|
||||
$ su -c "pip3 install jabbergram"
|
||||
|
||||
Clone the repository:
|
||||
|
||||
::
|
||||
|
||||
$ git clone git://daemons.cf/jabbergram
|
||||
$ cd jabbergram
|
||||
$ su -c "pip3 install -r requirements.txt"
|
||||
$ su -c "python3 setup.py install"
|
||||
|
||||
Configuration
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
This program is simple, it even doesn't have a ``help`` menu. First
|
||||
thing you need to do is to create ``Telegram`` Bot. To do so, you must
|
||||
have a telegram account and talk to
|
||||
`BotFather <https://telegram.me/botfather>`__. Then, execute:
|
||||
|
||||
::
|
||||
|
||||
/start
|
||||
/newbot
|
||||
YourNameBot # ended in bot, always
|
||||
# then it will show your bot token, save it
|
||||
/setprivacy
|
||||
YourNameBot
|
||||
# now press Disable
|
||||
|
||||
The ``/setprivacy`` option is to make the bot read all what it's said to
|
||||
him, not only when using commands. It's necessary to make ``jabbergram``
|
||||
work. More info on creating ``Telegram`` bots at their
|
||||
`webpage <https://core.telegram.org/bots>`__.
|
||||
|
||||
Then, you will have to create a config file. We'll call it
|
||||
``config.ini``. In that file, enter the next parameters:
|
||||
|
||||
::
|
||||
|
||||
[config]
|
||||
jid = exampleJid@nope.org
|
||||
password = difficultPassword
|
||||
muc_room = exampleMuc@muc.nope.org
|
||||
nick = jabbergram
|
||||
token = jabbergramBotTokken
|
||||
group = -10293943920
|
||||
|
||||
The only thing worth mentioning is the ``token`` section, which is said
|
||||
to you when creating the bot, and the ``group``, that is the
|
||||
``Telegram`` group ID.
|
||||
|
||||
There's no easy way to see this from telegram, so you can use the
|
||||
separate utility called ``seeIdGroups.py``. To execute it, you only need
|
||||
to set the ``token`` parameter in the config file. You will need that
|
||||
somebody invite the bot to the group. Also, people on that group must
|
||||
send some messages, so the utility can grab it's id. It may take a
|
||||
couple. When you have the group ID you want, just press Ctrl-c, copy it
|
||||
to the config file (even the minus symbol), and the configuration will
|
||||
be done.
|
||||
|
||||
Usage
|
||||
~~~~~
|
||||
|
||||
You can create all config files you want. You will only need to pass it
|
||||
as parameter, but if you don't it will try to grab ``config.ini`` by
|
||||
default, and it will fail if it doesn't exist:
|
||||
|
||||
::
|
||||
|
||||
# it's advisable to use tmux or screen to execute the next order
|
||||
$ jabbergram.py example.ini
|
||||
|
||||
License
|
||||
~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
This program is free software: you can redistribute it and / or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, Either version 3 of the License, or
|
||||
(At your option) any later version.
|
||||
|
||||
This program is distributed in the hope That it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
Along With This Program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Castellano
|
||||
----------
|
||||
|
||||
Acerca de
|
||||
~~~~~~~~~
|
||||
|
||||
Con este programa, es posible utilizar una sala ``XMPP`` para hablar con
|
||||
un grupo de ``Telegram`` y viceversa. El objetivo de este programa es el
|
||||
de ser sólo una pasarela sencilla, sólo tiene que pasar el texto de un
|
||||
lado al otro. Una vez que sea estable, probablemente no tendrá más
|
||||
mejoras, ya que yo no las necesito.
|
||||
|
||||
Instalación
|
||||
~~~~~~~~~~~
|
||||
|
||||
Como con cualquier programa escrito en ``Python``, deberia ser usado en
|
||||
un entorno virtual (virtualenv), pero eso queda a la elección del
|
||||
usuario. Es posible utilizar uno de los siguientes métodos de
|
||||
instalación:
|
||||
|
||||
Instalar a través de ``pip``:
|
||||
|
||||
::
|
||||
|
||||
$ su -c "pip3 instalar jabbergram"
|
||||
|
||||
Clonar el repositorio:
|
||||
|
||||
::
|
||||
|
||||
$ git clone git: //daemons.cf/jabbergram
|
||||
$ cd jabbergram
|
||||
$ su -c "pip3 instalar requirements.txt -r"
|
||||
$ su -c "python3 setup.py instalar"
|
||||
|
||||
Configuración
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Este programa es simple, no tiene ni un menú de ``ayuda``. Lo primero
|
||||
que hay que hacer es crear el bot de ``Telegrama``. Para ello, hay que
|
||||
tener una cuenta de ``Telegram`` y hablar con
|
||||
`BotFather <https://telegram.me/botfather>`__. A continuación, ejecuta:
|
||||
|
||||
::
|
||||
|
||||
/comienzo
|
||||
/newbot
|
||||
NombreDelBot # terminado en bot, siempre
|
||||
# A continuación, se mostrará el token del bot, hay que guardarlo
|
||||
/setprivacy
|
||||
NombreDelBot
|
||||
# Ahora hay que pulsar desactivar
|
||||
|
||||
La opción ``/setprivacy`` es para hacer que el robot pueda leer todo lo
|
||||
que se dice en el grupo, no sólo cuando se utilizan los comandos. Es
|
||||
necesario para hacer que ``jabbergram`` funcione. Más información sobre
|
||||
la creación los bots de ``Telegrama`` en su `página
|
||||
web <https://core.telegram.org/bots>`__.
|
||||
|
||||
A continuación, hay que crear un archivo de configuración, que
|
||||
llamaremos ``config.ini``. En ese archivo, introduce los siguientes
|
||||
parámetros:
|
||||
|
||||
::
|
||||
|
||||
[Config]
|
||||
JID = exampleJid@nope.org
|
||||
password = difficultPassword
|
||||
muc_room = exampleMuc@muc.nope.org
|
||||
nick = jabbergram
|
||||
token = jabbergramBotTokken
|
||||
group = -10,293,943,920
|
||||
|
||||
La única cosa que vale la pena mencionar es la sección del ``token``
|
||||
(que es la que nos da cuando se crea el robot) y el ``group``, que es ID
|
||||
del grupo de ``Telegram``.
|
||||
|
||||
No hay manera fácil de ver el ID desde ``Telegram``, por lo que se puede
|
||||
utilizar el programa llamado ``seeIdGroups.py``. Para ejecutarlo sólo es
|
||||
necesario establecer el parámetro ``token`` del archivo de
|
||||
configuración. Necesitarás que alguien invite al bot al grupo. Además,
|
||||
las personas de ese grupo deben enviar algunos mensajes, para que el
|
||||
programa pueda coger su ID. Puede llevar unos segundos el que aparezcan
|
||||
los mensajes. Cuando se tenga el ID de grupo que se quiere, sólo hay que
|
||||
pulsar Ctrl-c, copiarlo en el archivo de configuración (incluido el
|
||||
simbolo menos), y la configuración estará terminada.
|
||||
|
||||
Uso
|
||||
~~~
|
||||
|
||||
Se pueden crear todos los archivos de configuración que se deseen. Sólo
|
||||
tendrás que pasarlo como parámetro al programa, si no se hace se
|
||||
intentará coger el archivo ``config.ini`` por defecto, y se producirá un
|
||||
error si no existe:
|
||||
|
||||
::
|
||||
|
||||
# Es recomendable utilizar tmux o la pantalla para ejecutar la siguiente orden
|
||||
$ Jabbergram.py example.ini
|
||||
|
||||
Licencia
|
||||
~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
This program is free software: you can redistribute it and / or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, Either version 3 of the License, or
|
||||
(At your option) any later version.
|
||||
|
||||
This program is distributed in the hope That it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
Along With This Program. If not, see <http://www.gnu.org/licenses/>.
|
|
@ -0,0 +1,111 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sleekxmpp
|
||||
import telegram
|
||||
import logging
|
||||
import configparser
|
||||
from threading import Thread
|
||||
from queue import Queue
|
||||
from telegram.error import NetworkError, Unauthorized
|
||||
from time import sleep
|
||||
from sys import argv
|
||||
|
||||
|
||||
class EchoBot(sleekxmpp.ClientXMPP):
|
||||
def __init__(self, jid, password, room, nick, token, group):
|
||||
# XMPP
|
||||
super(EchoBot, self).__init__(jid, password)
|
||||
self.add_event_handler('session_start', self.start)
|
||||
self.add_event_handler('groupchat_message', self.muc_message)
|
||||
self.muc_room = room
|
||||
self.nick = nick
|
||||
self.token = token
|
||||
|
||||
# Telegram
|
||||
self.group = group
|
||||
self.bot = telegram.Bot(self.token)
|
||||
|
||||
# meter el conecto del tg en un hilo
|
||||
t = Thread(target=self.read_tg)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
# activar logueo basico
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
level=logging.INFO)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def read_tg(self):
|
||||
update_id = 0
|
||||
|
||||
while True:
|
||||
try:
|
||||
for update in self.bot.getUpdates(offset=update_id,
|
||||
timeout=10):
|
||||
update_id = update.update_id + 1
|
||||
message = update.message.text
|
||||
user = str(update.message.from_user.username)
|
||||
if not user:
|
||||
user = str(update.message.from_user.first_name)
|
||||
if not user:
|
||||
user = "Unidentified: "
|
||||
mensaje = user + ": " + message
|
||||
chat_id = update.message.chat_id
|
||||
|
||||
if message and chat_id == self.group:
|
||||
self.send_message(mto=self.muc_room,
|
||||
mbody=mensaje,
|
||||
mtype='groupchat')
|
||||
except NetworkError:
|
||||
sleep(1)
|
||||
except Unauthorized:
|
||||
update_id += 1
|
||||
|
||||
def start(self, event):
|
||||
self.get_roster()
|
||||
self.send_presence()
|
||||
self.plugin['xep_0045'].joinMUC(self.muc_room, self.nick, wait=True)
|
||||
|
||||
def muc_message(self, msg):
|
||||
print(msg)
|
||||
if msg['mucnick'] != self.nick:
|
||||
mensaje = str(msg['from']).split('/')[1] + ': ' + str(msg['body'])
|
||||
print(mensaje)
|
||||
self.bot.sendMessage(self.group, text=mensaje)
|
||||
print("fuera")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# parsear config
|
||||
config = []
|
||||
parser = configparser.SafeConfigParser()
|
||||
|
||||
if len(argv) == 2:
|
||||
parser.read(argv[1])
|
||||
else:
|
||||
parser.read('config.ini')
|
||||
|
||||
for name, value in parser.items('config'):
|
||||
config.append(value)
|
||||
|
||||
# asignar valores para el bot
|
||||
jid = config[0]
|
||||
password = config[1]
|
||||
muc_room = config[2]
|
||||
nick = config[3]
|
||||
token = config[4]
|
||||
group = int(config[5])
|
||||
|
||||
xmpp = EchoBot(jid, password, muc_room, nick, token, group)
|
||||
xmpp.register_plugin('xep_0045')
|
||||
|
||||
if xmpp.connect():
|
||||
xmpp.process(block=True)
|
||||
print("Done")
|
||||
else:
|
||||
print("Unable to connect.")
|
||||
|
||||
# Vols un gram nen?
|
|
@ -0,0 +1,2 @@
|
|||
sleekxmpp >= 1.3.1
|
||||
python-telegram-bot >= 4.0.3
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import telegram
|
||||
import configparser
|
||||
from telegram.error import NetworkError, Unauthorized
|
||||
from time import sleep
|
||||
from sys import argv
|
||||
|
||||
|
||||
config = []
|
||||
parser = configparser.SafeConfigParser()
|
||||
|
||||
if len(argv) == 2:
|
||||
parser.read(argv[1])
|
||||
else:
|
||||
parser.read('config.ini')
|
||||
|
||||
for name, value in parser.items('config'):
|
||||
config.append(value)
|
||||
|
||||
bot = telegram.Bot(config[4])
|
||||
|
||||
update_id = 0
|
||||
print('It can take a while to print the ID, please wait.')
|
||||
print("Press Ctrl-c when the ID you want is printed.")
|
||||
|
||||
printed = []
|
||||
|
||||
while True:
|
||||
try:
|
||||
for update in bot.getUpdates(offset=update_id, timeout=10):
|
||||
chat_id = update.message.chat_id
|
||||
chat_title = update.message
|
||||
if chat_id not in printed:
|
||||
printed.append(chat_id)
|
||||
print("Title: " + str(chat_title['chat']['title']))
|
||||
print("ID: " + str(chat_id))
|
||||
except NetworkError:
|
||||
sleep(1)
|
||||
except Unauthorized:
|
||||
update_id += 1
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
VERSION = '0.1'
|
||||
|
||||
setup(name='jabbergram',
|
||||
version=VERSION,
|
||||
description='XMPP/Jabber - Telegram Gateway.',
|
||||
long_description=open('README.rst', encoding='utf-8').read(),
|
||||
author='drymer',
|
||||
author_email='drymer@autistici.org',
|
||||
url='http://daemons.cf/cgit/jabbergram/about/',
|
||||
download_url='http://daemons.cf/cgit/jabbergram/snapshot/jabbergram-' + VERSION + '.tar.gz',
|
||||
scripts=['jabbergram.py'],
|
||||
license="GPLv3",
|
||||
install_requires=[
|
||||
"sleekxmpp>=1.3.1",
|
||||
"python-telegram-bot>=4.0.3",
|
||||
],
|
||||
classifiers=["Development Status :: 4 - Beta",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.4",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Operating System :: OS Independent",
|
||||
"Operating System :: POSIX",
|
||||
"Intended Audience :: End Users/Desktop"]
|
||||
)
|
Loading…
Reference in New Issue