Update examples

Only `import fbchat`, and update to initialize Client using Session
This commit is contained in:
Mads Marquart
2020-01-08 10:45:41 +01:00
parent 06b7e14c31
commit 78949e8ad5
6 changed files with 66 additions and 43 deletions

View File

@@ -1,7 +1,7 @@
from fbchat import Client
import fbchat
# Subclass fbchat.Client and override required methods
class EchoBot(Client):
class EchoBot(fbchat.Client):
def on_message(self, author_id, message_object, thread_id, thread_type, **kwargs):
self.mark_as_delivered(thread_id, message_object.uid)
self.mark_as_read(thread_id)
@@ -13,5 +13,7 @@ class EchoBot(Client):
self.send(message_object, thread_id=thread_id, thread_type=thread_type)
client = EchoBot("<email>", "<password>")
client.listen()
session = fbchat.Session.login("<email>", "<password>")
echo_bot = EchoBot(session)
echo_bot.listen()