示例#1
0
from fbchat import Client
from fbchat.models import *
email = raw_input("What is your Facebook email? : ")
password = raw_input("What is your Facebook password? : ")
client = Client(email, password)

for key in receivers:
    if not client.isLoggedIn():
        client.login(email, password)

    #Dumb people with no facebook accounts, but messenger accounts.
    #find ID by "Right Click > View Page Source" on www.facebook.com, search name
    if key == "Bob":  #123456789
        client.sendLocalFiles(
            path + "/" + key + "/" + key + ".txt",
            message=Message(text="Merry Christmas!"),
            thread_id="123456789",
            thread_type=ThreadType.USER,
        )
        continue

    #people who changed names
    if key == "Alice":
        key = "Alex"

    #pick first person after searching for another user
    #if popularly named, change key with more specific name (or hard code with Dumb People)
    users = client.searchForUsers(key)
    person = users[0]

    #unchange names
    if key == "Alex":
示例#2
0
文件: sisc.py 项目: YordanMarkov/SISC
    if not sensor.is_pressed:
        sleep(1)
        continue
    print ("Movement detected! Picture taken! Processing...")
    take_picture()
    found_figures = analyze_picture()
    matching_figures = []
    for figure in found_figures:
        if figure in FIGURES:
            matching_figures.append(figure)
    if len(matching_figures) >= 1: #0
        message = "Detected {}!".format(', '.join(matching_figures))
        print(message)
    else:
        continue
    image = "/home/pi/SISC/analyzed_{}".format(PICTURE_NAME)
    if FB_SEND:
        message = "Movement detected! Detected {}!".format(', '.join(matching_figures))
        if not fb_client:
            fb_client = Client(FB_USER, FB_PASS)
        for to_user in RECIPIENTS:
            user = fb_client.searchForUsers(to_user)
            if not user:
                continue
            if not image:
                fb_client.send(Message(text=message), thread_id=user[0].uid, thread_type=ThreadType.USER)
            else:
                fb_client.sendLocalFiles(image, message=Message(text=message), thread_id=user[0].uid, thread_type=ThreadType.USER)
    sleep(10)

示例#3
0
        #    'Rylan Jardine',
        #    'Stevie Thomas',
           'Ethan Payne',
           'Grace Jones',
           'Maddy Howell',
           'Emily Jones',
           'Maeva Berchon',
           'Hayden McMahon',
           'Daniel Guy',
           'Ashley Nobes',
           'Dongsquad']
# friends = ["Thomas Nobes"]

msg = 'Prepare for the holy transformation: lunch memes ABOUT lunch memes ending...'

users = client.fetchThreadList()
for user in users:
    if user.name in friends:
        if user.type == ThreadType.GROUP:
            sent = client.sendLocalFiles(meme_path, thread_id=user.uid, thread_type=ThreadType.GROUP)
            # sent_msg = client.send(Message(text=msg), thread_id=user.uid, thread_type=ThreadType.GROUP)
        else:
            sent = client.sendLocalFiles(meme_path, thread_id=user.uid)
            # sent_msg = client.send(Message(text=msg), thread_id=user.uid)
        pause = random.randrange(0, 5)
        time.sleep(pause)
        if sent:
            print(f'Message sent to {user.name} successfully!')

client.logout()