Skip to content

Commit

Permalink
fixed telegram message text format
Browse files Browse the repository at this point in the history
  • Loading branch information
farzadex-eth committed May 22, 2023
1 parent 9eeaa5e commit 5b35483
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tokenfinderbot"
version = "1.0.1"
version = "1.0.2"
description = "A simple bot for scanning new ERC-20 token pools created and filtering them based on the time created, liquidity and market cap"
authors = ["Farzad Z <farzadex.eth@gmail.com>"]
readme = "README.md"
Expand Down
24 changes: 24 additions & 0 deletions tokenfinderbot/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,30 @@ class bcolors:
{bcolors.OKBLUE}Liquidity: {bcolors.ENDC}{pool['liquidity']['usd']}
{bcolors.OKBLUE}Market Cap: {bcolors.ENDC}{pool['fdv']}
{bcolors.OKBLUE}Created at: {bcolors.ENDC}{datetime.utcfromtimestamp(int(pool['pairCreatedAt']/1000)).strftime('%Y-%m-%d %H:%M:%S')} UTC [{(datetime.now(tz=timezone.utc) - timedelta(seconds=pool['pairCreatedAt']/1000)).strftime('%H hour(s), %M minute(s) ago')}]
--------------------------------------------------------------
"""
return info_str

def get_pool_clean_str(self, address: str) -> str:
"""Returns a string of summarized pool info without text colors
Args:
address (str): pool pair address
Returns:
str: pool info
"""

pool = self.get_pool(address)
info_str = f"""\n--------------------------------------------------------------\n{pool['baseToken']['symbol']} / {pool['quoteToken']['symbol']}:
Pair Address: {address}
URL: {pool['url']}
Price:
{pool['priceNative']} {pool['quoteToken']['symbol']}
{pool['priceUsd']} USD
Liquidity: {pool['liquidity']['usd']}
Market Cap: {pool['fdv']}
Created at: {datetime.utcfromtimestamp(int(pool['pairCreatedAt']/1000)).strftime('%Y-%m-%d %H:%M:%S')} UTC [{(datetime.now(tz=timezone.utc) - timedelta(seconds=pool['pairCreatedAt']/1000)).strftime('%H hour(s), %M minute(s) ago')}]
--------------------------------------------------------------
"""
return info_str
6 changes: 2 additions & 4 deletions tokenfinderbot/tokenfinderbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ def single_run(self) -> None:
for pair in filtered_pairs:
try:
pooldb.insert_pool(pair)
pool_message = pooldb.get_pool_str(pair['pairAddress'])
print(pool_message)
self.notify_on_telegram(pool_message)
print(pooldb.get_pool_str(pair['pairAddress']))
self.notify_on_telegram(pooldb.get_pool_clean_str(pair['pairAddress']))
new_pairs_num += 1
except:
pass
Expand All @@ -111,7 +110,6 @@ def notify_on_telegram(self, message) -> None:
BaseException: Error in telegram communication
"""
tsettings = self._settings.telegram
print(tsettings)
if tsettings.notify and tsettings.bot_token != "" and tsettings.chat_id != "":
try:
url = f'https://api.telegram.org/bot{tsettings.bot_token}/sendMessage?chat_id={tsettings.chat_id}&text={message}'
Expand Down

0 comments on commit 5b35483

Please sign in to comment.