This repository has been archived on 2025-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
Files
fbchat/examples/echobot.py
2020-01-09 17:21:07 +01:00

20 lines
578 B
Python

import fbchat
# Subclass fbchat.Client and override required methods
class EchoBot(fbchat.Client):
def on_message(self, author_id, message_object, thread, **kwargs):
self.mark_as_delivered(thread.id, message_object.id)
self.mark_as_read(thread.id)
print("{} from {} in {}".format(message_object, thread))
# If you're not the author, echo
if author_id != self.session.user_id:
thread.send_text(message_object.text)
session = fbchat.Session.login("<email>", "<password>")
echo_bot = EchoBot(session)
echo_bot.listen()