Skip to content

Commit

Permalink
Updated code examples (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
augustjune authored May 4, 2022
1 parent c6a61e4 commit 6c805a1
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 52 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sbt dependency:
libraryDependencies += "org.augustjune" %% "canoe" % "<version>"
```
You can find the latest version in [releases](https://github.com/augustjune/canoe/releases) tab
or by clicking on the maven-central badge. The library is available for Scala 2.12, 2.13, and Scala.js.
or by clicking on the maven-central badge. The library is available for Scala 2.12, 2.13, Scala 3 and Scala.js.

Imports:
```scala
Expand All @@ -40,14 +40,15 @@ More samples can be found [here](https://github.com/augustjune/canoe/tree/master
```scala
import canoe.api._
import canoe.syntax._
import cats.effect.ConcurrentEffect
import cats.effect.Async
import fs2.Stream

def app[F[_]: ConcurrentEffect]: F[Unit] =
def app[F[_]: Async]: F[Unit] =
Stream
.resource(TelegramClient.global[F](token))
.flatMap { implicit client => Bot.polling[F].follow(greetings) }
.compile.drain
.resource(TelegramClient[F](token))
.flatMap(implicit client => Bot.polling[F].follow(greetings))
.compile
.drain

def greetings[F[_]: TelegramClient]: Scenario[F, Unit] =
for {
Expand Down
7 changes: 2 additions & 5 deletions examples/src/main/scala/samples/DiceExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ import canoe.syntax._
import cats.effect.{IO, IOApp}
import fs2.Stream

/**
* Example of echos bot that will send both possible dice messages in response
/** Example of echos bot that will send both possible dice messages in response
*/
object DiceExample extends IOApp.Simple {
val token: String = "<your telegram token>"

def run: IO[Unit] =
Stream
.resource(TelegramClient[IO](token))
.flatMap { implicit client =>
Bot.polling[IO].follow(echos)
}
.flatMap(implicit client => Bot.polling[IO].follow(echos))
.compile
.drain

Expand Down
4 changes: 1 addition & 3 deletions examples/src/main/scala/samples/ErrorHandling.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ object ErrorHandling extends IOApp.Simple {
def run: IO[Unit] =
Stream
.resource(TelegramClient[IO](token))
.flatMap { implicit client =>
Bot.polling[IO].follow(order(amazon))
}
.flatMap(implicit client => Bot.polling[IO].follow(order(amazon)))
.compile
.drain

Expand Down
4 changes: 1 addition & 3 deletions examples/src/main/scala/samples/Recursive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ object Recursive extends IOApp.Simple {
def run: IO[Unit] =
Stream
.resource(TelegramClient[IO](token))
.flatMap { implicit client =>
Bot.polling[IO].follow(learnNaturals)
}
.flatMap(implicit client => Bot.polling[IO].follow(learnNaturals))
.compile
.drain

Expand Down
4 changes: 1 addition & 3 deletions examples/src/main/scala/samples/Registration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ object Registration extends IOApp.Simple {
def run: IO[Unit] =
Stream
.resource(TelegramClient[IO](token))
.flatMap { implicit client =>
Bot.polling[IO].follow(signup(service))
}
.flatMap(implicit client => Bot.polling[IO].follow(signup(service)))
.compile
.drain

Expand Down
25 changes: 0 additions & 25 deletions examples/src/main/scala/samples/Run.scala

This file was deleted.

4 changes: 1 addition & 3 deletions examples/src/main/scala/samples/SemanticBlocking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ object SemanticBlocking extends IOApp.Simple {
def run: IO[Unit] =
Stream
.resource(TelegramClient[IO](token))
.flatMap { implicit client =>
Bot.polling[IO].follow(count)
}
.flatMap(implicit client => Bot.polling[IO].follow(count))
.compile
.drain

Expand Down
4 changes: 1 addition & 3 deletions examples/src/main/scala/samples/Webhook.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ object Webhook extends IOApp.Simple {
def run: IO[Unit] =
Stream
.resource(TelegramClient[IO](token))
.flatMap { implicit client =>
Stream.resource(Bot.hook[IO](url)).flatMap(_.follow(greetings))
}
.flatMap(implicit client => Stream.resource(Bot.hook[IO](url)).flatMap(_.follow(greetings)))
.compile
.drain

Expand Down
1 change: 0 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0")

0 comments on commit 6c805a1

Please sign in to comment.