-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.py
More file actions
32 lines (24 loc) · 990 Bytes
/
chat.py
File metadata and controls
32 lines (24 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from fbchat import Client
from fbchat.models import *
import logging
from datetime import datetime
talking_to = ['Ioana Stoian', 'Costa Anton', 'Andrei Stamate', 'Oana Blair', 'Dan Moss']
last = None
class CustomClient(Client):
def onMessage(self, mid, author_id, message_object, thread_id, thread_type, ts, metadata, msg, **kwargs):
global last
if author_id != self.uid:
for u in talking_to:
user = client.searchForUsers(u)
user = user[0]
if user.uid == author_id:
if last != user.first_name:
print("\n{} {}:".format(user.first_name, user.last_name))
last = user.first_name
break
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ": " + message_object.text)
user = input('Username:')
passw = input('Pass:')
client = CustomClient(user, passw, logging_level=logging.ERROR)
client.listen()
client.logout()