Advertisement
l1von

sdsds

Dec 11th, 2020
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. if 0 < text_length <= 50 and message.from_id > 0:
  2. with open(chat_path, "a", encoding="utf8") as f:
  3. f.write(message.text + "\n")
  4.  
  5. with open(picture_path, encoding="utf8") as f:
  6. pic_count = len(f.readlines())
  7. with open(chat_path, encoding="utf8") as f:
  8. text_lines = len(f.readlines())
  9.  
  10. if text_lines >= 20 and pic_count >= 1 and random.randint(0, 15) == 3:
  11. print(message.from_id)
  12. print("ГЕНЕРИРУЕМ РАНДОМНО")
  13. with open(chat_path, encoding="utf8") as file:
  14. texts = file.read().splitlines()
  15. random_text = random.choice(texts)
  16. random_bottom_text = random.choice(texts) + " " + random.choice(texts)
  17. with open(picture_path, encoding="utf8") as file:
  18. pictures = file.read().splitlines()
  19. random_picture = random.choice(pictures)
  20. response = requests.get(random_picture)
  21. with open("randomimg.jpg", "wb") as f:
  22. f.write(response.content)
  23.  
  24. random_text_len = len(random_text)
  25. if random_text_len <= 50:
  26. dem = demcreate(random_text, random_bottom_text)
  27. dem.makeImage("randomimg")
  28. add_watermark()
  29. photo = await photo_uploader.upload_message_photo("demresult.jpg")
  30. await message(attachment=photo)
  31. return
  32. else:
  33. random_bottom_text_short = random_text[:50]
  34. dem = demcreate(random_text, random_bottom_text_short)
  35. dem.makeImage("randomimg")
  36. add_watermark()
  37. photo = await photo_uploader.upload_message_photo("demresult.jpg")
  38. await message(attachment=photo)
  39. return
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement