Closed NRD90M closed 7 months ago
这好像不能连接到telegram, 有如下两种方法:
你尝试添加 -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPost=(你的http代理端口)
设置代理
java -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPost=20171 -jar tgst-2.0-SNAPSHOT-jar-with-dependencies.jar
在国外服务器运行该程序
推荐第二种方法, 因为第一种方法不稳定, 即便设置代理,有时也会意外断开连接
java -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPost=20171 -jar tgst-2.0-SNAPSHOT-jar-with-dependencies.jar 错误: 找不到或无法加载主类 .proxyHost=127.0.0.1 原因: java.lang.ClassNotFoundException: /proxyHost=127/0/0/1 PS E:\Codes\tgsetu-master\target>
使用cmd
运行
java -Dhttp.proxyHost="127.0.0.1" -Dhttp.proxyPost="20171" -jar tgst-2.0-SNAPSHOT-jar-with-dependencies.jar
另外,检查配置文件里的机器人名(tgBotName)和机器人令牌(tgBotToken)是否正确,默认的是无法运行的,需要自己去申请tg机器人
{ "tgBotName": "setuPussy_bot", "tgBotToken": "6885349535:AAGvjmErrmzkQD88xEgp95Jld2oEcZvdpCM", "message": [ { "type": "help", "keyWord": ["help", "/help", "start", "/start", "帮助", "/帮助"], "intro": "色图机器人 for telegram, 仓库地址: https://github.com/xmexg/tgsetu" }, { "type": "image", "keyWord": ["/hentai", "hentai", "/setu", "setu", "色图", "涩图", "来点色图", "来点涩图", "来张色图", "来张涩图"], "url": "https://moe.jitsu.top/r18", "intro": "R18图" }, { "type": "image", "keyWord": ["/bg", "bg", "二次元"], "url": "https://www.loliapi.com/bg/", "intro": "随机二次元图" }, { "type": "image", "keyWord": ["/pc", "pc"], "url": "https://www.loliapi.com/acg/pc/", "intro": "二次元电脑图" }, { "type": "image", "keyWord": ["/pe", "pe"], "url": "https://www.loliapi.com/acg/pe/", "intro": "二次元手机图" }, { "type": "image", "keyWord": ["/tx", "tx", "头像"], "url": "https://www.loliapi.com/acg/pp/", "intro": "二次元头像" } ] }
使用socks代理
java -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=10810 -jar tgst-2.0-SNAPSHOT-jar-with-dependencies.jar
PS E:\Codes\tgsetu-master\target> java -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=10810 -jar tgst-2.0-SNAPSHOT-jar-with-dependencies.jar 错误: 找不到或无法加载主类 .0.0.1 原因: java.lang.ClassNotFoundException: /0/0/1 PS E:\Codes\tgsetu-master\target>
使用cmd运行,不要使用powershell
E:\Codes\tgsetu-master\target>java -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=10810 -jar tgst-2.0-SNAPSHOT-jar-with-dependencies.jar 随机色图 for telegram! MESSAGETYPE_MAP: {tx=5, bg=2, /setu=1, hentai=1, 头像=5, 来张色图=1, 色图=1, 来点涩图=1, 来张涩图=1, /pc=3, /pe=4, /hentai=1, /帮助=0, setu=1, start=0, /start=0, 帮助=0, help=0, pc=3, /tx=5, /bg=2, pe=4, /help=0, 来点色图=1, 涩图=1, 二次元=2} CONFIG json: {"tgBotName":"setuPussy_bot","tgBotToken":"6885349535:AAGvjmErrmzkQD88xEgp95Jld2oEcZvdpCM","message":[{"type":"help","keyWord":["help","/help","start","/start","帮助","/帮助"],"intro":"色图机器人 for telegram, 仓库地址: https://github.com/xmexg/tgsetu"},{"type":"image","keyWord":["/hentai","hentai","/setu","setu","色图","涩图","来点色图","来点涩图","来张色图","来张涩图"],"url":"https://moe.jitsu.top/r18","intro":"R18图"},{"type":"image","keyWord":["/bg","bg","二 次元"],"url":"https://www.loliapi.com/bg/","intro":"随机二次元图"},{"type":"image","keyWord":["/pc","pc"],"url":"https://www.loliapi.com/acg/pc/","intro":"二次元电脑图"},{"type":"image","keyWord":["/pe","pe"],"url":"https://www.loliapi.com/acg/pe/","intro":"二次元手机图"},{"type":"image","keyWord":["/tx","tx","头像"],"url":"https://www.loliapi.com/acg/pp/","intro":"二次元头像"}]} SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details. 4月 05, 2024 6:16:12 下午 org.apache.http.impl.execchain.RetryExec execute 信息: I/O exception (java.net.SocketException) caught when processing request to {s}->https://api.telegram.org:443: Can't connect to SOCKS proxy:Connection refused: no further information 4月 05, 2024 6:16:12 下午 org.apache.http.impl.execchain.RetryExec execute 信息: Retrying request to {s}->https://api.telegram.org:443 4月 05, 2024 6:16:12 下午 org.apache.http.impl.execchain.RetryExec execute 信息: I/O exception (java.net.SocketException) caught when processing request to {s}->https://api.telegram.org:443: Can't connect to SOCKS proxy:Connection refused: no further information 4月 05, 2024 6:16:12 下午 org.apache.http.impl.execchain.RetryExec execute 信息: Retrying request to {s}->https://api.telegram.org:443 4月 05, 2024 6:16:12 下午 org.apache.http.impl.execchain.RetryExec execute 信息: I/O exception (java.net.SocketException) caught when processing request to {s}->https://api.telegram.org:443: Can't connect to SOCKS proxy:Connection refused: no further information 4月 05, 2024 6:16:12 下午 org.apache.http.impl.execchain.RetryExec execute 信息: Retrying request to {s}->https://api.telegram.org:443 Exception in thread "main" java.lang.RuntimeException: Error removing old webhook at MainKt.start(Main.kt:46) at MainKt.main(Main.kt:20) at MainKt.main(Main.kt) Caused by: Error removing old webhook at org.telegram.telegrambots.util.WebhookUtils.clearWebhook(WebhookUtils.java:113) at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:41) at org.telegram.telegrambots.meta.TelegramBotsApi.registerBot(TelegramBotsApi.java:65) at MainKt.start(Main.kt:44) ... 2 more Caused by: org.telegram.telegrambots.meta.exceptions.TelegramApiException: Unable to execute deleteWebhook method at org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:1117) at org.telegram.telegrambots.meta.bots.AbsSender.execute(AbsSender.java:64) at org.telegram.telegrambots.util.WebhookUtils.clearWebhook(WebhookUtils.java:108) ... 5 more Caused by: java.net.SocketException: Can't connect to SOCKS proxy:Connection refused: no further information at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:359) at java.base/java.net.Socket.connect(Socket.java:633) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:368) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.telegram.telegrambots.bots.DefaultAbsSender.sendHttpPostRequest(DefaultAbsSender.java:1149) at org.telegram.telegrambots.bots.DefaultAbsSender.sendMethodRequest(DefaultAbsSender.java:1145) at org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:1114) ... 7 more
E:\Codes\tgsetu-master\target>java -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPost=20171 -jar tgst-2.0-SNAPSHOT-jar-with-dependencies.jar 随机色图 for telegram! MESSAGETYPE_MAP: {tx=5, bg=2, /setu=1, hentai=1, 头像=5, 来张色图=1, 色图=1, 来点涩图=1, 来张涩图=1, /pc=3, /pe=4, /hentai=1, /帮助=0, setu=1, start=0, /start=0, 帮助=0, help=0, pc=3, /tx=5, /bg=2, pe=4, /help=0, 来点色图=1, 涩图=1, 二次元=2} CONFIG json: {"tgBotName":"setuPussy_bot","tgBotToken":"6885349535:AAGvjmErrmzkQD88xEgp95Jld2oEcZvdpCM","message":[{"type":"help","keyWord":["help","/help","start","/start","帮助","/帮助"],"intro":"色图机器人 for telegram, 仓库地址: https://github.com/xmexg/tgsetu"},{"type":"image","keyWord":["/hentai","hentai","/setu","setu","色图","涩图","来点色图","来点涩图","来张色图","来张涩图"],"url":"https://moe.jitsu.top/r18","intro":"R18图"},{"type":"image","keyWord":["/bg","bg","二 次元"],"url":"https://www.loliapi.com/bg/","intro":"随机二次元图"},{"type":"image","keyWord":["/pc","pc"],"url":"https://www.loliapi.com/acg/pc/","intro":"二次元电脑图"},{"type":"image","keyWord":["/pe","pe"],"url":"https://www.loliapi.com/acg/pe/","intro":"二次元手机图"},{"type":"image","keyWord":["/tx","tx","头像"],"url":"https://www.loliapi.com/acg/pp/","intro":"二次元头像"}]} SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details. Exception in thread "main" java.lang.RuntimeException: Error removing old webhook at MainKt.start(Main.kt:46) at MainKt.main(Main.kt:20) at MainKt.main(Main.kt) Caused by: Error removing old webhook at org.telegram.telegrambots.util.WebhookUtils.clearWebhook(WebhookUtils.java:113) at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:41) at org.telegram.telegrambots.meta.TelegramBotsApi.registerBot(TelegramBotsApi.java:65) at MainKt.start(Main.kt:44) ... 2 more Caused by: org.telegram.telegrambots.meta.exceptions.TelegramApiException: Unable to execute deleteWebhook method at org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:1117) at org.telegram.telegrambots.meta.bots.AbsSender.execute(AbsSender.java:64) at org.telegram.telegrambots.util.WebhookUtils.clearWebhook(WebhookUtils.java:108) ... 5 more Caused by: org.apache.http.conn.HttpHostConnectException: Connect to api.telegram.org:443 [api.telegram.org/199.96.59.19] failed: Connection timed out: no further information at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.telegram.telegrambots.bots.DefaultAbsSender.sendHttpPostRequest(DefaultAbsSender.java:1149) at org.telegram.telegrambots.bots.DefaultAbsSender.sendMethodRequest(DefaultAbsSender.java:1145) at org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:1114) ... 7 more Caused by: java.net.ConnectException: Connection timed out: no further information at java.base/sun.nio.ch.Net.pollConnect(Native Method) at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:554) at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:602) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) at java.base/java.net.Socket.connect(Socket.java:633) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:368) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) ... 18 more
http代理无法连接,需要使用socks代理。
你本地的socks代理端口不是10810,你需要看看你的代理软件设置的socks端口
java -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=10810 -jar tgst-2.0-SNAPSHOT-jar-with-dependencies.jar
这个嘛?
这个
SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details. Exception in thread "main" java.lang.RuntimeException: Error removing old webhook at MainKt.start(Main.kt:46) at MainKt.main(Main.kt:20) at MainKt.main(Main.kt) Caused by: Error removing old webhook at org.telegram.telegrambots.util.WebhookUtils.clearWebhook(WebhookUtils.java:113) at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:41) at org.telegram.telegrambots.meta.TelegramBotsApi.registerBot(TelegramBotsApi.java:65) at MainKt.start(Main.kt:44) ... 2 more Caused by: org.telegram.telegrambots.meta.exceptions.TelegramApiException: Unable to execute deleteWebhook method at org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:1117) at org.telegram.telegrambots.meta.bots.AbsSender.execute(AbsSender.java:64) at org.telegram.telegrambots.util.WebhookUtils.clearWebhook(WebhookUtils.java:108) ... 5 more Caused by: org.apache.http.conn.HttpHostConnectException: Connect to api.telegram.org:443 [api.telegram.org/108.160.169.179] failed: Connection timed out: no further information at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.telegram.telegrambots.bots.DefaultAbsSender.sendHttpPostRequest(DefaultAbsSender.java:1149) at org.telegram.telegrambots.bots.DefaultAbsSender.sendMethodRequest(DefaultAbsSender.java:1145) at org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:1114) ... 7 more Caused by: java.net.ConnectException: Connection timed out: no further information at java.base/sun.nio.ch.Net.pollConnect(Native Method) at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:554) at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:602) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) at java.base/java.net.Socket.connect(Socket.java:633) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:368) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) ... 18 more