diff --git a/.gitignore b/.gitignore
index a6b7bc1..c20e862 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,4 @@ include/
lib/
share/
local/
+venv/
diff --git a/README.md b/README.md
index 2bdc8d7..83c23e2 100644
--- a/README.md
+++ b/README.md
@@ -118,9 +118,12 @@ echo "Enter your domain name into the following prompt:" && read DOMAIN
# configure nginx
sudo sed -r "s/example.org/$DOMAIN/g" deployment/example.org.conf > /etc/nginx/sites-enabled/$DOMAIN.conf
-# create folder for socket
+# create folder for socket & database
sudo mkdir /var/ticketfrei
sudo chown www-data:www-data -R /var/ticketfrei
+
+# create folder for logs
+sudo mkdir /var/log/ticketfrei
sudo chown www-data:www-data -R /var/log/ticketfrei
# start up nginx
@@ -149,3 +152,51 @@ less /var/log/syslog
# for the nginx web server:
less /var/log/nginx/example.org_error.log
```
+
+### Development Install
+
+If you want to install it locally to develop on it:
+
+```shell
+sudo apt install python3 virtualenv uwsgi uwsgi-plugin-python3 nginx git
+sudo git clone https://github.com/b3yond/ticketfrei
+cd ticketfrei
+git checkout multi-deployment
+```
+
+Install the necessary packages, create and activate virtualenv:
+
+```shell
+virtualenv -p python3 .
+. bin/activate
+```
+
+Install the dependencies:
+
+```shell
+pip install tweepy pytoml Mastodon.py bottle pyjwt pylibscrypt Markdown
+```
+
+Configure the bot:
+
+```shell
+cp config.toml.example config.toml
+vim config.toml
+```
+
+This configuration is only for the admin. Users can log into
+twitter/mastodon/mail and configure their personal bot on the settings page.
+
+```shell
+# create folder for socket & database
+sudo mkdir /var/ticketfrei
+sudo chown $USER:$USER -R /var/ticketfrei
+
+# create folder for logs
+sudo mkdir /var/log/ticketfrei
+sudo chown $USER:$USER -R /var/log/ticketfrei
+
+# start Ticketfrei
+./frontend.py & ./backend.py &
+```
+
diff --git a/db.py b/db.py
index 942cbf5..f96927e 100644
--- a/db.py
+++ b/db.py
@@ -90,6 +90,13 @@ class DB(object):
active INTEGER,
FOREIGN KEY(user_id) REFERENCES user(id)
);
+ CREATE TABLE IF NOT EXISTS telegram_accounts (
+ id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
+ user_id INTEGER,
+ apikey TEXT,
+ active INTEGER,
+ FOREIGN KEY(user_id) REFERENCES user(id)
+ );
CREATE TABLE IF NOT EXISTS seen_tweets (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
user_id INTEGER,
@@ -173,6 +180,8 @@ u\d\d?
uid = json['uid']
self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);",
(uid, json['email']))
+ self.execute("""INSERT INTO telegram_accounts (user_id, apikey,
+ active) VALUES(?, ?, ?);""", (uid, "", 1))
self.commit()
user = User(uid)
user.set_city(city)
diff --git a/frontend.py b/frontend.py
index a3ae423..969bea6 100755
--- a/frontend.py
+++ b/frontend.py
@@ -114,6 +114,14 @@ def update_badwords(user):
return user.state()
+@post('/settings/telegram')
+@view('template/settings.tpl')
+def register_telegram(user):
+ apikey = request.forms['apikey']
+ user.set_telegram_key(apikey)
+ return user.state()
+
+
@get('/api/state')
def api_enable(user):
return user.state()
diff --git a/static/css/style.css b/static/css/style.css
index 54590a4..3dc8126 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -41,3 +41,7 @@ input[type=text], input[type=password] {
display: inline-block;
border: 1px solid #ccc;
}
+
+h2 {
+ padding-top: 1em;
+}
diff --git a/template/settings.tpl b/template/settings.tpl
index cd7e524..b177f79 100644
--- a/template/settings.tpl
+++ b/template/settings.tpl
@@ -16,7 +16,7 @@
Log in with Twitter
-
Log in with Mastodon
+ If you have a Telegram account, you can register a bot there. Just write to @botfather. You can find detailed + instructions on Bots for + Telegram. +
++ The botfather will give you an API key - with the API key, Ticketfrei can use the Telegram bot. Enter it here: +
+These words have to be contained in a report. @@ -95,7 +110,7 @@
These words are not allowed in reports. diff --git a/user.py b/user.py index 83ea724..9823c78 100644 --- a/user.py +++ b/user.py @@ -205,6 +205,10 @@ schlitz (self.uid, )) return db.cur.fetchall() + def set_telegram_key(self, apikey): + db.execute("UPDATE telegram_accounts SET apikey = ? WHERE user_id = ?;", (apikey, self.uid)) + db.commit() + def get_mastodon_app_keys(self, instance): db.execute("SELECT client_id, client_secret FROM mastodon_instances WHERE instance = ?;", (instance, )) try: