Added unicoded emoji's to Telegram messages
This commit is contained in:
parent
ff289a7177
commit
080efd1102
@ -19,7 +19,6 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
logger.debug('Included module rpc.telegram ...')
|
logger.debug('Included module rpc.telegram ...')
|
||||||
|
|
||||||
|
|
||||||
MAX_TELEGRAM_MESSAGE_LENGTH = 4096
|
MAX_TELEGRAM_MESSAGE_LENGTH = 4096
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +28,7 @@ def authorized_only(command_handler: Callable[..., None]) -> Callable[..., Any]:
|
|||||||
:param command_handler: Telegram CommandHandler
|
:param command_handler: Telegram CommandHandler
|
||||||
:return: decorated function
|
:return: decorated function
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def wrapper(self, *args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
""" Decorator logic """
|
""" Decorator logic """
|
||||||
update = kwargs.get('update') or args[0]
|
update = kwargs.get('update') or args[0]
|
||||||
@ -126,6 +126,12 @@ class Telegram(RPC):
|
|||||||
def send_msg(self, msg: Dict[str, Any]) -> None:
|
def send_msg(self, msg: Dict[str, Any]) -> None:
|
||||||
""" Send a message to telegram channel """
|
""" Send a message to telegram channel """
|
||||||
|
|
||||||
|
'🔵'.encode('ascii', 'namereplace')
|
||||||
|
'🚀'.encode('ascii', 'namereplace')
|
||||||
|
'✳'.encode('ascii', 'namereplace')
|
||||||
|
'❌'.encode('ascii', 'namereplace')
|
||||||
|
'⚠'.encode('ascii', 'namereplace')
|
||||||
|
|
||||||
if msg['type'] == RPCMessageType.BUY_NOTIFICATION:
|
if msg['type'] == RPCMessageType.BUY_NOTIFICATION:
|
||||||
if self._fiat_converter:
|
if self._fiat_converter:
|
||||||
msg['stake_amount_fiat'] = self._fiat_converter.convert_amount(
|
msg['stake_amount_fiat'] = self._fiat_converter.convert_amount(
|
||||||
@ -133,7 +139,7 @@ class Telegram(RPC):
|
|||||||
else:
|
else:
|
||||||
msg['stake_amount_fiat'] = 0
|
msg['stake_amount_fiat'] = 0
|
||||||
|
|
||||||
message = ("*{exchange}:* Buying {pair}\n"
|
message = ("\N{LARGE BLUE CIRCLE} *{exchange}:* Buying {pair}\n"
|
||||||
"*Amount:* `{amount:.8f}`\n"
|
"*Amount:* `{amount:.8f}`\n"
|
||||||
"*Open Rate:* `{limit:.8f}`\n"
|
"*Open Rate:* `{limit:.8f}`\n"
|
||||||
"*Current Rate:* `{current_rate:.8f}`\n"
|
"*Current Rate:* `{current_rate:.8f}`\n"
|
||||||
@ -144,7 +150,7 @@ class Telegram(RPC):
|
|||||||
message += ")`"
|
message += ")`"
|
||||||
|
|
||||||
elif msg['type'] == RPCMessageType.BUY_CANCEL_NOTIFICATION:
|
elif msg['type'] == RPCMessageType.BUY_CANCEL_NOTIFICATION:
|
||||||
message = "*{exchange}:* Cancelling Open Buy Order for {pair}".format(**msg)
|
message = "\N{WARNING SIGN} *{exchange}:* Cancelling Open Buy Order for {pair}".format(**msg)
|
||||||
|
|
||||||
elif msg['type'] == RPCMessageType.SELL_NOTIFICATION:
|
elif msg['type'] == RPCMessageType.SELL_NOTIFICATION:
|
||||||
msg['amount'] = round(msg['amount'], 8)
|
msg['amount'] = round(msg['amount'], 8)
|
||||||
@ -153,33 +159,44 @@ class Telegram(RPC):
|
|||||||
microsecond=0) - msg['open_date'].replace(microsecond=0)
|
microsecond=0) - msg['open_date'].replace(microsecond=0)
|
||||||
msg['duration_min'] = msg['duration'].total_seconds() / 60
|
msg['duration_min'] = msg['duration'].total_seconds() / 60
|
||||||
|
|
||||||
message = ("*{exchange}:* Selling {pair}\n"
|
if float(msg['profit_percent']) >= 5.0:
|
||||||
"*Amount:* `{amount:.8f}`\n"
|
message = ("\N{ROCKET} *{exchange}:* Selling {pair}\n").format(**msg)
|
||||||
"*Open Rate:* `{open_rate:.8f}`\n"
|
|
||||||
"*Current Rate:* `{current_rate:.8f}`\n"
|
elif float(msg['profit_percent']) >= 0.0:
|
||||||
"*Close Rate:* `{limit:.8f}`\n"
|
message = "\N{EIGHT SPOKED ASTERISK} *{exchange}:* Selling {pair}\n"
|
||||||
"*Sell Reason:* `{sell_reason}`\n"
|
|
||||||
"*Duration:* `{duration} ({duration_min:.1f} min)`\n"
|
elif msg['sell_reason'] == "stop_loss":
|
||||||
"*Profit:* `{profit_percent:.2f}%`").format(**msg)
|
message = ("\N{WARNING SIGN} *{exchange}:* Selling {pair}\n").format(**msg)
|
||||||
|
|
||||||
|
else:
|
||||||
|
message = ("\N{CROSS MARK} *{exchange}:* Selling {pair}\n").format(**msg)
|
||||||
|
|
||||||
|
message += ("*Amount:* `{amount:.8f}`\n"
|
||||||
|
"*Open Rate:* `{open_rate:.8f}`\n"
|
||||||
|
"*Current Rate:* `{current_rate:.8f}`\n"
|
||||||
|
"*Close Rate:* `{limit:.8f}`\n"
|
||||||
|
"*Sell Reason:* `{sell_reason}`\n"
|
||||||
|
"*Duration:* `{duration} ({duration_min:.1f} min)`\n"
|
||||||
|
"*Profit:* `{profit_percent:.2f}%`").format(**msg)
|
||||||
|
|
||||||
# Check if all sell properties are available.
|
# Check if all sell properties are available.
|
||||||
# This might not be the case if the message origin is triggered by /forcesell
|
# This might not be the case if the message origin is triggered by /forcesell
|
||||||
if (all(prop in msg for prop in ['gain', 'fiat_currency', 'stake_currency'])
|
if (all(prop in msg for prop in ['gain', 'fiat_currency', 'stake_currency'])
|
||||||
and self._fiat_converter):
|
and self._fiat_converter):
|
||||||
msg['profit_fiat'] = self._fiat_converter.convert_amount(
|
msg['profit_fiat'] = self._fiat_converter.convert_amount(
|
||||||
msg['profit_amount'], msg['stake_currency'], msg['fiat_currency'])
|
msg['profit_amount'], msg['stake_currency'], msg['fiat_currency'])
|
||||||
message += (' `({gain}: {profit_amount:.8f} {stake_currency}'
|
message += (' `({gain}: {profit_amount:.8f} {stake_currency}'
|
||||||
' / {profit_fiat:.3f} {fiat_currency})`').format(**msg)
|
' / {profit_fiat:.3f} {fiat_currency})`').format(**msg)
|
||||||
|
|
||||||
elif msg['type'] == RPCMessageType.SELL_CANCEL_NOTIFICATION:
|
elif msg['type'] == RPCMessageType.SELL_CANCEL_NOTIFICATION:
|
||||||
message = ("*{exchange}:* Cancelling Open Sell Order "
|
message = ("\N{WARNING SIGN} *{exchange}:* Cancelling Open Sell Order "
|
||||||
"for {pair}. Reason: {reason}").format(**msg)
|
"for {pair}. Reason: {reason}").format(**msg)
|
||||||
|
|
||||||
elif msg['type'] == RPCMessageType.STATUS_NOTIFICATION:
|
elif msg['type'] == RPCMessageType.STATUS_NOTIFICATION:
|
||||||
message = '*Status:* `{status}`'.format(**msg)
|
message = '*Status:* `{status}`'.format(**msg)
|
||||||
|
|
||||||
elif msg['type'] == RPCMessageType.WARNING_NOTIFICATION:
|
elif msg['type'] == RPCMessageType.WARNING_NOTIFICATION:
|
||||||
message = '*Warning:* `{status}`'.format(**msg)
|
message = '\N{WARNING SIGN} *Warning:* `{status}`'.format(**msg)
|
||||||
|
|
||||||
elif msg['type'] == RPCMessageType.CUSTOM_NOTIFICATION:
|
elif msg['type'] == RPCMessageType.CUSTOM_NOTIFICATION:
|
||||||
message = '{status}'.format(**msg)
|
message = '{status}'.format(**msg)
|
||||||
@ -222,8 +239,8 @@ class Telegram(RPC):
|
|||||||
# Adding initial stoploss only if it is different from stoploss
|
# Adding initial stoploss only if it is different from stoploss
|
||||||
"*Initial Stoploss:* `{initial_stop_loss:.8f}` " +
|
"*Initial Stoploss:* `{initial_stop_loss:.8f}` " +
|
||||||
("`({initial_stop_loss_pct:.2f}%)`") if (
|
("`({initial_stop_loss_pct:.2f}%)`") if (
|
||||||
r['stop_loss'] != r['initial_stop_loss']
|
r['stop_loss'] != r['initial_stop_loss']
|
||||||
and r['initial_stop_loss_pct'] is not None) else "",
|
and r['initial_stop_loss_pct'] is not None) else "",
|
||||||
|
|
||||||
# Adding stoploss and stoploss percentage only if it is not None
|
# Adding stoploss and stoploss percentage only if it is not None
|
||||||
"*Stoploss:* `{stop_loss:.8f}` " +
|
"*Stoploss:* `{stop_loss:.8f}` " +
|
||||||
@ -363,14 +380,14 @@ class Telegram(RPC):
|
|||||||
"This mode is still experimental!\n"
|
"This mode is still experimental!\n"
|
||||||
"Starting capital: "
|
"Starting capital: "
|
||||||
f"`{self._config['dry_run_wallet']}` {self._config['stake_currency']}.\n"
|
f"`{self._config['dry_run_wallet']}` {self._config['stake_currency']}.\n"
|
||||||
)
|
)
|
||||||
for currency in result['currencies']:
|
for currency in result['currencies']:
|
||||||
if currency['est_stake'] > 0.0001:
|
if currency['est_stake'] > 0.0001:
|
||||||
curr_output = "*{currency}:*\n" \
|
curr_output = "*{currency}:*\n" \
|
||||||
"\t`Available: {free: .8f}`\n" \
|
"\t`Available: {free: .8f}`\n" \
|
||||||
"\t`Balance: {balance: .8f}`\n" \
|
"\t`Balance: {balance: .8f}`\n" \
|
||||||
"\t`Pending: {used: .8f}`\n" \
|
"\t`Pending: {used: .8f}`\n" \
|
||||||
"\t`Est. {stake}: {est_stake: .8f}`\n".format(**currency)
|
"\t`Est. {stake}: {est_stake: .8f}`\n".format(**currency)
|
||||||
else:
|
else:
|
||||||
curr_output = "*{currency}:* not showing <1$ amount \n".format(**currency)
|
curr_output = "*{currency}:* not showing <1$ amount \n".format(**currency)
|
||||||
|
|
||||||
@ -587,7 +604,7 @@ class Telegram(RPC):
|
|||||||
"*/profit:* `Lists cumulative profit from all finished trades`\n" \
|
"*/profit:* `Lists cumulative profit from all finished trades`\n" \
|
||||||
"*/forcesell <trade_id>|all:* `Instantly sells the given trade or all trades, " \
|
"*/forcesell <trade_id>|all:* `Instantly sells the given trade or all trades, " \
|
||||||
"regardless of profit`\n" \
|
"regardless of profit`\n" \
|
||||||
f"{forcebuy_text if self._config.get('forcebuy_enable', False) else '' }" \
|
f"{forcebuy_text if self._config.get('forcebuy_enable', False) else ''}" \
|
||||||
"*/performance:* `Show performance of each finished trade grouped by pair`\n" \
|
"*/performance:* `Show performance of each finished trade grouped by pair`\n" \
|
||||||
"*/daily <n>:* `Shows profit or loss per day, over the last n days`\n" \
|
"*/daily <n>:* `Shows profit or loss per day, over the last n days`\n" \
|
||||||
"*/count:* `Show number of trades running compared to allowed number of trades`" \
|
"*/count:* `Show number of trades running compared to allowed number of trades`" \
|
||||||
|
Loading…
Reference in New Issue
Block a user