Add blacklist-control to telegram
This commit is contained in:
@@ -111,9 +111,9 @@ class Telegram(RPCHandler):
|
||||
r'/daily$', r'/daily \d+$', r'/profit$', r'/profit \d+',
|
||||
r'/stats$', r'/count$', r'/locks$', r'/balance$',
|
||||
r'/stopbuy$', r'/reload_config$', r'/show_config$',
|
||||
r'/logs$', r'/whitelist$', r'/blacklist$', r'/edge$',
|
||||
r'/logs$', r'/whitelist$', r'/blacklist$', r'/bl_delete$',
|
||||
r'/weekly$', r'/weekly \d+$', r'/monthly$', r'/monthly \d+$',
|
||||
r'/forcebuy$', r'/help$', r'/version$']
|
||||
r'/forcebuy$', r'/edge$', r'/help$', r'/version$']
|
||||
# Create keys for generation
|
||||
valid_keys_print = [k.replace('$', '') for k in valid_keys]
|
||||
|
||||
@@ -170,6 +170,7 @@ class Telegram(RPCHandler):
|
||||
CommandHandler('stopbuy', self._stopbuy),
|
||||
CommandHandler('whitelist', self._whitelist),
|
||||
CommandHandler('blacklist', self._blacklist),
|
||||
CommandHandler(['blacklist_delete', 'bl_delete'], self._blacklist_delete),
|
||||
CommandHandler('logs', self._logs),
|
||||
CommandHandler('edge', self._edge),
|
||||
CommandHandler('help', self._help),
|
||||
@@ -1164,7 +1165,12 @@ class Telegram(RPCHandler):
|
||||
"""
|
||||
try:
|
||||
|
||||
blacklist = self._rpc._rpc_blacklist(context.args)
|
||||
self.send_blacklist_msg(self._rpc._rpc_blacklist(context.args))
|
||||
except RPCException as e:
|
||||
self._send_msg(str(e))
|
||||
|
||||
def send_blacklist_msg(self, blacklist: Dict):
|
||||
try:
|
||||
errmsgs = []
|
||||
for pair, error in blacklist['errors'].items():
|
||||
errmsgs.append(f"Error adding `{pair}` to blacklist: `{error['error_msg']}`")
|
||||
@@ -1179,6 +1185,17 @@ class Telegram(RPCHandler):
|
||||
except RPCException as e:
|
||||
self._send_msg(str(e))
|
||||
|
||||
@authorized_only
|
||||
def _blacklist_delete(self, update: Update, context: CallbackContext) -> None:
|
||||
"""
|
||||
Handler for /bl_delete
|
||||
Deletes pair(s) from current blacklist
|
||||
"""
|
||||
try:
|
||||
self.send_blacklist_msg(self._rpc._rpc_blacklist_delete(context.args))
|
||||
except RPCException as e:
|
||||
self._send_msg(str(e))
|
||||
|
||||
@authorized_only
|
||||
def _logs(self, update: Update, context: CallbackContext) -> None:
|
||||
"""
|
||||
@@ -1258,6 +1275,8 @@ class Telegram(RPCHandler):
|
||||
"*/whitelist:* `Show current whitelist` \n"
|
||||
"*/blacklist [pair]:* `Show current blacklist, or adds one or more pairs "
|
||||
"to the blacklist.` \n"
|
||||
"*/blacklist_delete [pairs]| /bl_delete [pairs]:* `Delete pair / pattern from blacklist. "
|
||||
"Will reset on reload_conf.` \n"
|
||||
"*/reload_config:* `Reload configuration file` \n"
|
||||
"*/unlock <pair|id>:* `Unlock this Pair (or this lock id if it's numeric)`\n"
|
||||
|
||||
|
Reference in New Issue
Block a user