Compare commits
No commits in common. "b5b9a898c48822e6794d9aac4372e046040f29a0" and "adfaaf8a24eae9cea907e79ff5394d29f19868a5" have entirely different histories.
b5b9a898c4
...
adfaaf8a24
|
@ -12,5 +12,3 @@ __pycache__/
|
||||||
.*.swp
|
.*.swp
|
||||||
config.json
|
config.json
|
||||||
venv/
|
venv/
|
||||||
*.log
|
|
||||||
filter.txt
|
|
|
@ -1,3 +0,0 @@
|
||||||
@reboot $HOME/amber-ebooks/reply.py >> $HOME/reply.log 2>>$HOME/reply.log #keep the reply process running in the background
|
|
||||||
*/20 * * * * $HOME/amber-ebooks/gen.py >> $HOME/gen.log 2>>$HOME/gen.log #post every twenty minutes
|
|
||||||
*/15 * * * * $HOME/amber-ebooks/main.py >> $HOME/main.log 2>>$HOME/main.log #refresh the database every 15 minutes
|
|
|
@ -1,5 +0,0 @@
|
||||||
put
|
|
||||||
bad
|
|
||||||
words
|
|
||||||
in
|
|
||||||
filter.txt
|
|
11
functions.py
11
functions.py
|
@ -56,15 +56,6 @@ def make_sentence(output, cfg):
|
||||||
elif cfg['mention_handling'] == 0:
|
elif cfg['mention_handling'] == 0:
|
||||||
sentence = re.sub(r"\S*@\u200B\S*\s?", "", sentence)
|
sentence = re.sub(r"\S*@\u200B\S*\s?", "", sentence)
|
||||||
|
|
||||||
# optionally remove filtered words
|
|
||||||
if cfg['word_filter'] == 1:
|
|
||||||
try:
|
|
||||||
fp = open('./filter.txt')
|
|
||||||
for word in fp:
|
|
||||||
if word in sentence:
|
|
||||||
sentence = sentence.replace(word, "[REDACTED]")
|
|
||||||
finally:
|
|
||||||
fp.close()
|
|
||||||
output.send(sentence)
|
output.send(sentence)
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +64,7 @@ def make_toot(cfg):
|
||||||
pin, pout = multiprocessing.Pipe(False)
|
pin, pout = multiprocessing.Pipe(False)
|
||||||
p = multiprocessing.Process(target=make_sentence, args=[pout, cfg])
|
p = multiprocessing.Process(target=make_sentence, args=[pout, cfg])
|
||||||
p.start()
|
p.start()
|
||||||
p.join(5) # wait 5 seconds to get something
|
p.join(300) # wait 5 seconds to get something
|
||||||
if p.is_alive(): # if it's still trying to make a toot after 5 seconds
|
if p.is_alive(): # if it's still trying to make a toot after 5 seconds
|
||||||
p.terminate()
|
p.terminate()
|
||||||
p.join()
|
p.join()
|
||||||
|
|
3
main.py
3
main.py
|
@ -30,8 +30,7 @@ cfg = {
|
||||||
"length_lower_limit": 5,
|
"length_lower_limit": 5,
|
||||||
"length_upper_limit": 50,
|
"length_upper_limit": 50,
|
||||||
"overlap_ratio_enabled": False,
|
"overlap_ratio_enabled": False,
|
||||||
"overlap_ratio": 0.7,
|
"overlap_ratio": 0.7
|
||||||
"word_filter": 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue