<commit_before>package sectery

import org.slf4j.LoggerFactory
import zio.App
import zio.Clock
import zio.ExitCode
import zio.Fiber
import zio.RIO
import zio.Schedule
import zio.URIO
import zio.ZEnv
import zio.ZIO
import zio.durationInt

object Sectery extends App:

  /** This is the main entry point for the application. Set your env
    * vars, then run this main method.
    *
    *   1. Spin up the message queues using [[Bot]] as the [[Sender]]
    *   1. Asynchronously process received messages through
    *      [[Bot.receive]]
    *   1. Connect to IRC
    */
  def run(args: List[String]): URIO[ZEnv, ExitCode] =

    val k1: RIO[Producer.Env, ExitCode] =
      for
        (inbox, outbox, loopFiber) <- MessageQueues.loop
        bot = Bot(
          (m: Rx) => unsafeRunAsync(inbox.offer(m)),
          (m: Tx) => unsafeRunAsync(outbox.offer(m))
        )
        _ <- ZIO.attemptBlocking(bot.startBot())
        outboxFiber <- (
          for
            m <- outbox.take
            _ <- ZIO.attempt {
              bot.sendIRC.message(m.channel, m.message)
            }
          yield ()
        ).repeat(Schedule.spaced(250.milliseconds)).fork
        _ <- Fiber.joinAll(List(loopFiber, outboxFiber))
      yield ExitCode.failure // should never exit

    val k0: URIO[Producer.Env, ExitCode] =
      k1
        .catchAll { e =>
          LoggerFactory
            .getLogger(this.getClass())
            .error("caught exception", e)
          ZIO.succeed(ExitCode.failure)
        }

    val k: URIO[ZEnv, ExitCode] =<commit_msg>Fork the blocking `startBot()` effect (#254)<commit_after>package sectery

import org.slf4j.LoggerFactory
import zio.App
import zio.Clock
import zio.ExitCode
import zio.Fiber
import zio.RIO
import zio.Schedule
import zio.URIO
import zio.ZEnv
import zio.ZIO
import zio.durationInt

object Sectery extends App:

  /** This is the main entry point for the application. Set your env
    * vars, then run this main method.
    *
    *   1. Spin up the message queues using [[Bot]] as the [[Sender]]
    *   1. Asynchronously process received messages through
    *      [[Bot.receive]]
    *   1. Connect to IRC
    */
  def run(args: List[String]): URIO[ZEnv, ExitCode] =

    val k1: RIO[Producer.Env, ExitCode] =
      for
        (inbox, outbox, loopFiber) <- MessageQueues.loop
        bot = Bot(
          (m: Rx) => unsafeRunAsync(inbox.offer(m)),
          (m: Tx) => unsafeRunAsync(outbox.offer(m))
        )
        botFiber <- ZIO.attemptBlocking(bot.startBot()).fork
        outboxFiber <- (
          for
            m <- outbox.take
            _ <- ZIO.attempt {
              bot.sendIRC.message(m.channel, m.message)
            }
          yield ()
        ).repeat(Schedule.spaced(250.milliseconds)).fork
        _ <- Fiber.joinAll(List(loopFiber, outboxFiber, botFiber))
      yield ExitCode.failure // should never exit

    val k0: URIO[Producer.Env, ExitCode] =
      k1
        .catchAll { e =>
          LoggerFactory
            .getLogger(this.getClass())
            .error("caught exception", e)
          ZIO.succeed(ExitCode.failure)
        }

    val k: URIO[ZEnv, ExitCode] =
{'fraction_non_alphanumeric': 0.11251980982567353, 'fraction_numerical': 0.007290015847860539, 'mean_word_length': 2.1686746987951806, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '957878', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1007, 'n_words': 255}