This commit is contained in:
Thomas L 2018-03-28 23:40:26 +02:00
parent 5db529702c
commit 88afab1270
2 changed files with 0 additions and 106 deletions

View file

@ -1,2 +0,0 @@
63c8d9ad74e688ad1160c7b91a69d2bc91bf56ecb9dee13377a5cdf9320ad332
7b4f452ef07ba0f045bea0420eac034a539236fa5bf994a6718b9bed06993722

View file

@ -1,104 +0,0 @@
diff --git a/active_bots/mailbot.py b/active_bots/mailbot.py
index a98872a..a11231f 100644
--- a/active_bots/mailbot.py
+++ b/active_bots/mailbot.py
@@ -20,14 +20,13 @@ class Mailbot(object):
other bots that it received mails.
"""

- def __init__(self, uid, db):
+ def __init__(self, uid):
"""
Creates a Bot who listens to mails and forwards them to other
bots.

- :param config: (dictionary) config.toml as a dictionary of dictionaries
"""
- self.user = User(db, uid)
+ self.user = User(uid)

try:
self.last_mail = self.user.get_seen_mail()
@@ -115,7 +114,7 @@ class Mailbot(object):

:param status: (report.Report object)
"""
- mailer = sendmail.Mailer(config)
+ mailer = sendmail.Mailer()
mailer.send(status.format(), self.mailinglist,
"Warnung: Kontrolleure gesehen")

diff --git a/active_bots/twitterbot.py b/active_bots/twitterbot.py
index 787cdfb..065da45 100755
--- a/active_bots/twitterbot.py
+++ b/active_bots/twitterbot.py
@@ -24,16 +24,13 @@ class TwitterBot(object):
last_mention: the ID of the last tweet which mentioned you
"""

- def __init__(self, uid, db):
+ def __init__(self, uid):
"""
Initializes the bot and loads all the necessary data.

- :param config: (dictionary) config.toml as a dictionary of dictionaries
- :param history_path: Path to the file with ID of the last retweeted
Tweet
"""
- self.db = db
- self.user = User(db, uid)
+ self.user = User(uid)

# initialize API access
keys = self.get_api_keys()
diff --git a/sendmail.py b/sendmail.py
index df91d1d..93028d9 100755
--- a/sendmail.py
+++ b/sendmail.py
@@ -2,6 +2,7 @@

import smtplib
import ssl
+from config import config
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
@@ -12,13 +13,12 @@ class Mailer(object):
Maintains the connection to the mailserver and sends text to users.
"""

- def __init__(self, config):
+ def __init__(self):
"""
Creates an SMTP client to send a mail. Is called only once
when you actually want to send a mail. After you sent the
mail, the SMTP client is shut down again.

- :param config: The config file generated from config.toml
"""
# This generates the From address by stripping the part until the first
# period from the mail server address and won't work always.
@@ -65,9 +65,5 @@ class Mailer(object):

# For testing:
if __name__ == '__main__':
- import prepare
-
- config = prepare.get_config()
-
- m = Mailer(config)
+ m = Mailer()
print(m.send("This is a test mail.", m.fromaddr, "Test"))
diff --git a/user.py b/user.py
index c4e99e4..ce95cd3 100644
--- a/user.py
+++ b/user.py
@@ -53,7 +53,7 @@ class User(object):
return jwt.encode({
'email': email,
'uid': self.uid
- }, self.secret).decode('ascii')
+ }, db.secret).decode('ascii')

def is_appropriate(self, report):
db.execute("SELECT pattern FROM triggerpatterns WHERE user_id=?;",