Add agentname in message

This commit is contained in:
2025-07-04 14:12:45 +07:00
parent f613020d9d
commit 38959db65f
2 changed files with 9 additions and 3 deletions

View File

@@ -14,6 +14,7 @@ public class AccountService : IAccountService
private readonly IEvmManager _evmManager; private readonly IEvmManager _evmManager;
private readonly ICacheService _cacheService; private readonly ICacheService _cacheService;
private readonly IWeb3ProxyService _web3ProxyService; private readonly IWeb3ProxyService _web3ProxyService;
private readonly IUserRepository _userRepository;
private readonly ILogger<AccountService> _logger; private readonly ILogger<AccountService> _logger;
public AccountService( public AccountService(
@@ -22,7 +23,8 @@ public class AccountService : IAccountService
IExchangeService exchangeService, IExchangeService exchangeService,
IEvmManager evmManager, IEvmManager evmManager,
ICacheService cacheService, ICacheService cacheService,
IWeb3ProxyService web3ProxyService) IWeb3ProxyService web3ProxyService,
IUserRepository userRepository)
{ {
_accountRepository = accountRepository; _accountRepository = accountRepository;
_logger = logger; _logger = logger;
@@ -30,6 +32,7 @@ public class AccountService : IAccountService
_evmManager = evmManager; _evmManager = evmManager;
_cacheService = cacheService; _cacheService = cacheService;
_web3ProxyService = web3ProxyService; _web3ProxyService = web3ProxyService;
_userRepository = userRepository;
} }
public async Task<Account> CreateAccount(User user, Account request) public async Task<Account> CreateAccount(User user, Account request)
@@ -99,6 +102,8 @@ public class AccountService : IAccountService
var account = await _accountRepository.GetAccountByNameAsync(name); var account = await _accountRepository.GetAccountByNameAsync(name);
ManageProperties(hideSecrets, getBalance, account); ManageProperties(hideSecrets, getBalance, account);
account.User = await _userRepository.GetUserByNameAsync(account.User.Name);
return account; return account;
} }

View File

@@ -1353,9 +1353,10 @@ public class TradingBot : Bot, ITradingBot
{ {
if (!Config.IsForBacktest) if (!Config.IsForBacktest)
{ {
var user = Account.User;
// Add bot name at the top of every message // Add bot name at the top of every message
var messageWithBotName = $"🤖 **{Name}**\n{message}"; var messageWithBotName = $"🤖 **{user.AgentName} - {Name}**\n{message}";
await MessengerService.SendTradeMessage(messageWithBotName, isBadBehavior, Account?.User); await MessengerService.SendTradeMessage(messageWithBotName, isBadBehavior, user);
} }
} }