fbchat icon indicating copy to clipboard operation
fbchat copied to clipboard

Client() not working

Open LMarto opened this issue 4 years ago • 1 comments

Description of the problem

Client not working properly. It shows that I'm logging in facebook from some browser on my phone (I set it up so that it shows me messages when I'm logging in from somewhere) but it crashes in the command prompt.

Traceback

Traceback (most recent call last): File "sitakscool.py", line 9, in client = Client(username, getpass(), max_tries = 1) File "C:*\Local\Programs\Python\Python38\lib\site-packages\fbchat_client.py", line 103, in init self.login(email, password, max_tries, user_agent=user_agent) File "C:*\Local\Programs\Python\Python38\lib\site-packages\fbchat_client.py", line 205, in login self._state = State.login( File "C:*\Local\Programs\Python\Python38\lib\site-packages\fbchat_state.py", line 149, in login return cls.from_session(session=session) File "C:*\Local\Programs\Python\Python38\lib\site-packages\fbchat_state.py", line 186, in from_session fb_dtsg = FB_DTSG_REGEX.search(r.text).group(1) AttributeError: 'NoneType' object has no attribute 'group'

Environment information

  • Python 3.8.3
  • fbchat 1.9.7

No code after client = Client(..) works.

Code

import os
from fbchat import Client
from fbchat.models import *
from getpass import getpass
from time import sleep


username = "MAIL" 
client = Client(username, getpass(), max_tries = 1)

if client.isLoggedIn():
    name = "GROUP NAME"
    friends = client.searchForGroups(name) 
    friend = friends[0]
    thread_type = ThreadType.GROUP 

    if os.path.exists('fromrtou.txt'): 
        with open('fromrtou.txt', 'r', encoding='utf-8') as data:
            for each_line in data:
                if each_line == '\n':
                    msg = ("######")
                else:
                    msg = (each_line)
                client.send(Message(text = msg), thread_id=friend.uid, thread_type=thread_type)
                sleep(2)
    else:
        print("Sellist faili ei eksisteeri!")

    client.logout()
else:
    print("Midagi laks perse ja ei saanudki sisse logida!")

LMarto avatar Jul 28 '20 17:07 LMarto

Did you try removing the line: client.logout()

xaadu avatar Aug 28 '20 10:08 xaadu