Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. from fbchat import Client
  2. from fbchat.models import *
  3. import time
  4. import json
  5. import random
  6. from textgenrnn import textgenrnn
  7.  
  8. with open("secret.json") as file:
  9. parsed = json.loads(file.read())
  10.  
  11. username = parsed['username']
  12. password = parsed['password']
  13. text = parsed['text']
  14.  
  15. def login():
  16. client = Client(username, password)
  17. return client
  18.  
  19. # Fetches a list of all users you're currently chatting with, as `User` objects
  20. client = login()
  21. users = client.fetchAllUsers()
  22.  
  23. print(f"users' IDs: {[user.uid for user in users]}")
  24. print(f"users' names: {[user.name for user in users]}")
  25. print(f"ready to send mass message {text}")
  26.  
  27. for user in users[100:]:
  28. with open("sent.json","r") as file:
  29. parsed = json.loads(file.read())
  30.  
  31.  
  32. try:
  33. while True:
  34. if user.uid not in parsed:
  35.  
  36. client = login()
  37.  
  38. print("generating gibber...")
  39. textgen = textgenrnn()
  40. textgen.generate_to_file("ai.txt")
  41. with open("ai.txt") as aifile:
  42. gibber = aifile.read()
  43. print(f"generated: {gibber}")
  44.  
  45. print(f"sending message to {user.name}")
  46.  
  47. client.send(Message(text=text + gibber), thread_id=user.uid, thread_type=ThreadType.USER)
  48.  
  49. with open("sent.json", "w") as file:
  50. parsed[user.uid]=user.name
  51. file.write(json.dumps(parsed))
  52.  
  53. delay = random.randint(60, 120)
  54. print(f"sleeping for {delay} seconds...")
  55. time.sleep(delay)
  56.  
  57. else:
  58. print(f"skipping {user.uid}, {user.name}, message already sent")
  59.  
  60. break
  61.  
  62. except Exception as e:
  63. print(e)
  64. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement