Beispiel #1
0
def kick(client, author_id, message_object, thread_id, thread_type):
    gc_thread = Client.fetchThreadInfo(client, thread_id)[thread_id]
    person_to_kick = message_object.text.split(' ')[1:]
    for person in Client.fetchAllUsersFromThreads(self=client,
                                                  threads=[gc_thread]):
        names = [person.first_name, person.last_name, person.nickname]
        if any([name in person_to_kick for name in names]):
            log.info("{} removed {} from {}").format(author_id, person_to_kick,
                                                     thread_id)
            Client.removeUserFromGroup(user_id=person.uid, thread_id=thread_id)
            return
    log.info("Unable to remove: person not found.")
Beispiel #2
0
# Will send the image located at `<image path>`
client.sendLocalImage('<image path>',
                      message=Message(text='This is a local image'),
                      thread_id=thread_id,
                      thread_type=thread_type)

# Will download the image at the url `<image url>`, and then send it
client.sendRemoteImage('<image url>',
                       message=Message(text='This is a remote image'),
                       thread_id=thread_id,
                       thread_type=thread_type)

# Only do these actions if the thread is a group
if thread_type == ThreadType.GROUP:
    # Will remove the user with ID `<user id>` from the thread
    client.removeUserFromGroup('<user id>', thread_id=thread_id)

    # Will add the user with ID `<user id>` to the thread
    client.addUsersToGroup('<user id>', thread_id=thread_id)

    # Will add the users with IDs `<1st user id>`, `<2nd user id>` and `<3th user id>` to the thread
    client.addUsersToGroup(['<1st user id>', '<2nd user id>', '<3rd user id>'],
                           thread_id=thread_id)

# Will change the nickname of the user `<user_id>` to `<new nickname>`
client.changeNickname('<new nickname>',
                      '<user id>',
                      thread_id=thread_id,
                      thread_type=thread_type)

# Will change the title of the thread to `<title>`
Beispiel #3
0
    thread_id=thread_id,
    thread_type=thread_type,
)

# Will download the image at the URL `<image url>`, and then send it
client.sendRemoteImage(
    "<image url>",
    message=Message(text="This is a remote image"),
    thread_id=thread_id,
    thread_type=thread_type,
)

# Only do these actions if the thread is a group
if thread_type == ThreadType.GROUP:
    # Will remove the user with ID `<user id>` from the thread
    client.removeUserFromGroup("<user id>", thread_id=thread_id)

    # Will add the user with ID `<user id>` to the thread
    client.addUsersToGroup("<user id>", thread_id=thread_id)

    # Will add the users with IDs `<1st user id>`, `<2nd user id>` and `<3th user id>` to the thread
    client.addUsersToGroup(["<1st user id>", "<2nd user id>", "<3rd user id>"],
                           thread_id=thread_id)

# Will change the nickname of the user `<user_id>` to `<new nickname>`
client.changeNickname("<new nickname>",
                      "<user id>",
                      thread_id=thread_id,
                      thread_type=thread_type)

# Will change the title of the thread to `<title>`
Beispiel #4
0
def RemoveMembers(fbids):
    client = Client(SECRETARY_EMAIL, SECRETARY_PASSWORD)
    for fbid in fbids:
        client.removeUserFromGroup(fbid, ROCKETRY_THREAD)