Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Check code format
uses: jrouly/scalafmt-native-action@v4
with:
arguments: "-c .scalafmt.conf --test core akka examples"
arguments: "-c .scalafmt.conf --test core pekko examples"
- name: Compile
run: ./mill '_._[_].compile'
- name: Test
Expand Down
9 changes: 0 additions & 9 deletions akka/src/com/bot4s/telegram/models/AkkaInputFile.scala

This file was deleted.

48 changes: 24 additions & 24 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ object library {
val scalaLogging = "3.9.5"
val logback = "1.5.18"
val scalajHttp = "2.4.2"
val akkaVersion = "2.6.20"
val akkaActor = akkaVersion
val akkaStream = akkaVersion
val akkaHttp = "10.5.2"
val akkaTestkit = akkaVersion
val akkaHttpCors = "1.2.0"
val pekkoVersion = "1.3.0"
val pekkoActor = pekkoVersion
val pekkoStream = pekkoVersion
val pekkoHttp = "1.3.0"
val pekkoTestkit = pekkoVersion
val pekkoHttpCors = pekkoHttp
val hammock = "0.11.3"
val monix = "3.4.1"
val sbtTesting = "1.0"
}

val akkaHttp = mvn"com.typesafe.akka::akka-http::${Version.akkaHttp}"
val akkaHttpTestkit = mvn"com.typesafe.akka::akka-http-testkit::${Version.akkaHttp}"
val akkaTestkit = mvn"com.typesafe.akka::akka-testkit::${Version.akkaTestkit}"
val akkaActor = mvn"com.typesafe.akka::akka-actor::${Version.akkaActor}"
val akkaStream = mvn"com.typesafe.akka::akka-stream::${Version.akkaStream}"
val pekkoHttp = mvn"org.apache.pekko::pekko-http::${Version.pekkoHttp}"
val pekkoHttpTestkit = mvn"org.apache.pekko::pekko-http-testkit::${Version.pekkoHttp}"
val pekkoTestkit = mvn"org.apache.pekko::pekko-testkit::${Version.pekkoTestkit}"
val pekkoActor = mvn"org.apache.pekko::pekko-actor::${Version.pekkoActor}"
val pekkoStream = mvn"org.apache.pekko::pekko-stream::${Version.pekkoStream}"

val asyncHttpClientBackendCats =
mvn"com.softwaremill.sttp.client4::fs2ce2::${Version.sttp}"
Expand All @@ -50,7 +50,7 @@ object library {
val scalajHttp = mvn"org.scalaj::scalaj-http::${Version.scalajHttp}"
val scalaLogging = mvn"com.typesafe.scala-logging::scala-logging::${Version.scalaLogging}"
val scalaMockScalaTest = mvn"org.scalamock::scalamock::${Version.scalaMockScalaTest}"
val akkaHttpCors = mvn"ch.megard::akka-http-cors::${Version.akkaHttpCors}"
val pekkoHttpCors = mvn"org.apache.pekko::pekko-http-cors::${Version.pekkoHttpCors}"
val scalaTest = mvn"org.scalatest::scalatest::${Version.scalaTest}"
val sbtTesting = mvn"org.scala-sbt:test-interface:${Version.sbtTesting}"

Expand Down Expand Up @@ -166,19 +166,19 @@ object core extends Module {

}

object akka extends Module {
object pekko extends Module {

object jvm extends Cross[AkkaModule](ScalaVersions)
trait AkkaModule extends Bot4sTelegramCrossPlatform with Publishable {
object jvm extends Cross[pekkoModule](ScalaVersions)
trait pekkoModule extends Bot4sTelegramCrossPlatform with Publishable {
override val platformSegment: String = "jvm"
override val location: String = "akka"
override def artifactName = "telegram-akka"
override val location: String = "pekko"
override def artifactName = "telegram-pekko"

override def mvnDeps = Task {
super.mvnDeps() ++ Seq(
library.akkaActor,
library.akkaHttp,
library.akkaStream
library.pekkoActor,
library.pekkoHttp,
library.pekkoStream
)
}

Expand All @@ -189,8 +189,8 @@ object akka extends Module {

override def mvnDeps = Task {
super.mvnDeps() ++ Seq(
library.akkaTestkit,
library.akkaHttpTestkit
library.pekkoTestkit,
library.pekkoHttpTestkit
)
}
}
Expand All @@ -216,12 +216,12 @@ object examples extends Module {

override def mvnDeps = Task {
super.mvnDeps() ++ Seq(
library.akkaHttpCors,
library.pekkoHttpCors,
library.sttpOkHttp
) ++ versionDependencies()
}

override def moduleDeps = super.moduleDeps ++ Seq(core.jvm(), akka.jvm())
override def moduleDeps = super.moduleDeps ++ Seq(core.jvm(), pekko.jvm())
}

object catsjvm extends Cross[ExamplesCatsModule](ScalaVersions)
Expand Down
6 changes: 0 additions & 6 deletions examples/src-jvm-2/AkkaExampleBot.scala

This file was deleted.

19 changes: 9 additions & 10 deletions examples/src-jvm-2/GitHubHosted2048Bot.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import akka.http.scaladsl.model.Uri
import akka.http.scaladsl.model.Uri.{ Path, Query }
import akka.http.scaladsl.model.headers.HttpOrigin
import akka.http.scaladsl.server.RouteConcatenation._
import akka.http.scaladsl.server.Route

import ch.megard.akka.http.cors.scaladsl.model.HttpOriginMatcher
import org.apache.pekko.http.scaladsl.model.Uri
import org.apache.pekko.http.scaladsl.model.Uri.{ Path, Query }
import org.apache.pekko.http.scaladsl.model.headers.HttpOrigin
import org.apache.pekko.http.scaladsl.server.RouteConcatenation._
import org.apache.pekko.http.scaladsl.server.Route
import org.apache.pekko.http.cors.scaladsl.settings.CorsSettings
import org.apache.pekko.http.cors.scaladsl.model.HttpOriginMatcher
import org.apache.pekko.http.cors.scaladsl.CorsDirectives._

import cats.instances.future._
import cats.syntax.functor._
import ch.megard.akka.http.cors.scaladsl.CorsDirectives.cors
import ch.megard.akka.http.cors.scaladsl.settings.CorsSettings
import com.bot4s.telegram.api.declarative.{ Callbacks, Commands }
import com.bot4s.telegram.api.{ GameManager, Payload }
import com.bot4s.telegram.future.Polling
Expand Down Expand Up @@ -48,7 +47,7 @@ import scala.concurrent.Future
* @param gameManagerHost Base URL of the game manager.
*/
class GitHubHosted2048Bot(token: String, gameManagerHost: String)
extends AkkaExampleBot(token)
extends PekkoExampleBot(token)
with Polling
with Commands[Future]
with Callbacks[Future]
Expand Down
4 changes: 2 additions & 2 deletions examples/src-jvm-2/LmgtfyBot.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import akka.http.scaladsl.model.Uri
import akka.http.scaladsl.model.Uri.Query
import org.apache.pekko.http.scaladsl.model.Uri
import org.apache.pekko.http.scaladsl.model.Uri.Query
import cats.instances.future._
import cats.syntax.functor._
import com.bot4s.telegram.Implicits._
Expand Down
6 changes: 6 additions & 0 deletions examples/src-jvm-2/PekkoExampleBot.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import com.bot4s.telegram.api.PekkoTelegramBot
import com.bot4s.telegram.clients.PekkoHttpClient

abstract class PekkoExampleBot(val token: String) extends PekkoTelegramBot {
override val client = new PekkoHttpClient(token)
}
6 changes: 3 additions & 3 deletions examples/src-jvm-2/PerChatRequestsBot.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import akka.actor.{ Actor, ActorRef, Props, Terminated }
import org.apache.pekko.actor.{ Actor, ActorRef, Props, Terminated }
import cats.syntax.functor._
import cats.instances.future._
import com.bot4s.telegram.api.declarative.Commands
import com.bot4s.telegram.api.{ ActorBroker, AkkaDefaults }
import com.bot4s.telegram.api.{ ActorBroker, PekkoDefaults }
import com.bot4s.telegram.future.Polling
import com.bot4s.telegram.methods.SendMessage
import com.bot4s.telegram.models.{ Message, Update }

import scala.concurrent.Future

trait PerChatRequests extends ActorBroker with AkkaDefaults {
trait PerChatRequests extends ActorBroker with PekkoDefaults {

override val broker = Some(system.actorOf(Props(new Broker), "broker"))

Expand Down
4 changes: 2 additions & 2 deletions examples/src-jvm-2/PollingWithWebRoutes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.concurrent.Future
* and even serving entire websites.
*/
class PollingWithWebRoutes(token: String)
extends AkkaExampleBot(token)
extends PekkoExampleBot(token)
with Polling
with WebRoutes
with Commands[Future] {
Expand All @@ -24,7 +24,7 @@ class PollingWithWebRoutes(token: String)
reply("Hello").void
}

import akka.http.scaladsl.server.Directives._
import org.apache.pekko.http.scaladsl.server.Directives._

override def routes = pathEndOrSingleSlash {
complete("I'm running...")
Expand Down
14 changes: 7 additions & 7 deletions examples/src-jvm-2/QrCodesBot.scala
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import java.net.URLEncoder

import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{ HttpRequest, Uri }
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.util.ByteString
import org.apache.pekko.http.scaladsl.Http
import org.apache.pekko.http.scaladsl.model.{ HttpRequest, Uri }
import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal
import org.apache.pekko.util.ByteString
import com.bot4s.telegram.api.declarative.Commands
import com.bot4s.telegram.api._
import com.bot4s.telegram.future.Polling
import com.bot4s.telegram.methods._
import com.bot4s.telegram.models.AkkaInputFile
import com.bot4s.telegram.models.PekkoInputFile

import scala.concurrent.Future

/**
* Generates QR codes from text/url.
*/
class QrCodesBot(token: String)
extends AkkaExampleBot(token)
extends PekkoExampleBot(token)
with Polling
with Commands[Future]
with ChatActions[Future] {
Expand All @@ -31,7 +31,7 @@ class QrCodesBot(token: String)
response <- Http().singleRequest(HttpRequest(uri = Uri(url)))
if response.status.isSuccess()
bytes <- Unmarshal(response).to[ByteString]
photo = AkkaInputFile("qrcode.png", bytes)
photo = PekkoInputFile("qrcode.png", bytes)
_ <- uploadingPhoto // Hint the user
_ <- request(SendPhoto(msg.source, photo))
} yield ()
Expand Down
14 changes: 7 additions & 7 deletions examples/src-jvm-2/SelfHosted2048Bot.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import akka.http.scaladsl.model.Uri
import akka.http.scaladsl.model.Uri.{ Path, Query }
import akka.http.scaladsl.server.Directives.{ getFromResourceDirectory, pathPrefix }
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.RouteConcatenation._
import org.apache.pekko.http.scaladsl.model.Uri
import org.apache.pekko.http.scaladsl.model.Uri.{ Path, Query }
import org.apache.pekko.http.scaladsl.server.Directives.{ getFromResourceDirectory, pathPrefix }
import org.apache.pekko.http.scaladsl.server.Route
import org.apache.pekko.http.scaladsl.server.RouteConcatenation._
import cats.instances.future._
import cats.syntax.functor._
import com.bot4s.telegram.api.declarative.{ Callbacks, Commands }
import com.bot4s.telegram.api.{ AkkaDefaults, GameManager, Payload }
import com.bot4s.telegram.api.{ GameManager, Payload, PekkoDefaults }
import com.bot4s.telegram.future.Polling
import com.bot4s.telegram.methods.SendGame

Expand Down Expand Up @@ -35,7 +35,7 @@ import scala.concurrent.Future
class SelfHosted2048Bot(token: String, gameManagerHost: String)
extends ExampleBot(token)
with Polling
with AkkaDefaults
with PekkoDefaults
with Callbacks[Future]
with GameManager
with Commands[Future] {
Expand Down
10 changes: 5 additions & 5 deletions examples/src-jvm-2/SpotifyBot.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import java.net.URLEncoder

import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{ Authorization, BasicHttpCredentials }
import akka.http.scaladsl.unmarshalling.Unmarshal
import org.apache.pekko.http.scaladsl.Http
import org.apache.pekko.http.scaladsl.model._
import org.apache.pekko.http.scaladsl.model.headers.{ Authorization, BasicHttpCredentials }
import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal
import cats.instances.future._
import cats.syntax.functor._
import com.bot4s.telegram.future.Polling
Expand All @@ -22,7 +22,7 @@ import scala.concurrent.Future
* The provided clientId/secret are not guaranteed to work forever.
* See [[https://developer.spotify.com/web-api/authorization-guide/]]
*/
class SpotifyBot(token: String) extends AkkaExampleBot(token) with Polling {
class SpotifyBot(token: String) extends PekkoExampleBot(token) with Polling {

val limit = 10

Expand Down
10 changes: 5 additions & 5 deletions examples/src-jvm-2/VoiceFileBot.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{ HttpRequest, Uri }
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.util.ByteString
import org.apache.pekko.http.scaladsl.Http
import org.apache.pekko.http.scaladsl.model.{ HttpRequest, Uri }
import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal
import org.apache.pekko.util.ByteString
import cats.instances.future._
import cats.syntax.functor._
import com.bot4s.telegram.api.declarative.Commands
Expand All @@ -14,7 +14,7 @@ import scala.util.{ Failure, Success }
/**
* This bot receives voice recordings and outputs the file size.
*/
class VoiceFileBot(token: String) extends AkkaExampleBot(token) with Polling with Commands[Future] {
class VoiceFileBot(token: String) extends PekkoExampleBot(token) with Polling with Commands[Future] {

onMessage { implicit msg =>
using(_.voice) { voice =>
Expand Down
8 changes: 4 additions & 4 deletions examples/src-jvm-2/WebhookBot.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import java.net.URLEncoder

import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{ HttpRequest, Uri }
import akka.http.scaladsl.unmarshalling.Unmarshal
import org.apache.pekko.http.scaladsl.Http
import org.apache.pekko.http.scaladsl.model.{ HttpRequest, Uri }
import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal
import com.bot4s.telegram.api.Webhook
import com.bot4s.telegram.methods._
import com.bot4s.telegram.models.Message
Expand All @@ -13,7 +13,7 @@ import scala.concurrent.Future
* Webhook-backed JS calculator.
* To test Webhooks locally, use an SSH tunnel or ngrok.
*/
class WebhookBot(token: String) extends AkkaExampleBot(token) with Webhook {
class WebhookBot(token: String) extends PekkoExampleBot(token) with Webhook {

val port = 8080
val webhookUrl = "https://88c444ab.ngrok.io"
Expand Down
12 changes: 6 additions & 6 deletions examples/src-jvm-2/WebhookSSLBot.scala
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import java.net.URLEncoder

import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{ HttpRequest, Uri }
import akka.http.scaladsl.unmarshalling.Unmarshal
import org.apache.pekko.http.scaladsl.Http
import org.apache.pekko.http.scaladsl.model.{ HttpRequest, Uri }
import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal
import com.bot4s.telegram.api.Webhook
import com.bot4s.telegram.methods._
import com.bot4s.telegram.models.Message

import scala.concurrent.Future
import com.bot4s.telegram.models.InputFile
import java.io.File
import akka.http.scaladsl.HttpsConnectionContext
import org.apache.pekko.http.scaladsl.HttpsConnectionContext
import java.security.KeyStore
import javax.net.ssl.KeyManagerFactory
import javax.net.ssl.TrustManagerFactory
import javax.net.ssl.SSLContext
import akka.http.scaladsl.ConnectionContext
import org.apache.pekko.http.scaladsl.ConnectionContext
import java.security.SecureRandom

/**
Expand All @@ -34,7 +34,7 @@ import java.security.SecureRandom
*
* Replace XXXX with your bot's key
*/
class WebhookSSLBot(token: String) extends AkkaExampleBot(token) with Webhook {
class WebhookSSLBot(token: String) extends PekkoExampleBot(token) with Webhook {

val port = 8080
val webhookUrl = "https://domain.extension:8443"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.bot4s.telegram.api

import akka.actor.ActorRef
import org.apache.pekko.actor.ActorRef
import com.bot4s.telegram.models.{ Update, User }

import scala.concurrent.Future
Expand Down
Loading