Merge branch 'develop' into api-server-list-custom-data
This commit is contained in:
@@ -471,6 +471,12 @@ CONF_SCHEMA = {
|
||||
"description": "Telegram topic ID - only applicable for group chats",
|
||||
"type": "string",
|
||||
},
|
||||
"authorized_users": {
|
||||
"description": "Authorized users for the bot.",
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"uniqueItems": True,
|
||||
},
|
||||
"allow_custom_messages": {
|
||||
"description": "Allow sending custom messages from the Strategy.",
|
||||
"type": "boolean",
|
||||
@@ -1026,8 +1032,7 @@ CONF_SCHEMA = {
|
||||
"Number of historical candles to use for computing target (label) "
|
||||
"statistics from prediction data, instead of from the training dataset."
|
||||
),
|
||||
"type": "boolean",
|
||||
"default": False,
|
||||
"type": "integer",
|
||||
},
|
||||
"data_kitchen_thread_count": {
|
||||
"description": (
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2441,8 +2441,8 @@ class Exchange:
|
||||
|
||||
return self._exchange_ws.get_ohlcv(pair, timeframe, candle_type, candle_ts)
|
||||
logger.info(
|
||||
f"Failed to reuse watch {pair}, {timeframe}, {candle_ts < last_refresh_time},"
|
||||
f" {candle_ts}, {last_refresh_time}, "
|
||||
f"Couldn't reuse watch for {pair}, {timeframe}, falling back to REST api. "
|
||||
f"{candle_ts < last_refresh_time}, {candle_ts}, {last_refresh_time}, "
|
||||
f"{format_ms_time(candle_ts)}, {format_ms_time(last_refresh_time)} "
|
||||
)
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ def _get_resample_from_period(period: str) -> str:
|
||||
if period == "month":
|
||||
return "1ME"
|
||||
if period == "year":
|
||||
return "1Y"
|
||||
return "1YE"
|
||||
raise ValueError(f"Period {period} is not supported.")
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ from telegram import (
|
||||
InlineKeyboardButton,
|
||||
InlineKeyboardMarkup,
|
||||
KeyboardButton,
|
||||
Message,
|
||||
ReplyKeyboardMarkup,
|
||||
Update,
|
||||
)
|
||||
@@ -96,17 +97,17 @@ def authorized_only(command_handler: Callable[..., Coroutine[Any, Any, None]]):
|
||||
"""
|
||||
|
||||
@wraps(command_handler)
|
||||
async def wrapper(self, *args, **kwargs):
|
||||
async def wrapper(self, *args, **kwargs) -> None:
|
||||
"""Decorator logic"""
|
||||
update = kwargs.get("update") or args[0]
|
||||
|
||||
# Reject unauthorized messages
|
||||
if update.callback_query:
|
||||
cchat_id = int(update.callback_query.message.chat.id)
|
||||
ctopic_id = update.callback_query.message.message_thread_id
|
||||
else:
|
||||
cchat_id = int(update.message.chat_id)
|
||||
ctopic_id = update.message.message_thread_id
|
||||
message: Message = (
|
||||
update.message if update.callback_query is None else update.callback_query.message
|
||||
)
|
||||
cchat_id: int = int(message.chat_id)
|
||||
ctopic_id: int | None = message.message_thread_id
|
||||
from_user_id: str = str(update.effective_user.id if update.effective_user else "")
|
||||
|
||||
chat_id = int(self._config["telegram"]["chat_id"])
|
||||
if cchat_id != chat_id:
|
||||
@@ -118,6 +119,10 @@ def authorized_only(command_handler: Callable[..., Coroutine[Any, Any, None]]):
|
||||
logger.debug(f"Rejected message from wrong channel: {cchat_id}, {ctopic_id}")
|
||||
return None
|
||||
|
||||
authorized = self._config["telegram"].get("authorized_users", None)
|
||||
if authorized is not None and from_user_id not in authorized:
|
||||
logger.info(f"Unauthorized user tried to control the bot: {from_user_id}")
|
||||
return None
|
||||
# Rollback session to avoid getting data stored in a transaction.
|
||||
Trade.rollback()
|
||||
logger.debug("Executing handler: %s for chat_id: %s", command_handler.__name__, chat_id)
|
||||
@@ -2155,6 +2160,9 @@ class Telegram(RPCHandler):
|
||||
return
|
||||
chat_id = update.message.chat_id
|
||||
topic_id = update.message.message_thread_id
|
||||
user_id = (
|
||||
update.effective_user.id if topic_id is not None and update.effective_user else None
|
||||
)
|
||||
|
||||
msg = f"""Freqtrade Bot Info:
|
||||
```json
|
||||
@@ -2162,7 +2170,8 @@ class Telegram(RPCHandler):
|
||||
"enabled": true,
|
||||
"token": "********",
|
||||
"chat_id": "{chat_id}",
|
||||
{f'"topic_id": "{topic_id}"' if topic_id else ""}
|
||||
{f'"topic_id": "{topic_id}",' if topic_id else ""}
|
||||
{f'//"authorized_users": ["{user_id}"]' if topic_id and user_id else ""}
|
||||
}}
|
||||
```
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user