diff --git a/README.md b/README.md
index 7b4603d..2bdc8d7 100644
--- a/README.md
+++ b/README.md
@@ -91,7 +91,7 @@ virtualenv -p python3 .
Install the dependencies:
```shell
-pip install tweepy pytoml Mastodon.py bottle pyjwt pylibscrypt
+pip install tweepy pytoml Mastodon.py bottle pyjwt pylibscrypt Markdown
```
Configure the bot:
diff --git a/db.py b/db.py
index ac4999d..0259a85 100644
--- a/db.py
+++ b/db.py
@@ -42,13 +42,13 @@ class DB(object):
CREATE TABLE IF NOT EXISTS triggerpatterns (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
user_id INTEGER,
- pattern TEXT,
+ patterns TEXT,
FOREIGN KEY(user_id) REFERENCES user(id)
);
CREATE TABLE IF NOT EXISTS badwords (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
user_id INTEGER,
- word TEXT,
+ words TEXT,
FOREIGN KEY(user_id) REFERENCES user(id)
);
CREATE TABLE IF NOT EXISTS mastodon_instances (
@@ -146,10 +146,29 @@ class DB(object):
self.execute("INSERT INTO user (passhash) VALUES(?);",
(json['passhash'], ))
uid = self.cur.lastrowid
- self.execute("""
- INSERT INTO triggerpatterns (user_id, pattern)
- VALUES(?, ?);
- """, (uid, '.*'))
+ default_triggerpatterns = """
+kontroll?e
+konti
+db
+vgn
+vag
+zivil
+sicherheit
+uniform
+station
+bus
+bahn
+tram
+linie
+nuernberg
+nürnberg
+s\d
+u\d\d?
+ """
+ self.execute("""INSERT INTO triggerpatterns (user_id, patterns)
+ VALUES(?, ?); """, (uid, default_triggerpatterns))
+ self.execute("INSERT INTO badwords (user_id, words) VALUES(?, ?);",
+ (uid, ""))
else:
uid = json['uid']
self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);",
diff --git a/frontend.py b/frontend.py
index 43ca54d..07aff7f 100755
--- a/frontend.py
+++ b/frontend.py
@@ -38,7 +38,7 @@ def register_post():
return dict(error='Email address already in use.')
# send confirmation mail
try:
- # print(url('confirm/' + city + '/%s' % db.user_token(email, password))) # only for local testing
+ print(url('confirm/' + city + '/%s' % db.user_token(email, password))) # only for local testing
sendmail(
email,
"Confirm your account",
@@ -93,6 +93,20 @@ def settings(user):
return user.state()
+@post('/settings/goodlist')
+@view('template/settings.tpl')
+def update_trigger_patterns(user):
+ user.set_trigger_words(request.forms['goodlist'])
+ return user.state()
+
+
+@post('/settings/blacklist')
+@view('template/settings.tpl')
+def update_badwords(user):
+ user.set_badwords(request.forms['blacklist'])
+ return user.state()
+
+
@get('/api/state')
def api_enable(user):
return user.state()
diff --git a/template/city.tpl b/template/city.tpl
index d102660..dddac8d 100644
--- a/template/city.tpl
+++ b/template/city.tpl
@@ -1,4 +1,9 @@
% rebase('template/wrapper.tpl')
-$markdown.render()
+<%
+import markdown as md
+html = md.markdown(markdown)
+%>
+
+{{html}}
diff --git a/template/settings.tpl b/template/settings.tpl
index 32ab147..ea9c35d 100644
--- a/template/settings.tpl
+++ b/template/settings.tpl
@@ -1,7 +1,11 @@
% rebase('template/wrapper.tpl')
-
asdf
+% if enabled:
+ Disable
+% else:
+ Enable
+% end