Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/settings/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface TelegramSyncSettings {
processOldMessagesSettings: ProcessOldMessagesSettings;
processOtherBotsMessages: boolean;
retryFailedMessagesProcessing: boolean;
proxyUrl: string;
// add new settings above this line
topicNames: Topic[];
}
Expand All @@ -92,6 +93,7 @@ export const DEFAULT_SETTINGS: TelegramSyncSettings = {
processOldMessagesSettings: getDefaultProcessOldMessagesSettings(),
processOtherBotsMessages: false,
retryFailedMessagesProcessing: false,
proxyUrl: "",
// add new settings above this line
topicNames: [],
};
Expand Down
15 changes: 15 additions & 0 deletions src/settings/modals/AdvancedSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class AdvancedSettingsModal extends Modal {
this.addDeleteMessagesFromTelegram();
this.addMessageDelimiterSetting();
this.addParallelMessageProcessing();
this.addProxyUrl();
}

addHeader() {
Expand Down Expand Up @@ -85,6 +86,20 @@ export class AdvancedSettingsModal extends Modal {
});
}

addProxyUrl() {
new Setting(this.advancedSettingsDiv)
.setName("Proxy URL")
.setDesc("HTTP proxy for connecting to Telegram (e.g., http://127.0.0.1:7897). Restart the plugin after changing.")
.addText((text) => {
text.setPlaceholder("http://127.0.0.1:7897");
text.setValue(this.plugin.settings.proxyUrl);
text.onChange(async (value) => {
this.plugin.settings.proxyUrl = value.trim();
await this.plugin.saveSettings();
});
});
}

onOpen() {
this.display();
}
Expand Down
6 changes: 5 additions & 1 deletion src/telegram/bot/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export async function connect(plugin: TelegramSyncPlugin) {
return;
}
// Create a new bot instance and start polling
plugin.bot = new TelegramBot(await enqueue(plugin, plugin.getBotToken));
const botOptions: TelegramBot.ConstructorOptions = {};
if (plugin.settings.proxyUrl) {
botOptions.request = { proxy: plugin.settings.proxyUrl };
}
plugin.bot = new TelegramBot(await enqueue(plugin, plugin.getBotToken), botOptions);
const bot = plugin.bot;
// Set connected flag to false and log errors when a polling error occurs
bot.on("polling_error", async (error: unknown) => {
Expand Down
Loading