Changed interface to lenovo.
This commit is contained in:
@@ -40,9 +40,9 @@ class TelegramBotServer(botId: String, port: Int, httpsContext: Option[HttpsConn
|
||||
|
||||
private val http: HttpExt = Http()
|
||||
private val hookId = UUID.randomUUID().toString
|
||||
private val webhookUri = Uri(s"https://xeppaka.eu:$port/$hookId")
|
||||
private val webhookUri = Uri(s"https://xeppaka.eu:88/$hookId")
|
||||
private val bindingFuture = http.bindAndHandle(botRoutes(hookId),
|
||||
"pkcloud",
|
||||
"lenovo",
|
||||
port,
|
||||
connectionContext = httpsContext.getOrElse(http.defaultClientHttpsContext))
|
||||
|
||||
@@ -65,7 +65,7 @@ class TelegramBotServer(botId: String, port: Int, httpsContext: Option[HttpsConn
|
||||
def botRoutes(hookId: String): Route = {
|
||||
path(hookId) {
|
||||
post {
|
||||
entity(as[Update]) { update =>
|
||||
entity(as[Update]) { _ =>
|
||||
handleWith(receivedUpdate)
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ object TelegramBotServer {
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
val httpsContext = createHttpsConnectionContext
|
||||
val tbs = TelegramBotServer(88, Some(createHttpsConnectionContext))
|
||||
val tbs = TelegramBotServer(8443, Some(createHttpsConnectionContext))
|
||||
|
||||
StdIn.readLine()
|
||||
tbs.stop()
|
||||
|
||||
@@ -4,19 +4,14 @@ import akka.actor.typed.scaladsl.Behaviors
|
||||
import akka.actor.typed.{ActorRef, Behavior}
|
||||
|
||||
object ChatActor {
|
||||
|
||||
sealed trait ChatCommand {
|
||||
def replyTo: ActorRef[Response]
|
||||
}
|
||||
|
||||
case class Response(text: String)
|
||||
|
||||
case class Help(replyTo: ActorRef[Response]) extends ChatCommand
|
||||
|
||||
case class Start(replyTo: ActorRef[Response]) extends ChatCommand
|
||||
|
||||
case class MessageReceived(text: String, replyTo: ActorRef[Response]) extends ChatCommand
|
||||
|
||||
case class Stop(replyTo: ActorRef[Response]) extends ChatCommand
|
||||
|
||||
private val started: Behavior[ChatCommand] = Behaviors.receive { (ctx, msg) =>
|
||||
@@ -33,7 +28,7 @@ object ChatActor {
|
||||
case _ =>
|
||||
Behaviors.unhandled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val initial: Behavior[ChatCommand] = Behaviors.receive { (ctx, msg) =>
|
||||
msg match {
|
||||
@@ -44,7 +39,7 @@ object ChatActor {
|
||||
c.replyTo ! Response("Only /start command is supported. Try it...")
|
||||
Behaviors.same
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private def replyHelp(replyTo: ActorRef[Response]): Unit = {
|
||||
replyTo ! Response("No help is provided for such motherfuckers like you! But... ok, send /stop and we are free.")
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package eu.xeppaka.bot1.actors
|
||||
|
||||
import akka.actor.{Actor, ActorLogging, Props}
|
||||
import akka.http.scaladsl.HttpExt
|
||||
import akka.http.scaladsl.model.{ContentTypes, HttpEntity, HttpMethods, HttpRequest}
|
||||
import akka.util.ByteString
|
||||
import eu.xeppaka.bot1.TelegramEntities.SendMessage
|
||||
import eu.xeppaka.bot1.{BotUri, TelegramEntities}
|
||||
|
||||
class UpdateActor2 extends Actor with ActorLogging {
|
||||
import UpdateActor2.ReceivedUpdate
|
||||
|
||||
override def receive: Receive = {
|
||||
case ReceivedUpdate(update) => processUpdate(update)
|
||||
}
|
||||
|
||||
private def processUpdate(update: TelegramEntities.Update) = {
|
||||
log.info(s"Received update: $update")
|
||||
if (update.message.isDefined) {
|
||||
processMessage(update.message.get)
|
||||
}
|
||||
}
|
||||
|
||||
private def processMessage(message: TelegramEntities.Message) = {
|
||||
import io.circe._, io.circe.generic.auto._, io.circe.syntax._
|
||||
|
||||
// log.info("Received message from: {}", message.from)
|
||||
// val sendMessage = SendMessage(message.chat.id, s"Привет, ${message.from.get.first_name}")
|
||||
// val printer = Printer.noSpaces.copy(dropNullValues = true)
|
||||
// val json = printer.pretty(sendMessage.asJson)
|
||||
// val request = HttpRequest(HttpMethods.POST, uri = botUri.sendMessage, entity = HttpEntity.Strict(ContentTypes.`application/json`, ByteString(json)))
|
||||
// http.singleRequest(request)
|
||||
}
|
||||
}
|
||||
|
||||
object UpdateActor2 {
|
||||
|
||||
case class ReceivedUpdate(update: TelegramEntities.Update)
|
||||
|
||||
def props(): Props = Props(new UpdateActor2())
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user