added telegram to frontend
This commit is contained in:
parent
83d8700e30
commit
0719b094f8
9
db.py
9
db.py
|
@ -90,6 +90,13 @@ class DB(object):
|
||||||
active INTEGER,
|
active INTEGER,
|
||||||
FOREIGN KEY(user_id) REFERENCES user(id)
|
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 (
|
CREATE TABLE IF NOT EXISTS seen_tweets (
|
||||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||||
user_id INTEGER,
|
user_id INTEGER,
|
||||||
|
@ -173,6 +180,8 @@ u\d\d?
|
||||||
uid = json['uid']
|
uid = json['uid']
|
||||||
self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);",
|
self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);",
|
||||||
(uid, json['email']))
|
(uid, json['email']))
|
||||||
|
self.execute("""INSERT INTO telegram_accounts (user_id, apikey,
|
||||||
|
active) VALUES(?, ?, ?);""", (uid, "", 1))
|
||||||
self.commit()
|
self.commit()
|
||||||
user = User(uid)
|
user = User(uid)
|
||||||
user.set_city(city)
|
user.set_city(city)
|
||||||
|
|
|
@ -114,6 +114,14 @@ def update_badwords(user):
|
||||||
return user.state()
|
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')
|
@get('/api/state')
|
||||||
def api_enable(user):
|
def api_enable(user):
|
||||||
return user.state()
|
return user.state()
|
||||||
|
|
|
@ -67,6 +67,21 @@
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<div style="float: left; padding: 1.5em;">
|
||||||
|
<h2>Connect with Telegram</h2>
|
||||||
|
<p>
|
||||||
|
If you have a Telegram account, you can register a bot there. Just write to @botfather. You can find detailed
|
||||||
|
instructions <a href="https://botsfortelegram.com/project/the-bot-father/" target="_blank">on Bots for
|
||||||
|
Telegram</a>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The botfather will give you an API key - with the API key, Ticketfrei can use the Telegram bot. Enter it here:
|
||||||
|
</p>
|
||||||
|
<form action="/settings/telegram" method="post">
|
||||||
|
<input type="text" name="apikey" placeholder="Telegram bot API key" id="apikey" required>
|
||||||
|
<input name='confirm' value='Login with Telegram' type='submit'/>
|
||||||
|
</div
|
||||||
|
|
||||||
<div style="float: left; padding: 1.5em;">
|
<div style="float: left; padding: 1.5em;">
|
||||||
<h2>Edit your city page</h2>
|
<h2>Edit your city page</h2>
|
||||||
<p>
|
<p>
|
||||||
|
|
4
user.py
4
user.py
|
@ -205,6 +205,10 @@ schlitz
|
||||||
(self.uid, ))
|
(self.uid, ))
|
||||||
return db.cur.fetchall()
|
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):
|
def get_mastodon_app_keys(self, instance):
|
||||||
db.execute("SELECT client_id, client_secret FROM mastodon_instances WHERE instance = ?;", (instance, ))
|
db.execute("SELECT client_id, client_secret FROM mastodon_instances WHERE instance = ?;", (instance, ))
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue