Fixed examples, added changeNickname and changeThreadEmoji, changed changeGroupTitle back to changeThreadTitle

I also removed the parameter `set_default_events` from __init__, since
it's not really necessary
Also added testing of examples and simple testing of listen functions
This commit is contained in:
Mads Marquart
2017-05-26 18:48:37 +02:00
parent d2741ca419
commit 39eafa5a3e
6 changed files with 173 additions and 87 deletions

View File

@@ -4,13 +4,13 @@ from fbchat import log, Client
from fbchat.models import *
class RemoveBot(Client):
def onMessage(self, mid, author_id, message, thread_id, thread_type, ts, metadata, msg):
def onMessage(self, author_id, message, thread_id, thread_type, **kwargs):
# We can only kick people from group chats, so no need to try if it's a user chat
if message == 'Remove me!' and thread_type == ThreadType.GROUP:
log.info("{} will be removed from {}".format(author_id, thread_id)))
self.removeUserFromGroup(user_id, thread_id=thread_id)
log.info("{} will be removed from {}".format(author_id, thread_id))
self.removeUserFromGroup(author_id, thread_id=thread_id)
else:
log.info("Message from {} in {} ({}): {}".format(author_id, thread_id, thread_type.name, message)))
log.info("Message from {} in {} ({}): {}".format(author_id, thread_id, thread_type.name, message))
client = RemoveBot("<email>", "<password>")
client.listen()
client.listen()