luckydonald / pytg

Python package that wraps around Telegram messenger CLI. Send and receive messages, and more.
MIT License
369 stars 76 forks source link

'DictObject' object has no attribute 'text' #30

Open painhardcore opened 9 years ago

painhardcore commented 9 years ago

Crush becouse of image recieved. Python3. Traceback (most recent call last): File "/home/administrator/tgbot/tgbotenv/lib/python3.4/site-packages/DictObject-0.1.1-py3.4.egg/DictObject/init.py", line 434, in getattr AttributeError: 'DictObject' object has no attribute 'text'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/administrator/tgbot/tgbotenv/lib/python3.4/site-packages/DictObject-0.1.1-py3.4.egg/DictObject/init.py", line 441, in getattr KeyError: 'text'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tgbotmain.py", line 54, in main() # executing main function # Last command of file (so everything needed is already loaded above) File "tgbotmain.py", line 16, in main receiver.message(example_function(sender)) # now it will call the example_function and yield the new messages. File "/home/administrator/tgbot/tgbotenv/lib/python3.4/site-packages/pytg-0.4.1b0-py3.4.egg/pytg/utils.py", line 29, in start File "/home/administrator/tgbot/tgbotenv/lib/python3.4/site-packages/pytg-0.4.1b0-py3.4.egg/pytg/receiver.py", line 217, in message File "tgbotmain.py", line 36, in example_function if msg.text is not str: # we have media instead. File "/home/administrator/tgbot/tgbotenv/lib/python3.4/site-packages/DictObject-0.1.1-py3.4.egg/DictObject/init.py", line 455, in getattr AttributeError: text Terminating currently sending request.

luckydonald commented 9 years ago

You can check existence with

if "text" in msg:
luckydonald commented 9 years ago

I will introduce real objects for messages and events soon, so you can assume existence. The Message object's text attribute then might be None, but will exist. The progress can be watched in the development branch.

luckydonald commented 9 years ago

This is happening in the developing branch.