简体   繁体   English

Talend 开放工作室中的 Telegram 机器人

[英]Telegram bot in Talend open studio

Maybe someone came across this problem.也许有人遇到过这个问题。 I try run my jar with telegram bot on talend studio, but my job just stop after start.我尝试在 talend studio 上使用电报机器人运行我的 jar,但我的工作在启动后就停止了。 If i run job without Talend studio, just java -jar TelegramBot.jar , or I run in intellij idea, it's worked perfect.如果我在没有 Talend studio 的情况下运行工作,只需java -jar TelegramBot.jar ,或者我在 intellij idea 中运行,它就完美了。

I create routines and export my jar file in tLibraryLoad and in tJava call main method.我创建例程并在 tLibraryLoad 和 tJava 调用 main 方法中导出我的 jar 文件。


import org.telegram.telegrambots.ApiContextInitializer;
import org.telegram.telegrambots.bots.DefaultBotOptions;
import org.telegram.telegrambots.meta.ApiContext;
import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;

public class StartBot {

    public static void start() {

        ApiContextInitializer.init();

        DefaultBotOptions botOptions = ApiContext.getInstance(DefaultBotOptions.class);

        FMTelegramBOTTest bot = new FMTelegramBOTTest(botOptions);

        TelegramBotsApi apiBots = new TelegramBotsApi();

        try {
            apiBots.registerBot(bot);
        } catch (TelegramApiRequestException e) {
            e.printStackTrace();
        }
        System.out.println("END");
    }


}

Work only this method仅使用此方法

logs:日志:

[statistics] connecting to socket on port 2607

[statistics] connected

END

[statistics] disconnected

在此处输入图像描述

If your are using windows operating system, please use below command to call the jar file directly, no need to use tLibraryLoad component.如果您使用的是 windows 操作系统,请使用以下命令直接调用 jar 文件,无需使用 tLibraryLoad 组件。 This component can be used in case you are accessing any method from the jar.如果您从 jar 访问任何方法,则可以使用此组件。 If you just want to execute the jar you can use below,如果您只想执行 jar 您可以在下面使用,

Runtime.getRuntime().exec("cmd /c start path/to/jar/file_name.jar");

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM