This repository was archived by the owner on Mar 3, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 22
22
@register_platform_adapter ("telegram" , "telegram 适配器" , default_config_tmpl = {
23
23
"telegram_token" : "your_token" ,
24
24
"start_message" : "Hello, I'm AstrBot!" ,
25
- "提示" : "由于 Telegram 无法在中国大陆访问,如果你的网络环境为中国大陆,记得在 `其他配置` 处设置代理!"
25
+ "telegram_api_base_url" : "https://api.telegram.org/bot" ,
26
+ "提示" : "由于 Telegram 无法在中国大陆 / Iran 访问,如果你的网络环境为中国大陆 / Iran,记得在 `其他配置` 处设置代理!"
26
27
})
27
28
class TelegramPlatformAdapter (Platform ):
28
29
@@ -47,7 +48,11 @@ def meta(self) -> PlatformMetadata:
47
48
48
49
@override
49
50
async def run (self ):
50
- self .application = ApplicationBuilder ().token (self .config ['telegram_token' ]).build ()
51
+ base_url = self .config .get ("telegram_api_base_url" , "https://api.telegram.org/bot" )
52
+ if not base_url :
53
+ base_url = "https://api.telegram.org/bot"
54
+
55
+ self .application = ApplicationBuilder ().token (self .config ['telegram_token' ]).base_url (base_url ).build ()
51
56
message_handler = TelegramMessageHandler (
52
57
filters = None ,
53
58
callback = self .convert_message
@@ -98,4 +103,4 @@ async def handle_msg(self, message: AstrBotMessage):
98
103
session_id = message .session_id ,
99
104
client = self .client
100
105
)
101
- self .commit_event (message_event )
106
+ self .commit_event (message_event )
You can’t perform that action at this time.
0 commit comments