
14 changed files with 105 additions and 286 deletions
@ -0,0 +1,91 @@
|
||||
# -*- coding: utf-8 -*- |
||||
# |
||||
# This file is part of GetTor, a Tor Browser distribution system. |
||||
# |
||||
# :authors: isra <hiro@torproject.org> |
||||
# see also AUTHORS file |
||||
# |
||||
# :copyright: (c) 2008-2014, The Tor Project, Inc. |
||||
# (c) 2019, Hiro |
||||
# |
||||
# :license: This is Free Software. See LICENSE for license information. |
||||
|
||||
from __future__ import absolute_import |
||||
|
||||
import gettext |
||||
import hashlib |
||||
|
||||
import configparser |
||||
|
||||
from twisted.internet import defer |
||||
|
||||
from ...utils.db import SQLite3 as DB |
||||
from ...utils.commons import log |
||||
from ...utils import strings |
||||
|
||||
class Twitterdm(object): |
||||
""" |
||||
Class for sending twitter replies to `help` and `links` requests. |
||||
""" |
||||
def __init__(self, settings): |
||||
""" |
||||
Constructor. It opens and stores a connection to the database. |
||||
:dbname: reads from configs |
||||
""" |
||||
self.settings = settings |
||||
dbname = self.settings.get("dbname") |
||||
consumer_key = self.settings.get("consumer_key") |
||||
consumer_secret = self.settings.get("consumer_secret") |
||||
access_key = self.settings.get("access_key") |
||||
access_secret = self.settings.get("access_secret") |
||||
twitter_handle = self.settings.get("twitter_handle") |
||||
|
||||
self.conn = DB(dbname) |
||||
|
||||
def get_interval(self): |
||||
""" |
||||
Get time interval for service periodicity. |
||||
|
||||
:return: time interval (float) in seconds. |
||||
""" |
||||
return self.settings.get("twitter_interval") |
||||
|
||||
|
||||
def twitter_callback(self, message): |
||||
""" |
||||
Callback invoked after a message has been sent. |
||||
|
||||
:param message (string): Success details from the server. |
||||
""" |
||||
log.info("Message sent successfully.") |
||||
|
||||
def twitter_errback(self, error): |
||||
""" |
||||
Errback if we don't/can't send the message. |
||||
""" |
||||
log.debug("Could not send message.") |
||||
raise Error("{}".format(error)) |
||||
|
||||
|
||||
def twitter_msg_list(self): |
||||
|
||||
|
||||
|
||||
def twitterdm(self): |
||||
""" |
||||
Send a twitter message for each message received. It creates a plain |
||||
text message, and sends it via twitter APIs |
||||
|
||||
:param twitter_handle (str): email address of the recipient. |
||||
:param text (str): subject of the message. |
||||
|
||||
:return: deferred whose callback/errback will handle the API execution |
||||
details. |
||||
""" |
||||
|
||||
log.debug("Retrieve list of messages") |
||||
|
||||
log.debug("Creating message") |
||||
|
||||
|
||||
log.debug("Calling twitter APIs.") |
Binary file not shown.
@ -1,57 +0,0 @@
|
||||
domain "en" |
||||
|
||||
#: Links subject |
||||
msgid "links_subject" |
||||
msgstr "[GetTor] Links for your request" |
||||
|
||||
#: Mirrors subject |
||||
msgid "mirrors_subject" |
||||
msgstr "[GetTor] Mirrors" |
||||
|
||||
#: Help subject |
||||
msgid "help_subject" |
||||
msgstr "[GetTor] Help" |
||||
|
||||
# Unsupported locale subject |
||||
msgid "unsupported_locale_subject" |
||||
msgstr "[GetTor] Unsupported locale" |
||||
|
||||
# Unsupported locale message |
||||
msgid "unsupported_locale_msg" |
||||
msgstr "The locale you requested '%s' is not supported." |
||||
|
||||
#: Links message |
||||
msgid "links_msg" |
||||
msgstr "You requested Tor Browser for %s.\n\ |
||||
\n\ |
||||
You will need only one of the links below to download the bundle. If a link\n\ |
||||
does not work for you, try the next one.\n\ |
||||
\n\ |
||||
%s\n\ |
||||
\n\ |
||||
\n\ |
||||
--\n\ |
||||
GetTor" |
||||
|
||||
#: Mirrors message |
||||
msgid "mirrors_msg" |
||||
msgstr "Hi! this is the GetTor robot.\n\ |
||||
\n\ |
||||
Thank you for your request. Attached to this email you will find\n\ |
||||
an updated list of mirrors of Tor Project's website." |
||||
|
||||
#: Help message |
||||
msgid "help_msg" |
||||
msgstr "Hi! This is the GetTor robot. I am here to help you download the\n\ |
||||
latest version of Tor Browser.\n\ |
||||
\n\ |
||||
Please reply to this message with one of the options below:\n\ |
||||
\n\ |
||||
windows\n\ |
||||
linux\n\ |
||||
osx\n\ |
||||
mirrors\n\ |
||||
\n\ |
||||
I will then send you the download instructions.\n\ |
||||
\n\ |
||||
If you are unsure, just send a blank reply to this message." |
Binary file not shown.
@ -1,94 +0,0 @@
|
||||
domain "es" |
||||
|
||||
#: Links subject |
||||
msgid "links_subject" |
||||
msgstr "[GetTor] Enlaces para tu petición" |
||||
|
||||
#: Links subject (PT) |
||||
msgid "links_pt_subject" |
||||
msgstr "[GetTor] Enlaces para tu petición" |
||||
|
||||
#: Help subject |
||||
msgid "help_subject" |
||||
msgstr "[GetTor] Ayuda" |
||||
|
||||
#: Delay subject |
||||
msgid "delay_subject" |
||||
msgstr "[GetTor] Mensaje de demora" |
||||
|
||||
# Unsupported locale subject |
||||
msgid "unsupported_locale_subject" |
||||
msgstr "[GetTor] Locale no soportado" |
||||
|
||||
# Unsupported locale message |
||||
msgid "unsupported_locale_msg" |
||||
msgstr "El locale especificado %s no está soportado." |
||||
|
||||
#: Links message |
||||
msgid "links_msg" |
||||
msgstr """Gracias por tu petición para %s-%s.\n\ |
||||
\n\ |
||||
Aquí están los links de descarga:\n\ |
||||
\n\ |
||||
===\n\ |
||||
%s\n\ |
||||
===\n\ |
||||
\n\ |
||||
===\n\ |
||||
Soporte:\n\ |
||||
===\n\ |
||||
\n\ |
||||
¿Aún necesitas ayuda? Si tienes dudas, problemas para conectarte a la\n\ |
||||
red Tor, o necesitas hablar con un humano, por favor contacta a nuestro\n\ |
||||
equipo de soporte a:\n\ |
||||
\n\ |
||||
help@rt.torproject.org\n\ |
||||
\n\ |
||||
Estamos listos para responder tus consultas en Inglés, Farsi, Chino,\n\ |
||||
Arábico, Francés y Español.""" |
||||
|
||||
#: Links message (PT) |
||||
msgid "links_pt_msg" |
||||
msgstr """Gracias por tu petición para %s-%s.\n\ |
||||
\n\ |
||||
Aquí están los links de descarga:\n\ |
||||
\n\ |
||||
===\n\ |
||||
%s\n\ |
||||
===\n\ |
||||
Tip: Información sobre pluggable transports.\n\ |
||||
\n\ |
||||
===\n\ |
||||
Soporte:\n\ |
||||
===\n\ |
||||
\n\ |
||||
¿Aún necesitas ayuda? Si tienes dudas, problemas para conectarte a la\n\ |
||||
red Tor, o necesitas hablar con un humano, por favor contacta a nuestro\n\ |
||||
equipo de soporte a:\n\ |
||||
\n\ |
||||
help@rt.torproject.org\n\ |
||||
\n\ |
||||
Estamos listos para responder tus consultas en Inglés, Farsi, Chino,\n\ |
||||
Arábico, Francés y Español.""" |
||||
|
||||
#: Help message |
||||
msgid "help_msg" |
||||
msgstr "Hola, este es el robot 'GetTor'.\n\ |
||||
\n\ |
||||
Gracias por tu petición. Estoy aquí para ayudarte a descargar la última\n\ |
||||
versión del Tor Browser Bundle.\n\ |
||||
\n\ |
||||
Por favor responde a este mensaje con una de las siguientes opciones:\n\ |
||||
\n\ |
||||
windows\n\ |
||||
linux\n\ |
||||
osx\n\ |
||||
\n\ |
||||
Y te enviaré las instrucciones de descarga.\n\ |
||||
\n\ |
||||
Tip: Sólo envía una respuesta en blanco a este mensaje si no estás\n\ |
||||
seguro." |
||||
|
||||
#: Delay message |
||||
msgid "delay_msg" |
||||
msgstr "Mensaje de demora." |
@ -1,55 +0,0 @@
|
||||
domain "en" |
||||
|
||||
#: Links |
||||
msgid "links" |
||||
msgstr "You requested Tor Browser for %s.\n\ |
||||
\n\ |
||||
You will need only one of the links below to download the bundle. If a link\n\ |
||||
does not work for you, try the next one.\n\ |
||||
\n\ |
||||
%s" |
||||
|
||||
#: Mirrors message |
||||
msgid "mirrors" |
||||
msgstr "Hi! this is the GetTor robot.\n\ |
||||
\n\ |
||||
Thank you for your request. Below you will find an updated list of\n\ |
||||
mirrors of Tor Project's website.\n\ |
||||
\n\ |
||||
%s" |
||||
|
||||
#: Help |
||||
msgid "help" |
||||
msgstr "Hi! This is the GetTor robot. I am here to help you download the\n\ |
||||
latest version of Tor Browser.\n\ |
||||
\n\ |
||||
Please reply to this message with one of the options below:\n\ |
||||
\n\ |
||||
windows\n\ |
||||
linux\n\ |
||||
osx\n\ |
||||
mirrors\n\ |
||||
\n\ |
||||
I will then send you the download instructions." |
||||
|
||||
#: Mirrors unavailable message |
||||
msgid "mirrors_unavailable" |
||||
msgstr "Hello there! this is the 'GetTor' robot.\n\ |
||||
\n\ |
||||
I'm sorry, I can't send you mirrors right now, please try again later.\n\ |
||||
\n\ |
||||
Still need help? If you have any questions, trouble connecting to Tor\n\ |
||||
network, or need to talk to a human, please contact our support team at:\n\ |
||||
\n\ |
||||
help@rt.torproject.org\n\ |
||||
\n\ |
||||
We are ready to answer your queries in English, Farsi, Chinese, Arabic,\n\ |
||||
French and Spanish." |
||||
|
||||
#: Internal error |
||||
msgid "internal_error" |
||||
msgstr "Internal error" |
||||
|
||||
#: Internal error |
||||
msgid "message_error" |
||||
msgstr "Message too long." |
Binary file not shown.
@ -1,55 +0,0 @@
|
||||
domain "en" |
||||
|
||||
#: Links |
||||
msgid "links" |
||||
msgstr "You requested Tor Browser for %s.\n\ |
||||
\n\ |
||||
You will need only one of the links below to download the bundle. If a link\n\ |
||||
does not work for you, try the next one.\n\ |
||||
\n\ |
||||
%s" |
||||
|
||||
#: Mirrors message |
||||
msgid "mirrors" |
||||
msgstr "Hi! this is the GetTor robot.\n\ |
||||
\n\ |
||||
Thank you for your request. Below you will find an updated list of\n\ |
||||
mirrors of Tor Project's website.\n\ |
||||
\n\ |
||||
%s" |
||||
|
||||
#: Help |
||||
msgid "help" |
||||
msgstr "Hi! This is the GetTor robot. I am here to help you download the\n\ |
||||
latest version of Tor Browser.\n\ |
||||
\n\ |
||||
Please reply to this message with one of the options below:\n\ |
||||
\n\ |
||||
windows\n\ |
||||
linux\n\ |
||||
osx\n\ |
||||
mirrors\n\ |
||||
\n\ |
||||
I will then send you the download instructions." |
||||
|
||||
#: Mirrors unavailable message |
||||
msgid "mirrors_unavailable" |
||||
msgstr "Hello there! this is the 'GetTor' robot.\n\ |
||||
\n\ |
||||
I'm sorry, I can't send you mirrors right now, please try again later.\n\ |
||||
\n\ |
||||
Still need help? If you have any questions, trouble connecting to Tor\n\ |
||||
network, or need to talk to a human, please contact our support team at:\n\ |
||||
\n\ |
||||
help@rt.torproject.org\n\ |
||||
\n\ |
||||
We are ready to answer your queries in English, Farsi, Chinese, Arabic,\n\ |
||||
French and Spanish." |
||||
|
||||
#: Internal error |
||||
msgid "internal_error" |
||||
msgstr "Internal error" |
||||
|
||||
#: Internal error |
||||
msgid "message_error" |
||||
msgstr "Message too long." |
Binary file not shown.
Binary file not shown.
@ -1,22 +0,0 @@
|
||||
domain "es" |
||||
|
||||
#: Links |
||||
msgid "links" |
||||
msgstr "Enlaces para %s-%s:\n %s" |
||||
|
||||
#: Links |
||||
msgid "links_pt" |
||||
msgstr "Enlaces-PT para %s-%s:\n %s" |
||||
|
||||
#: Help |
||||
msgid "help" |
||||
msgstr "ayuda" |
||||
|
||||
#: Unsupported locale |
||||
msgid "unsupported_lc" |
||||
msgstr "Locale no soportado" |
||||
|
||||
#: Internal error |
||||
msgid "internal_error" |
||||
msgstr "Error interno" |
||||
|
Loading…
Reference in new issue