# by default, only select posts that don't have CWs.
# if learn_from_cw, then also select posts with CWs
cw_list=[False]
ifbot[0]:
cw_list=[False,True]
# select 1000 random posts for the bot to learn from
c.execute("SELECT content FROM posts WHERE fedi_id IN (SELECT fedi_id FROM bot_learned_accounts WHERE bot_id = %s) AND cw IN %s ORDER BY RAND() LIMIT 1000",(handle,cw_list))
# this line is a little gross/optimised but here's what it does
# 1. fetch all of the results from the above query
# 2. turn (('this',), ('format')) into ('this', 'format')
# 3. convert the tuple to a list
# 4. join the list into a string separated by newlines
posts="\n".join(list(sum(c.fetchall(),())))
model=nlt_fixed(posts)
tries=0
sentence=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.