Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fbchat import Client
- from fbchat.models import *
- import time
- import json
- import random
- from textgenrnn import textgenrnn
- with open("secret.json") as file:
- parsed = json.loads(file.read())
- username = parsed['username']
- password = parsed['password']
- text = parsed['text']
- def login():
- client = Client(username, password)
- return client
- # Fetches a list of all users you're currently chatting with, as `User` objects
- client = login()
- users = client.fetchAllUsers()
- print(f"users' IDs: {[user.uid for user in users]}")
- print(f"users' names: {[user.name for user in users]}")
- print(f"ready to send mass message {text}")
- for user in users[100:]:
- with open("sent.json","r") as file:
- parsed = json.loads(file.read())
- try:
- while True:
- if user.uid not in parsed:
- client = login()
- print("generating gibber...")
- textgen = textgenrnn()
- textgen.generate_to_file("ai.txt")
- with open("ai.txt") as aifile:
- gibber = aifile.read()
- print(f"generated: {gibber}")
- print(f"sending message to {user.name}")
- client.send(Message(text=text + gibber), thread_id=user.uid, thread_type=ThreadType.USER)
- with open("sent.json", "w") as file:
- parsed[user.uid]=user.name
- file.write(json.dumps(parsed))
- delay = random.randint(60, 120)
- print(f"sleeping for {delay} seconds...")
- time.sleep(delay)
- else:
- print(f"skipping {user.uid}, {user.name}, message already sent")
- break
- except Exception as e:
- print(e)
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement