nikhilkumarrathi / cryptotrader-telegram

A Telegram bot written in Python which provides various Cryptocurrency Trading features, and Technical Analysis using Binance API.
MIT License
51 stars 19 forks source link

JSONDecodeError #1

Closed linehman closed 4 years ago

linehman commented 4 years ago

I was trying to run the bot and check it out. first there was an error in config file JSON formatting ( missing comma after "adminUserId": "--userid--" ). after that the following error was displayed when running the bot :

Traceback (most recent call last): File "bot.py", line 6, in import commands as cm File "/root/cryptotrader-telegram/commands.py", line 11, in import charts File "/root/cryptotrader-telegram/charts.py", line 17, in from lib import app File "/root/cryptotrader-telegram/lib.py", line 16, in from config import configData File "/root/cryptotrader-telegram/config.py", line 11, in configData = DotMap(json.load(open('config/config.json','r'))) File "/usr/lib/python3.6/json/init.py", line 299, in load parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) File "/usr/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 14 column 5 (char 418)

any suggestion on this would be appreciated.

nikhilkumarrathi commented 4 years ago

Hi, There seemed to be some comma issues in the config file, I have corrected those and also arranged the config a bit. Please try again.

Thanks, Nikhil

linehman commented 4 years ago

Hi, thanks for the fast update. the problem is solved and the bot started successfully. But it's currently not accepting commands and displays " ERROR error returned: module 'time' has no attribute 'time_ns' ".

nikhilkumarrathi commented 4 years ago

Hi, I have been running this in Docker successfully, could be an error due to Python version. You tried in Docker?

Regards,
Nikhil

linehman commented 4 years ago

I just tried running this with docker. this time the error changed to: 2020-06-14 12:43:13 MainThread INFO submitting task: schdinfo []

2020-06-14 12:43:13 Command_0_1 ERROR HTTP Error 400: Bad Request Traceback (most recent call last): File "/app/commands.py", line 40, in wrapped app.send_msg(msg, task.message.chat.id) File "/app/lib.py", line 153, in send_msg with urllib.request.urlopen(url) as response: File "/opt/conda/lib/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/opt/conda/lib/python3.7/urllib/request.py", line 531, in open response = meth(req, response) File "/opt/conda/lib/python3.7/urllib/request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "/opt/conda/lib/python3.7/urllib/request.py", line 569, in error return self._call_chain(args) File "/opt/conda/lib/python3.7/urllib/request.py", line 503, in _call_chain result = func(args) File "/opt/conda/lib/python3.7/urllib/request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 400: Bad Request the bot is still running after this error. all the telegram bot commands display access denied message. thanks for the reply.

nikhilkumarrathi commented 4 years ago

Hi, This is happening because you didn't set the Chat ID for the telegram, which is different from the UserID. Could you please try sending some commands from Telegram and see if it works ? I will add some code to notify the user about the error.

Regards, Nikhil

nikhilkumarrathi commented 4 years ago

Please pull the new code and have a look at the readme to see how to find out adminChatId.

linehman commented 4 years ago

Hi, I pulled the new code and configured the chat id. The " ERROR HTTP Error 400: Bad Request " is gone but still displaying " access denied " error in telegram bot when sending commands. the python bot receives the command like " 2020-06-15 05:17:37 Telegram INFO submitting task: now ['now'] " but nothing else happens and the telegram bot just throws access denied.

nikhilkumarrathi commented 4 years ago

Hi, The "access denied" appears if your adminUserId is not configured with what you have been sending messages with. Please confirm that. e.g. My configuration looks like: "adminUserId": "nrathi*****"

linehman commented 4 years ago

Hi, Because "Id" was mentioned in "adminUserId" , I ended up entering my telegram id instead of username. after changing this, the access denied is fixed and the bot is working. thanks you for helping me setting up the bot.