mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 07:25:36 +01:00
Fix webhook ip
This commit is contained in:
@@ -110,12 +110,15 @@ export default class BotsManager {
|
||||
|
||||
static async _setWebhook(bot: Telegraf, state: BotState): Promise<boolean> {
|
||||
const dockerIps = (await dockerIpTools.getContainerIp()).split(" ");
|
||||
const filteredIp = dockerIps.filter((ip) => ip.startsWith(env.NETWORK_IP_PREFIX));
|
||||
|
||||
for (const dockerIp of dockerIps) {
|
||||
const ips = filteredIp.length !== 0 ? filteredIp : dockerIps;
|
||||
|
||||
for (const ip of ips) {
|
||||
try {
|
||||
await bot.telegram.setWebhook(
|
||||
`${env.WEBHOOK_BASE_URL}:${env.WEBHOOK_PORT}/${state.id}/${bot.telegram.token}`, {
|
||||
ip_address: dockerIp,
|
||||
ip_address: ip,
|
||||
}
|
||||
);
|
||||
return true;
|
||||
|
||||
@@ -18,4 +18,5 @@ export default cleanEnv(process.env, {
|
||||
DOWNLOADER_API_KEY: str(),
|
||||
USER_SETTINGS_URL: str(),
|
||||
USER_SETTINGS_API_KEY: str(),
|
||||
NETWORK_IP_PREFIX: str(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user