1
0
Fork 0
mirror of https://github.com/Lynnesbian/FediBooks/ synced 2024-11-25 08:38:59 +00:00

fixed a silly but rather bad bug\ni'm pretty sure i'm gonna stop working on fedibooks, and everything else i do relating to fedi. writing complex webapps to (rather poorly) interface with decentralised, half-standardised social networking platforms really isn't for me, and much of this code is honestly pretty awful. i have no idea why i did some of this stuff - for example, writing an object to interface with the outbox json would have been a LOT cleaner than what i'm currently doing. fedibooks really doesn't work well at all, and its biggest flaw is, of course, the fact that it can't interact with any instances using authenticated fetch. while i may fix minor bugs from time to time, i can pretty much guarantee that one's never getting fixed. i'm not shutting down fedibooks.com or anything like that - and if i ever do, i'll give advance warning - but don't expect any new features here, or in mstdn-ebooks, OCRbot, et al. but hey, at least it's fixed now.

This commit is contained in:
Lynne Megido 2020-05-27 19:39:15 +10:00
parent d9d7f751c6
commit 33b72d8e4c
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90

View file

@ -88,7 +88,7 @@ def generate_output(handle):
posts = "\n".join(list(sum(c.fetchall(), ()))) posts = "\n".join(list(sum(c.fetchall(), ())))
if len(posts) == 0: if len(posts) == 0:
print("{} - No posts to learn from.".format(handle)) print("{} - No posts to learn from.".format(handle))
return return bot, None
if bot['fake_mentions'] == 'never': if bot['fake_mentions'] == 'never':
# remove all mentions from the training data before the markov model sees it # remove all mentions from the training data before the markov model sees it
@ -99,8 +99,8 @@ def generate_output(handle):
post = None post = None
# even with such a high tries value for markovify, it still sometimes returns none. # even with such a high tries value for markovify, it still sometimes returns none.
# so we implement our own tries function as well, and try ten times. # so we implement our own tries function as well, and try five times.
while post is None and tries < 10: while post is None and tries < 5:
post = model.make_short_sentence(bot['length'], tries = 1000) post = model.make_short_sentence(bot['length'], tries = 1000)
tries += 1 tries += 1
@ -138,6 +138,10 @@ def make_post(args):
bot, post = generate_output(handle) bot, post = generate_output(handle)
# post will be None if there's no posts for the bot to learn from.
# in such a case, we should just exit without doing anything.
if post == None: return
client = Mastodon( client = Mastodon(
client_id = bot['client_id'], client_id = bot['client_id'],
client_secret = bot['client_secret'], client_secret = bot['client_secret'],