carderne / signal-export

Export your Signal chats to markdown files with attachments
Other
446 stars 47 forks source link

Local variable 'sender' referenced before assignment #18

Closed crypt0jan closed 3 years ago

crypt0jan commented 3 years ago

OS: MacOS BigSur 11.4 Python: Python 3.8.8

$ ./sigexport.py --overwrite --chats "MY TEST GROUP" ~/Temp/signal-export/

Fetching data from /Users/user/Library/Application Support/Signal/sql/db.sqlite

Copying and renaming attachments

Creating markdown files
Traceback (most recent call last):
  File "./sigexport.py", line 597, in <module>
    main()
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "./sigexport.py", line 585, in main
    make_simple(dest, convos, contacts)
  File "./sigexport.py", line 161, in make_simple
    print(f"[{date}] {sender}: {body}", file=mdfile)
UnboundLocalError: local variable 'sender' referenced before assignment

Any idea why I get this error? Assigning the sender at the beginning of the script does not help unfortunately.

crypt0jan commented 3 years ago

Fixed! I've added sender = False on line 88. Please include this bugfix. Example:

def make_simple(dest, conversations, contacts):
    """Output each conversation into a simple text file."""

    dest = Path(dest)
    sender = False
    for key, messages in conversations.items():
carderne commented 3 years ago

Hi @crypt0jan I've made a slightly different fix here: 3726ccfc14b662fb86f4c7e6408c5cdcec5eadf2.

Should have the same effect.