ebellocchia / telegram_crypto_price_bot Goto Github PK
View Code? Open in Web Editor NEWTelegram bot for displaying cryptocurrencies prices and charts
License: MIT License
Telegram bot for displaying cryptocurrencies prices and charts
License: MIT License
When I run for exemple /pricebot_get_single tamadoge usd 2
I have an error in CLI :
/Library/Python/3.9/lib/python/site-packages/telegram_crypto_price_bot/chart_info/chart_info_file_saver.py:79: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail.
fig, ax = plt.subplots()
2022-10-06 18:28:00.061 Python[6434:232584] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
0 CoreFoundation 0x00007ff8018f647b __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007ff801445e25 objc_exception_throw + 48
2 CoreFoundation 0x00007ff80191e616 _CFBundleGetValueForInfoKey + 0
3 AppKit 0x00007ff8049c1e99 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 307
4 AppKit 0x00007ff8049aee0f -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1247
5 AppKit 0x00007ff8049ae929 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
6 _macosx.cpython-39-darwin.so 0x000000010d061d3e -[Window initWithContentRect:styleMask:backing:defer:withManager:] + 62
7 _macosx.cpython-39-darwin.so 0x000000010d065400 FigureManager_init + 256
8 Python3 0x00000001080c0b9c _PyType_Lookup + 38268
9 Python3 0x0000000108065f69 PyComplex_AsCComplex + 10937
10 Python3 0x000000010805d58a _PyObject_MakeTpCall + 378
11 Python3 0x000000010814f2c2 _PyEval_EvalFrameDefault + 40930
12 Python3 0x000000010814be85 _PyEval_EvalFrameDefault + 27557
13 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
14 Python3 0x000000010805d3b4 _PyObject_FastCallDictTstate + 260
15 Python3 0x000000010805e0ab _PyObject_Call_Prepend + 139
16 Python3 0x00000001080c0ae6 _PyType_Lookup + 38086
17 Python3 0x00000001080b7dd4 _PyType_Lookup + 1972
18 Python3 0x000000010805d58a _PyObject_MakeTpCall + 378
19 Python3 0x000000010814f2c2 _PyEval_EvalFrameDefault + 40930
20 Python3 0x000000010814bf24 _PyEval_EvalFrameDefault + 27716
21 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
22 Python3 0x00000001080600fd PyMethod_New + 365
23 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
24 Python3 0x000000010814be85 _PyEval_EvalFrameDefault + 27557
25 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
26 Python3 0x00000001080600fd PyMethod_New + 365
27 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
28 Python3 0x000000010814be85 _PyEval_EvalFrameDefault + 27557
29 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
30 Python3 0x00000001080600fd PyMethod_New + 365
31 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
32 Python3 0x000000010814be85 _PyEval_EvalFrameDefault + 27557
33 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
34 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
35 Python3 0x00000001080600fd PyMethod_New + 365
36 Python3 0x000000010805d98b PyVectorcall_Call + 155
37 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
38 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
39 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
40 Python3 0x000000010805d98b PyVectorcall_Call + 155
41 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
42 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
43 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
44 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
45 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
46 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
47 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
48 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
49 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
50 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
51 Python3 0x000000010814be85 _PyEval_EvalFrameDefault + 27557
52 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
53 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
54 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
55 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
56 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
57 Python3 0x000000010814be61 _PyEval_EvalFrameDefault + 27521
58 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
59 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
60 Python3 0x000000010814be61 _PyEval_EvalFrameDefault + 27521
61 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
62 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
63 Python3 0x0000000108060232 PyMethod_New + 674
64 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
65 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
66 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
67 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
68 Python3 0x000000010814be61 _PyEval_EvalFrameDefault + 27521
69 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
70 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
71 Python3 0x000000010814be61 _PyEval_EvalFrameDefault + 27521
72 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
73 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
74 Python3 0x00000001080601a3 PyMethod_New + 531
75 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
76 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
77 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
78 Python3 0x0000000108060232 PyMethod_New + 674
79 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
80 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
81 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
82 Python3 0x0000000108060232 PyMethod_New + 674
83 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
84 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
85 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
86 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
87 Python3 0x000000010814be61 _PyEval_EvalFrameDefault + 27521
88 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
89 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
90 Python3 0x000000010814bf24 _PyEval_EvalFrameDefault + 27716
91 Python3 0x000000010815014e _PyEval_EvalFrameDefault + 44654
92 Python3 0x000000010805dcc9 _PyFunction_Vectorcall + 265
93 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
94 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
95 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
96 Python3 0x000000010814be61 _PyEval_EvalFrameDefault + 27521
97 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
98 Python3 0x000000010814c302 _PyEval_EvalFrameDefault + 28706
99 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
100 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
101 Python3 0x000000010814be61 _PyEval_EvalFrameDefault + 27521
102 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
103 Python3 0x000000010814f1ed _PyEval_EvalFrameDefault + 40717
104 Python3 0x000000010814be61 _PyEval_EvalFrameDefault + 27521
105 Python3 0x000000010805ddd3 _PyFunction_Vectorcall + 531
106 Python3 0x00000001080601a3 PyMethod_New + 531
107 Python3 0x00000001081f3177 PyInit__thread + 5799
108 Python3 0x00000001081a2299 PyThread_start_new_thread + 313
109 libsystem_pthread.dylib 0x00007ff8017a3259 _pthread_start + 125
110 libsystem_pthread.dylib 0x00007ff80179ec7b thread_start + 15
)
libc++abi: terminating with uncaught exception of type NSException
zsh: abort python3 bot.py
Can you help me ?
Run On MacOs 13.0
I ran the following commands:
python setup.py install
pip install telegram_crypto_price_bot
After this I changed the config.ini file and added api_id, api_hash and bot_token (from BotFather).
Then ran:
cd app
python bot.py
But the error I am getting is:
File "/Users/alisolanki/Program Files/cryptoPriceTelegramBot/app/bot.py", line 26, in <module>
from telegram_crypto_price_bot import PriceBot, __version__
File "/opt/homebrew/lib/python3.9/site-packages/telegram_crypto_price_bot-0.3.3-py3.9.egg/telegram_crypto_price_bot/__init__.py", line 5, in <module>
from telegram_crypto_price_bot.price_bot import PriceBot
File "/opt/homebrew/lib/python3.9/site-packages/telegram_crypto_price_bot-0.3.3-py3.9.egg/telegram_crypto_price_bot/price_bot.py", line 24, in <module>
from telegram_crypto_price_bot.bot.bot_base import BotBase
File "/opt/homebrew/lib/python3.9/site-packages/telegram_crypto_price_bot-0.3.3-py3.9.egg/telegram_crypto_price_bot/bot/bot_base.py", line 31, in <module>
from telegram_crypto_price_bot.command.command_dispatcher import CommandDispatcher, CommandTypes
File "/opt/homebrew/lib/python3.9/site-packages/telegram_crypto_price_bot-0.3.3-py3.9.egg/telegram_crypto_price_bot/command/command_dispatcher.py", line 30, in <module>
from telegram_crypto_price_bot.command.commands import (
File "/opt/homebrew/lib/python3.9/site-packages/telegram_crypto_price_bot-0.3.3-py3.9.egg/telegram_crypto_price_bot/command/commands.py", line 28, in <module>
from telegram_crypto_price_bot.coin_info.coin_info_scheduler import (
File "/opt/homebrew/lib/python3.9/site-packages/telegram_crypto_price_bot-0.3.3-py3.9.egg/telegram_crypto_price_bot/coin_info/coin_info_scheduler.py", line 27, in <module>
from apscheduler.schedulers.background import BackgroundScheduler
ModuleNotFoundError: No module named 'apscheduler.schedulers.background'```
Hi can you advise what has gone wrong here?
2023-01-22 20:36:11,500 WARNING - BadMsgNotification: [17] The msg_id is too high, the client time has to be synchronized.
2023-01-22 20:36:11,500 INFO - PingTask stopped
2023-01-22 20:36:11,501 INFO - Disconnected
2023-01-22 20:36:11,501 INFO - NetworkTask stopped
2023-01-22 20:36:11,501 INFO - Session stopped
Traceback (most recent call last):
File "/root/priceflash/telegram_crypto_price_bot/app/bot.py", line 95, in
price_bot.Run()
File "/root/priceflash/telegram_crypto_price_bot/lib/python3.10/site-packages/telegram_crypto_price_bot-0.3.3-py3.10.egg/telegram_crypto_price_bot/bot/bot_base.py", line 87, in Run
self.client.run()
File "/root/priceflash/telegram_crypto_price_bot/lib/python3.10/site-packages/Pyrogram-2.0.97-py3.10.egg/pyrogram/methods/utilities/run.py", line 84, in run
self.start()
File "/root/priceflash/telegram_crypto_price_bot/lib/python3.10/site-packages/Pyrogram-2.0.97-py3.10.egg/pyrogram/sync.py", line 66, in async_to_sync_wrap
return loop.run_until_complete(coroutine)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
return future.result()
File "/root/priceflash/telegram_crypto_price_bot/lib/python3.10/site-packages/Pyrogram-2.0.97-py3.10.egg/pyrogram/methods/utilities/start.py", line 62, in start
await self.authorize()
File "/root/priceflash/telegram_crypto_price_bot/lib/python3.10/site-packages/Pyrogram-2.0.97-py3.10.egg/pyrogram/client.py", line 333, in authorize
return await self.sign_in_bot(self.bot_token)
File "/root/priceflash/telegram_crypto_price_bot/lib/python3.10/site-packages/Pyrogram-2.0.97-py3.10.egg/pyrogram/methods/auth/sign_in_bot.py", line 76, in sign_in_bot
await self.storage.user_id(r.user.id)
AttributeError: 'BadMsgNotification' object has no attribute 'user'
Hello,
I Have this error just after have installed, when I run a single request :
2022-10-27 18:38:32,529 ERROR - 'utf-8' codec can't encode characters in position 0-1: surrogates not allowed [0/878]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/pyrogram/dispatcher.py", line 242, in handler_worker
await self.loop.run_in_executor(
File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/bot/bot_base.py", line 107, in <lambda>
curr_type(lambda client, message: curr_cfg["callback"](self, client, message),
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/bot/bot_handlers_cfg.py", line 87, in <lambda>
"callback": lambda self, client, message: self.DispatchCommand(client,
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/bot/bot_base.py", line 120, in DispatchCommand
self.cmd_dispatcher.Dispatch(client, message, cmd_type, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/command/command_dispatcher.py", line 124, in Dispatch
cmd_class.Execute(message, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/command/command_base.py", line 96, in Execute
self._ExecuteCommand(**kwargs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/command/commands.py", line 150, in _ExecuteCommand
coin_info_sender.SendMessage(self.cmd_data.Chat(), coin_id, coin_vs, last_days)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/info_message_sender/coin_info_message_sender.py", line 94, in SendMessage
self.chart_price_info_msg_sender.SendMessage(chat, coin_id, coin_vs, last_days)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/info_message_sender/info_message_sender_base.py", line 61, in SendMessage
self.last_sent_msg = self._SendMessage(chat, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/info_message_sender/chart_price_info_message_sender.py", line 80, in _SendMessage
return self._MessageSender().SendPhoto(chat,
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/message/message_sender.py", line 72, in SendPhoto
return self.client.send_photo(receiver.id, photo, **kwargs) # type: ignore
File "/usr/local/lib/python3.9/dist-packages/pyrogram/sync.py", line 78, in async_to_sync_wrap
return asyncio.run_coroutine_threadsafe(coroutine, main_loop).result()
File "/usr/lib/python3.9/concurrent/futures/_base.py", line 440, in result
return self.__get_result()
File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
File "/usr/local/lib/python3.9/dist-packages/pyrogram/methods/messages/send_photo.py", line 170, in send_photo
r = await self.invoke(
File "/usr/local/lib/python3.9/dist-packages/pyrogram/methods/advanced/invoke.py", line 79, in invoke
r = await self.session.invoke(
File "/usr/local/lib/python3.9/dist-packages/pyrogram/session/session.py", line 361, in invoke
return await self.send(query, timeout=timeout)
File "/usr/local/lib/python3.9/dist-packages/pyrogram/session/session.py", line 290, in send
message = self.msg_factory(data)
File "/usr/local/lib/python3.9/dist-packages/pyrogram/session/internals/msg_factory.py", line 37, in __call__
len(body)
File "/usr/local/lib/python3.9/dist-packages/pyrogram/raw/core/tl_object.py", line 79, in __len__
return len(self.write())
File "/usr/local/lib/python3.9/dist-packages/pyrogram/raw/functions/messages/send_media.py", line 168, in write
b.write(Vector(self.entities))
File "/usr/local/lib/python3.9/dist-packages/pyrogram/raw/core/primitives/vector.py", line 58, in __new__
+ [cast(bytes, t(i)) if t else i.write() for i in value]
File "/usr/local/lib/python3.9/dist-packages/pyrogram/raw/core/primitives/vector.py", line 58, in <listcomp>
+ [cast(bytes, t(i)) if t else i.write() for i in value]
File "/usr/local/lib/python3.9/dist-packages/pyrogram/raw/types/message_entity_pre.py", line 86, in write
b.write(String(self.language))
File "/usr/local/lib/python3.9/dist-packages/pyrogram/raw/core/primitives/string.py", line 31, in __new__
return super().__new__(cls, value.encode())
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-1: surrogates not allowed
Can you help me ?
Hello,
I've an error :
2022-12-15 09:17:27,648 ERROR - int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/pyrogram/dispatcher.py", line 242, in handler_worker
await self.loop.run_in_executor(
File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/bot/bot_base.py", line 107, in <lambda>
curr_type(lambda client, message: curr_cfg["callback"](self, client, message),
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/bot/bot_handlers_cfg.py", line 87, in <lambda>
"callback": lambda self, client, message: self.DispatchCommand(client,
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/bot/bot_base.py", line 120, in DispatchCommand
self.cmd_dispatcher.Dispatch(client, message, cmd_type, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/command/command_dispatcher.py", line 124, in Dispatch
cmd_class.Execute(message, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/command/command_base.py", line 96, in Execute
self._ExecuteCommand(**kwargs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/command/commands.py", line 150, in _ExecuteCommand
coin_info_sender.SendMessage(self.cmd_data.Chat(), coin_id, coin_vs, last_days)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/info_message_sender/coin_info_message_sender.py", line 94, in SendMessage
self.chart_price_info_msg_sender.SendMessage(chat, coin_id, coin_vs, last_days)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/info_message_sender/info_message_sender_base.py", line 61, in SendMessage
self.last_sent_msg = self._SendMessage(chat, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/info_message_sender/chart_price_info_message_sender.py", line 67, in _SendMessage
price_info = self._CoinGeckoPriceApi().GetPriceInfo(args[0], args[1])
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/coingecko/coingecko_price_api.py", line 57, in GetPriceInfo
return PriceInfo(coin_info, coin_vs)
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/price_info/price_info.py", line 73, in __init__
PriceInfoTypes.MARKET_CAP_RANK: Utils.StrToInt(coin_data["market_data"]["market_cap_rank"]),
File "/usr/local/lib/python3.9/dist-packages/telegram_crypto_price_bot/utils/utils.py", line 66, in StrToInt
return int(s)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
When I try on new crypto, coingecko return null value in market cap.
My workaround in telegram_crypto_price_bot/utils/utils.py
change block line 63 to :
# Convert string to integer
@staticmethod
def StrToInt(s: str) -> int:
if s is None:
res = int(0)
else:
res = int(s)
return res
Hello,
From CoinGecko.
Before i've the price (pair) displayed :
BUT price_info_builder.py
return good values :
2022-12-15 11:47:57,974 INFO - Executed by user: XXXX (ID: XXXXX)
('**Bitcoin - Price Info**\n'
'\n'
'```💵 BTC/USD 17664$\n'
'📈 High 24h 18323$\n'
'📈 Low 24h 17609$\n'
'📊 Volume 24h 27.81B $\n'
'💎 Market Cap 340.10B $\n'
'\n'
'⚖ Diff.\n'
' 24h 🔴 -0.93%\n'
' 7d 🟢 +4.82%\n'
' 14d 🟢 +2.78%\n'
' 30d 🟢 +6.12%```')
how can i debug this?
thank's
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.