diff --git a/.env.sample b/.env.sample index 524c060..b37c2e8 100644 --- a/.env.sample +++ b/.env.sample @@ -5,7 +5,6 @@ CRYPTO_NOTIFY_SATANG_API_SECRET="" CRYPTO_NOTIFY_SATANG_API_USER_ID="" CRYPTO_NOTIFY_TELEGRAM_BOT_TOKEN="" CRYPTO_NOTIFY_TELEGRAM_CHAT_ID="" -CRYPTO_NOTIFY_LINE_NOTIFY_TOKEN="" CRYPTO_NOTIFY_NOTIFY_CRON="0 0 */3 * * ? *" # optional CRYPTO_NOTIFY_HEALTHCHECK_CRON="0 */1 * * * ? *" # optional CRYPTO_NOTIFY_ETHERSCAN_API_KEY="" # optional diff --git a/README.md b/README.md index 66e1fb5..c1b1849 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # crypto-notify -Notify your current cryptocurrency balance from Satang Pro via Line Notify or Telegram. THB currency +Notify your current cryptocurrency balance from Satang Pro via Telegram. THB currency ## Supported Source diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 743a736..a50ff53 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -9,9 +9,6 @@ satang { apiSecret = ${?CRYPTO_NOTIFY_SATANG_API_SECRET} userId = ${?CRYPTO_NOTIFY_SATANG_API_USER_ID} } -line { - lineNotifyToken = ${?CRYPTO_NOTIFY_LINE_NOTIFY_TOKEN} -} telegram { botToken = ${?CRYPTO_NOTIFY_TELEGRAM_BOT_TOKEN} chatId = ${?CRYPTO_NOTIFY_TELEGRAM_CHAT_ID} diff --git a/src/main/scala/commons/Configuration.scala b/src/main/scala/commons/Configuration.scala index 48b7d4e..ad77929 100644 --- a/src/main/scala/commons/Configuration.scala +++ b/src/main/scala/commons/Configuration.scala @@ -7,7 +7,6 @@ import scala.util.{Success, Try} trait Configuration { lazy val appConfig: AppConfig - lazy val lineConfig: Option[LineConfig] lazy val telegramConfig: Option[TelegramConfig] lazy val satangConfig: SatangConfig lazy val akkaConfig: AkkaConfig @@ -25,7 +24,6 @@ class ConfigurationImpl extends Configuration { ConfigFactory.load("application.local").withFallback(baseConfig) } private val appSection = conf.getConfig("app") - private val lineSection = conf.getConfig("line") private val satangSection = conf.getConfig("satang") private val akkaSection = conf.getConfig("akka") private val etherScanSection = conf.getConfig("etherScan") @@ -40,14 +38,6 @@ class ConfigurationImpl extends Configuration { appSection.getBoolean("useScheduler"), appSection.getString("apiKey") ) - lazy val lineConfig: Option[LineConfig] = Try( - LineConfig( - lineSection.getString("lineNotifyToken") - ) - ) match { - case Success(v) => Some(v) - case _ => None - } lazy val satangConfig: SatangConfig = SatangConfig( satangSection.getString("apiKey"), satangSection.getString("apiSecret"), diff --git a/src/main/scala/commons/Constant.scala b/src/main/scala/commons/Constant.scala index 214bdc6..ca12f06 100644 --- a/src/main/scala/commons/Constant.scala +++ b/src/main/scala/commons/Constant.scala @@ -13,7 +13,6 @@ object Constant { val terraUrl = "https://terra-classic-lcd.publicnode.com" val twoPointOTerraUrl = "https://terra-lcd.publicnode.com" val makerelUrl = "https://api.mackerelio.com" - val lineNotifyUrl = "https://notify-api.line.me/api/notify" val telegramUrl = "https://api.telegram.org" val blockStreamUrl = "https://blockstream.info/api" @@ -23,5 +22,5 @@ object Constant { case HmacSHA512, HmacSHA256 enum MessageProvider: - case Line, Telegram + case Telegram } diff --git a/src/main/scala/models/configuration/LineConfig.scala b/src/main/scala/models/configuration/LineConfig.scala deleted file mode 100644 index 03f5eff..0000000 --- a/src/main/scala/models/configuration/LineConfig.scala +++ /dev/null @@ -1,3 +0,0 @@ -package models.configuration - -final case class LineConfig(lineNotifyToken: String) diff --git a/src/main/scala/models/line/LineResponse.scala b/src/main/scala/models/line/LineResponse.scala deleted file mode 100644 index bb3900a..0000000 --- a/src/main/scala/models/line/LineResponse.scala +++ /dev/null @@ -1,10 +0,0 @@ -package models.line - -import io.circe.* -import io.circe.generic.semiauto.* - -case class LineResponse(status: Int, message: String) -object LineResponse { - given Encoder[LineResponse] = deriveEncoder[LineResponse] - given Decoder[LineResponse] = deriveDecoder[LineResponse] -} diff --git a/src/main/scala/services/notification/LineService.scala b/src/main/scala/services/notification/LineService.scala deleted file mode 100644 index 4a41d61..0000000 --- a/src/main/scala/services/notification/LineService.scala +++ /dev/null @@ -1,38 +0,0 @@ -package services.notification - -import akka.actor.typed.ActorSystem -import com.typesafe.scalalogging.LazyLogging -import commons.* -import commons.Constant.MessageProvider.Line -import models.line.LineResponse - -import scala.concurrent.{ExecutionContext, Future} - -trait LineService extends NotificationService { - def notify(message: String): Future[Boolean] -} - -class LineServiceImpl(using httpClient: HttpClient, configuration: Configuration)(using - system: ActorSystem[Nothing], - context: ExecutionContext -) extends LineService - with LocalLogger { - override def notify(message: String): Future[Boolean] = { - val response = httpClient.postFormData[LineResponse]( - Constant.lineNotifyUrl, - Map("message" -> message), - Map( - "Authorization" -> s"Bearer ${configuration.lineConfig.map(_.lineNotifyToken).getOrElse("")}" - ) - ) - - response.map { - case Left(err) => - logger.error(s"Line notify unexpected error, $err") - false - case Right(_) => true - } - } - - override def getProvider: Constant.MessageProvider = Line -}