Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Cecylia Bocovich
gettor
Commits
1ca12690
Commit
1ca12690
authored
Oct 09, 2019
by
Hiro
🏄
Browse files
Start twitter responder
parent
e4278339
Changes
14
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
1ca12690
...
...
@@ -7,3 +7,4 @@ _trial_temp
gettor.pid
csv
.config
gettor.conf.json
gettor.conf.json
View file @
1ca12690
...
...
@@ -6,5 +6,10 @@
"sendmail_interval"
:
10
,
"sendmail_addr"
:
"gettor@torproject.org"
,
"sendmail_host"
:
"localhost"
,
"sendmail_port"
:
587
"sendmail_port"
:
587
,
"consumer_key"
:
""
,
"consumer_secret"
:
""
,
"access_key"
:
""
,
"access_secret"
:
""
,
"twitter_handle"
:
"get_tor"
}
gettor/services/twitter/twitterdm.py
0 → 100644
View file @
1ca12690
# -*- 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."
)
gettor/utils/settings.py
View file @
1ca12690
...
...
@@ -53,7 +53,7 @@ class Settings(object):
if
os
.
path
.
exists
(
self
.
filename
):
try
:
with
open
(
self
.
filename
,
'r'
)
as
f
:
self
.
_settings
=
json
.
load
(
f
)
self
.
_settings
=
json
.
load
(
f
)
except
:
pass
else
:
...
...
@@ -65,7 +65,12 @@ class Settings(object):
"sendmail_interval"
:
10
,
"sendmail_addr"
:
"gettor@torproject.org"
,
"sendmail_host"
:
"localhost"
,
"sendmail_port"
:
587
"sendmail_port"
:
587
,
"consumer_key"
:
""
,
"consumer_secret"
:
""
,
"access_key"
:
""
,
"access_secret"
:
""
,
"twitter_handle"
:
"get_tor"
}
def
get
(
self
,
key
):
...
...
share/locale/smtp/i18n/en/LC_MESSAGES/en.mo
deleted
100644 → 0
View file @
e4278339
File deleted
share/locale/smtp/i18n/en/LC_MESSAGES/en.po
deleted
100644 → 0
View file @
e4278339
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."
share/locale/smtp/i18n/es/LC_MESSAGES/es.mo
deleted
100644 → 0
View file @
e4278339
File deleted
share/locale/smtp/i18n/es/LC_MESSAGES/es.po
deleted
100644 → 0
View file @
e4278339
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."
share/locale/twitter/i18n/en/LC_MESSAGES/en.po
deleted
100644 → 0
View file @
e4278339
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."
share/locale/xmpp/i18n/en/LC_MESSAGES/en.mo
deleted
100644 → 0
View file @
e4278339
File deleted
share/locale/xmpp/i18n/en/LC_MESSAGES/en.po
deleted
100644 → 0
View file @
e4278339
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."
share/locale/xmpp/i18n/en/LC_MESSAGES/es.mo
deleted
100644 → 0
View file @
e4278339
File deleted
share/locale/xmpp/i18n/es/LC_MESSAGES/es.mo
deleted
100644 → 0
View file @
e4278339
File deleted
share/locale/xmpp/i18n/es/LC_MESSAGES/es.po
deleted
100644 → 0
View file @
e4278339
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"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment