Compare commits
No commits in common. "cb30496d6263c554dfb59f387331ec439c69bf30" and "7f41872c5a67b06417ea2ceb5abdd94b13b11537" have entirely different histories.
cb30496d62
...
7f41872c5a
5 changed files with 9 additions and 15 deletions
15
run.py
15
run.py
|
@ -17,10 +17,10 @@ dc = db.cursor(dictionary=True)
|
||||||
|
|
||||||
dc.execute("SELECT * FROM data")
|
dc.execute("SELECT * FROM data")
|
||||||
for row in dc.fetchall():
|
for row in dc.fetchall():
|
||||||
print(row['cc'])
|
print(row)
|
||||||
t = int(time.time())
|
t = int(time.time())
|
||||||
next_check = row['last_check'] + row['time_between_checks'] * 60
|
next_check = row['last_check'] + row['time_between_checks'] * 60
|
||||||
if next_check <= t:
|
if next_check > t:
|
||||||
row['time_between_checks'] = cfg['min_time_between_checks']
|
row['time_between_checks'] = cfg['min_time_between_checks']
|
||||||
#time to check
|
#time to check
|
||||||
if row['cc'] != "None" and row['cc'] != None:
|
if row['cc'] != "None" and row['cc'] != None:
|
||||||
|
@ -35,12 +35,5 @@ for row in dc.fetchall():
|
||||||
else:
|
else:
|
||||||
sender = post['senderData']['username']
|
sender = post['senderData']['username']
|
||||||
|
|
||||||
toot = "Curious cat question from {}: \"{}\"<br />My answer: {}\nView online at https://curiouscat.me/{}/post/{}".format(sender, post['comment'], post['reply'], row['cc'], post['id']) #TODO: what if this is over 500 characters?
|
toot = "Curious cat question from {}: \"{}\"<br />My answer: {}\nView online at https://curiouscat.me/{}/post/{}".format(sender, post['comment'], post['reply'], row['cc'], post['id'])
|
||||||
c.execute("UPDATE data SET last_check = %s, time_between_checks = %s, latest_post = %s", (t, cfg['min_time_between_checks'], j['posts'][0]['timestamp']))
|
|
||||||
else:
|
|
||||||
#we checked, and they haven't made a post
|
|
||||||
tbc = int(row['time_between_checks']) + 1
|
|
||||||
if tbc > int(cfg['max_time_between_checks']):
|
|
||||||
tbc = cfg['max_time_between_checks']
|
|
||||||
c.execute("UPDATE data SET last_check = %s, time_between_checks = %s", (t, tbc))
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 198 B |
BIN
static/logo.png
BIN
static/logo.png
Binary file not shown.
Before Width: | Height: | Size: 17 KiB |
9
web.py
9
web.py
|
@ -23,6 +23,7 @@ settings = {
|
||||||
db = mysql.connector.connect(user=cfg['dbuser'], password=cfg['dbpass'], database=cfg['dbname'])
|
db = mysql.connector.connect(user=cfg['dbuser'], password=cfg['dbpass'], database=cfg['dbname'])
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
dc = db.cursor(dictionary=True)
|
dc = db.cursor(dictionary=True)
|
||||||
|
# MariaDB [curiousgreg]> DESCRIBE data;
|
||||||
# +---------------------+---------------+------+-----+------------------------------------------------+-------+
|
# +---------------------+---------------+------+-----+------------------------------------------------+-------+
|
||||||
# | Field | Type | Null | Key | Default | Extra |
|
# | Field | Type | Null | Key | Default | Extra |
|
||||||
# +---------------------+---------------+------+-----+------------------------------------------------+-------+
|
# +---------------------+---------------+------+-----+------------------------------------------------+-------+
|
||||||
|
@ -36,11 +37,11 @@ dc = db.cursor(dictionary=True)
|
||||||
# | cc | tinytext | YES | | NULL | |
|
# | cc | tinytext | YES | | NULL | |
|
||||||
# | ccavi | varchar(128) | YES | | https://lynnesbian.space/res/ceres/cc-smol.png | |
|
# | ccavi | varchar(128) | YES | | https://lynnesbian.space/res/ceres/cc-smol.png | |
|
||||||
# | latest_post | tinytext | YES | | NULL | |
|
# | latest_post | tinytext | YES | | NULL | |
|
||||||
# | last_check | int(11) | NO | | 0 | |
|
# | last_check | tinytext | YES | | NULL | |
|
||||||
# | time_between_checks | int(11) | NO | | 1 | |
|
# | time_between_checks | int(11) | YES | | NULL | |
|
||||||
# | settings | varchar(4096) | YES | | {"cw": false} | |
|
# | settings | varchar(4096) | YES | | {"cw": false} | |
|
||||||
# +---------------------+---------------+------+-----+------------------------------------------------+-------+
|
# +---------------------+---------------+------+-----+------------------------------------------------+-------+
|
||||||
c.execute("CREATE TABLE IF NOT EXISTS `data` (username VARCHAR(64) NOT NULL, instance VARCHAR(128) NOT NULL, password TINYTEXT NOT NULL, avi TEXT NOT NULL, secret TINYTEXT NOT NULL, client_id VARCHAR(128) NOT NULL, client_secret TINYTEXT NOT NULL, cc TINYTEXT, ccavi VARCHAR(128) DEFAULT 'https://lynnesbian.space/res/ceres/cc-smol.png', latest_post TINYTEXT, last_check INT DEFAULT 0 NOT NULL, time_between_checks INT DEFAULT %s NOT NULL, settings VARCHAR(4096) DEFAULT %s, PRIMARY KEY(username, instance))", (cfg['min_time_between_checks'], json.dumps(settings),))
|
c.execute("CREATE TABLE IF NOT EXISTS `data` (username VARCHAR(64) NOT NULL, instance VARCHAR(128) NOT NULL, password TINYTEXT NOT NULL, avi TEXT NOT NULL, secret TINYTEXT NOT NULL, client_id VARCHAR(128) NOT NULL, client_secret TINYTEXT NOT NULL, cc TINYTEXT, ccavi VARCHAR(128) DEFAULT 'https://lynnesbian.space/res/ceres/cc-smol.png', latest_post TINYTEXT, last_check TINYTEXT, time_between_checks INT, settings VARCHAR(4096) DEFAULT %s, PRIMARY KEY(username, instance))", (json.dumps(settings),))
|
||||||
|
|
||||||
app = Flask(cfg['name'])
|
app = Flask(cfg['name'])
|
||||||
app.secret_key = cfg['flask_key']
|
app.secret_key = cfg['flask_key']
|
||||||
|
@ -236,7 +237,7 @@ def ccc_c():
|
||||||
return redirect('/cc_connect/code?invalid')
|
return redirect('/cc_connect/code?invalid')
|
||||||
for item in ['cc', 'ccavi']:
|
for item in ['cc', 'ccavi']:
|
||||||
session[item] = session['cctemp'][item]
|
session[item] = session['cctemp'][item]
|
||||||
c.execute("UPDATE data SET cc = %s, ccavi = %s, latest_post = %s, WHERE username = %s AND instance = %s", (session['cc'], session['ccavi'], session['cctemp']['latest_post'], session['username'], session['instance']))
|
c.execute("UPDATE data SET cc = %s, ccavi = %s, latest_post = %s, time_between_checks = %s, last_check = %s WHERE username = %s AND instance = %s", (session['cc'], session['ccavi'], session['cctemp']['latest_post'], 1, 0, session['username'], session['instance']))
|
||||||
db.commit()
|
db.commit()
|
||||||
del session['cctemp']
|
del session['cctemp']
|
||||||
return redirect('/cc_connect/complete')
|
return redirect('/cc_connect/complete')
|
||||||
|
|
Loading…
Reference in a new issue