-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 📇 Function & Mechanisms - add for /encrypt - add urlencode / urldecode sub-command: they process text input only - add alias /enc - add for InlineBilibiliShare - add b23.tv share-link parse - add b23.tv video link parse ## 🔩 for self-hosted/developer - cha EventListener use EventEnv instead of Update - new LogLevel NOTICE(notice) and ATTION(attention) - with new formatter
- Loading branch information
Showing
35 changed files
with
603 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
rootProject.name = 'Coeur Morny Cono' | ||
rootProject.name = "Coeur Morny Cono" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/scala/cc/sukazyo/cono/morny/bot/api/EventEnv.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cc.sukazyo.cono.morny.bot.api | ||
|
||
import com.pengrad.telegrambot.model.Update | ||
|
||
import scala.collection.mutable | ||
|
||
class EventEnv ( | ||
|
||
val update: Update | ||
|
||
) { | ||
|
||
private var _isOk: Int = 0 | ||
private val variables: mutable.HashMap[Class[?], Any] = mutable.HashMap.empty | ||
|
||
def isEventOk: Boolean = _isOk > 0 | ||
|
||
//noinspection UnitMethodIsParameterless | ||
def setEventOk: Unit = | ||
_isOk = _isOk + 1 | ||
|
||
def provide (i: Any): Unit = | ||
variables += (i.getClass -> i) | ||
|
||
def consume [T] (t: Class[T]) (consumer: T => Unit): ConsumeResult = { | ||
variables get t match | ||
case Some(i) => consumer(i.asInstanceOf[T]); ConsumeResult(true) | ||
case None => ConsumeResult(false) | ||
} | ||
|
||
class ConsumeResult (success: Boolean) { | ||
def onfail (processor: => Unit): Unit = { | ||
if !success then processor | ||
} | ||
} | ||
|
||
} |
30 changes: 14 additions & 16 deletions
30
src/main/scala/cc/sukazyo/cono/morny/bot/api/EventListener.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
package cc.sukazyo.cono.morny.bot.api | ||
|
||
import com.pengrad.telegrambot.model.Update | ||
|
||
trait EventListener () { | ||
|
||
def onMessage (using Update): Boolean = false | ||
def onEditedMessage (using Update): Boolean = false | ||
def onChannelPost (using Update): Boolean = false | ||
def onEditedChannelPost (using Update): Boolean = false | ||
def onInlineQuery (using Update): Boolean = false | ||
def onChosenInlineResult (using Update): Boolean = false | ||
def onCallbackQuery (using Update): Boolean = false | ||
def onShippingQuery (using Update): Boolean = false | ||
def onPreCheckoutQuery (using Update): Boolean = false | ||
def onPoll (using Update): Boolean = false | ||
def onPollAnswer (using Update): Boolean = false | ||
def onMyChatMemberUpdated (using Update): Boolean = false | ||
def onChatMemberUpdated (using Update): Boolean = false | ||
def onChatJoinRequest (using Update): Boolean = false | ||
def onMessage (using EventEnv): Unit = {} | ||
def onEditedMessage (using EventEnv): Unit = {} | ||
def onChannelPost (using EventEnv): Unit = {} | ||
def onEditedChannelPost (using EventEnv): Unit = {} | ||
def onInlineQuery (using EventEnv): Unit = {} | ||
def onChosenInlineResult (using EventEnv): Unit = {} | ||
def onCallbackQuery (using EventEnv): Unit = {} | ||
def onShippingQuery (using EventEnv): Unit = {} | ||
def onPreCheckoutQuery (using EventEnv): Unit = {} | ||
def onPoll (using EventEnv): Unit = {} | ||
def onPollAnswer (using EventEnv): Unit = {} | ||
def onMyChatMemberUpdated (using EventEnv): Unit = {} | ||
def onChatMemberUpdated (using EventEnv): Unit = {} | ||
def onChatJoinRequest (using EventEnv): Unit = {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.