Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将电报Bot(在Kotlin中)部署到云服务_Kotlin_Deployment_Bots_Telegram_Telegram Bot - Fatal编程技术网

将电报Bot(在Kotlin中)部署到云服务

将电报Bot(在Kotlin中)部署到云服务,kotlin,deployment,bots,telegram,telegram-bot,Kotlin,Deployment,Bots,Telegram,Telegram Bot,我开始使用Kotlin编写一个电报机器人,并使用以下API: 我在intellijidea中有一个项目,一切都很好:当我在本地运行代码时,程序正在轮询以侦听我的请求。此外,在电报客户端,机器人的响应非常平滑 这是GitHub上提供的示例 Main.kt fun main() { val bot = bot { token = "YOUR_API_KEY" dispatch { command("sta

我开始使用
Kotlin
编写一个电报机器人,并使用以下API:

我在
intellijidea
中有一个项目,一切都很好:当我在本地运行代码时,程序正在轮询以侦听我的请求。此外,在电报客户端,机器人的响应非常平滑

这是GitHub上提供的示例

Main.kt

fun main() {
    val bot = bot {
        token = "YOUR_API_KEY"
        dispatch {
            command("start") {
                val result = bot.sendMessage(chatId = ChatId.fromId(message.chat.id), text = "Hi there!")
                result.fold({
                    // do something here with the response
                },{
                    // do something with the error 
                })
            }
        }
    }
    bot.startPolling()
}
如何将代码部署到云服务器并保持其运行?我应该在亚马逊AWS微软Azure谷歌云中选择哪家提供商来轻松实现我的目标(主要用于测试目的,所以只提供免费计划)


阅读其他问题,我发现了仅使用Python的解决方案……我可以使用相同的方法吗?

常见的解决方案是将应用程序包装在Docker容器中,然后部署它。请参阅如何将Docker容器部署到ECS