small bugfixes
This commit is contained in:
parent
1dd75c10d5
commit
ec3053a0ab
|
@ -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")
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
104
mall bugfixes
Normal file
104
mall bugfixes
Normal file
|
@ -0,0 +1,104 @@
|
|||
[1mdiff --git a/active_bots/mailbot.py b/active_bots/mailbot.py[m
|
||||
[1mindex a98872a..a11231f 100644[m
|
||||
[1m--- a/active_bots/mailbot.py[m
|
||||
[1m+++ b/active_bots/mailbot.py[m
|
||||
[36m@@ -20,14 +20,13 @@[m [mclass Mailbot(object):[m
|
||||
other bots that it received mails.[m
|
||||
"""[m
|
||||
[m
|
||||
[31m- def __init__(self, uid, db):[m
|
||||
[32m+[m[32m def __init__(self, uid):[m
|
||||
"""[m
|
||||
Creates a Bot who listens to mails and forwards them to other[m
|
||||
bots.[m
|
||||
[m
|
||||
[31m- :param config: (dictionary) config.toml as a dictionary of dictionaries[m
|
||||
"""[m
|
||||
[31m- self.user = User(db, uid)[m
|
||||
[32m+[m[32m self.user = User(uid)[m
|
||||
[m
|
||||
try:[m
|
||||
self.last_mail = self.user.get_seen_mail()[m
|
||||
[36m@@ -115,7 +114,7 @@[m [mclass Mailbot(object):[m
|
||||
[m
|
||||
:param status: (report.Report object)[m
|
||||
"""[m
|
||||
[31m- mailer = sendmail.Mailer(config)[m
|
||||
[32m+[m[32m mailer = sendmail.Mailer()[m
|
||||
mailer.send(status.format(), self.mailinglist,[m
|
||||
"Warnung: Kontrolleure gesehen")[m
|
||||
[m
|
||||
[1mdiff --git a/active_bots/twitterbot.py b/active_bots/twitterbot.py[m
|
||||
[1mindex 787cdfb..065da45 100755[m
|
||||
[1m--- a/active_bots/twitterbot.py[m
|
||||
[1m+++ b/active_bots/twitterbot.py[m
|
||||
[36m@@ -24,16 +24,13 @@[m [mclass TwitterBot(object):[m
|
||||
last_mention: the ID of the last tweet which mentioned you[m
|
||||
"""[m
|
||||
[m
|
||||
[31m- def __init__(self, uid, db):[m
|
||||
[32m+[m[32m def __init__(self, uid):[m
|
||||
"""[m
|
||||
Initializes the bot and loads all the necessary data.[m
|
||||
[m
|
||||
[31m- :param config: (dictionary) config.toml as a dictionary of dictionaries[m
|
||||
[31m- :param history_path: Path to the file with ID of the last retweeted[m
|
||||
Tweet[m
|
||||
"""[m
|
||||
[31m- self.db = db[m
|
||||
[31m- self.user = User(db, uid)[m
|
||||
[32m+[m[32m self.user = User(uid)[m
|
||||
[m
|
||||
# initialize API access[m
|
||||
keys = self.get_api_keys()[m
|
||||
[1mdiff --git a/sendmail.py b/sendmail.py[m
|
||||
[1mindex df91d1d..93028d9 100755[m
|
||||
[1m--- a/sendmail.py[m
|
||||
[1m+++ b/sendmail.py[m
|
||||
[36m@@ -2,6 +2,7 @@[m
|
||||
[m
|
||||
import smtplib[m
|
||||
import ssl[m
|
||||
[32m+[m[32mfrom config import config[m
|
||||
from email.mime.text import MIMEText[m
|
||||
from email.mime.application import MIMEApplication[m
|
||||
from email.mime.multipart import MIMEMultipart[m
|
||||
[36m@@ -12,13 +13,12 @@[m [mclass Mailer(object):[m
|
||||
Maintains the connection to the mailserver and sends text to users.[m
|
||||
"""[m
|
||||
[m
|
||||
[31m- def __init__(self, config):[m
|
||||
[32m+[m[32m def __init__(self):[m
|
||||
"""[m
|
||||
Creates an SMTP client to send a mail. Is called only once[m
|
||||
when you actually want to send a mail. After you sent the[m
|
||||
mail, the SMTP client is shut down again.[m
|
||||
[m
|
||||
[31m- :param config: The config file generated from config.toml[m
|
||||
"""[m
|
||||
# This generates the From address by stripping the part until the first[m
|
||||
# period from the mail server address and won't work always.[m
|
||||
[36m@@ -65,9 +65,5 @@[m [mclass Mailer(object):[m
|
||||
[m
|
||||
# For testing:[m
|
||||
if __name__ == '__main__':[m
|
||||
[31m- import prepare[m
|
||||
[31m-[m
|
||||
[31m- config = prepare.get_config()[m
|
||||
[31m-[m
|
||||
[31m- m = Mailer(config)[m
|
||||
[32m+[m[32m m = Mailer()[m
|
||||
print(m.send("This is a test mail.", m.fromaddr, "Test"))[m
|
||||
[1mdiff --git a/user.py b/user.py[m
|
||||
[1mindex c4e99e4..ce95cd3 100644[m
|
||||
[1m--- a/user.py[m
|
||||
[1m+++ b/user.py[m
|
||||
[36m@@ -53,7 +53,7 @@[m [mclass User(object):[m
|
||||
return jwt.encode({[m
|
||||
'email': email,[m
|
||||
'uid': self.uid[m
|
||||
[31m- }, self.secret).decode('ascii')[m
|
||||
[32m+[m[32m }, db.secret).decode('ascii')[m
|
||||
[m
|
||||
def is_appropriate(self, report):[m
|
||||
db.execute("SELECT pattern FROM triggerpatterns WHERE user_id=?;",[m
|
10
sendmail.py
10
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"))
|
||||
|
|
|
@ -20,7 +20,7 @@ class SessionPlugin(object):
|
|||
uid = request.get_cookie('uid', secret=db.secret)
|
||||
if uid is None:
|
||||
return redirect(self.loginpage)
|
||||
kwargs[self.keyword] = User(db, uid)
|
||||
kwargs[self.keyword] = User(uid)
|
||||
return callback(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
|
Loading…
Reference in a new issue