Compare commits

...

3 commits
v1.6 ... master

Author SHA1 Message Date
Dryusdan fa1550e26a Merge branch 'improve-randomness' of framasky/masto-image-bot into master 2019-09-12 12:05:48 +02:00
Luc Didry e5e4938479
Improve local images randomness by using random.SystemRandom()
My bot @gracyimp@botsin.space gave me the same image twice this morning,
within a few seconds, so I asked myself how to improve the randomness.
Indeed, this allowed my bot to publish some images that never were
published!
2019-09-04 09:24:26 +02:00
Dryusdan 67849b7f9f Remove quote for unsplash_client_id 2019-06-22 10:49:11 +02:00
2 changed files with 3 additions and 2 deletions

3
bot.py
View file

@ -32,7 +32,8 @@ def post_img_local(mastodon, text, log, config):
continu = True;
while continu:
file = random.choice(os.listdir(img_path+"/"))
secure_random = random.SystemRandom()
file = secure_random.choice(os.listdir(img_path+"/"))
if os.path.isdir(img_path+file):
img_path = img_path+file+"/"
else:

View file

@ -10,4 +10,4 @@ spoiler_text: some text here
limit: 2
limit_hour: 10
collection_url: https://source.unsplash.com/collection/<collection>/
unsplash_client_id: "03ad5bfbaa0acd6c96a728d425e533683ec25e5fb7fcf99f6461720b3d0d75a1"
unsplash_client_id: 03ad5bfbaa0acd6c96a728d425e533683ec25e5fb7fcf99f6461720b3d0d75a1