-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
/gdpr and /privacy command handlers stubs
- Loading branch information
Showing
7 changed files
with
130 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
...in/kotlin/me/madhead/tyzenhaus/core/telegram/updates/policy/GDPRCommandUpdateProcessor.kt
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,54 @@ | ||
package me.madhead.tyzenhaus.core.telegram.updates.policy | ||
|
||
import dev.inmo.tgbotapi.bot.RequestsExecutor | ||
import dev.inmo.tgbotapi.extensions.api.send.sendMessage | ||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton | ||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup | ||
import dev.inmo.tgbotapi.types.message.MarkdownV2 | ||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage | ||
import dev.inmo.tgbotapi.types.message.content.TextContent | ||
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource | ||
import dev.inmo.tgbotapi.types.update.MessageUpdate | ||
import dev.inmo.tgbotapi.types.update.abstracts.Update | ||
import me.madhead.tyzenhaus.core.telegram.updates.UpdateProcessor | ||
import me.madhead.tyzenhaus.core.telegram.updates.UpdateReaction | ||
import me.madhead.tyzenhaus.core.telegram.updates.groupId | ||
import me.madhead.tyzenhaus.core.telegram.updates.lang.LangCallbackQueryUpdateProcessor.Companion.CALLBACK_PREFIX | ||
import me.madhead.tyzenhaus.core.telegram.updates.policy.PrivacyCommandUpdateProcessor.Companion | ||
import me.madhead.tyzenhaus.core.telegram.updates.userId | ||
import me.madhead.tyzenhaus.entity.dialog.state.DialogState | ||
import me.madhead.tyzenhaus.entity.group.config.GroupConfig | ||
import me.madhead.tyzenhaus.i18.I18N | ||
import org.apache.logging.log4j.LogManager | ||
|
||
/** | ||
* /GDPR command handler. | ||
*/ | ||
class GDPRCommandUpdateProcessor( | ||
private val requestsExecutor: RequestsExecutor, | ||
) : UpdateProcessor { | ||
companion object { | ||
private val logger = LogManager.getLogger(GDPRCommandUpdateProcessor::class.java)!! | ||
} | ||
|
||
@Suppress("DuplicatedCode") | ||
override suspend fun process(update: Update, groupConfig: GroupConfig?, dialogState: DialogState?): UpdateReaction? { | ||
@Suppress("NAME_SHADOWING") | ||
val update = update as? MessageUpdate ?: return null | ||
val message = update.data as? CommonMessage<*> ?: return null | ||
val content = (message as? CommonMessage<*>)?.content as? TextContent ?: return null | ||
|
||
return if (content.textSources.any { "gdpr" == (it as? BotCommandTextSource)?.command }) { | ||
{ | ||
logger.debug("{} asked for GDPR in {}", update.userId, update.groupId) | ||
|
||
requestsExecutor.sendMessage( | ||
chatId = update.data.chat.id, | ||
text = I18N(groupConfig?.language)["gdpr"], | ||
parseMode = MarkdownV2, | ||
disableWebPagePreview = true, | ||
) | ||
} | ||
} else null | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...kotlin/me/madhead/tyzenhaus/core/telegram/updates/policy/PrivacyCommandUpdateProcessor.kt
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,55 @@ | ||
package me.madhead.tyzenhaus.core.telegram.updates.policy | ||
|
||
import dev.inmo.tgbotapi.bot.RequestsExecutor | ||
import dev.inmo.tgbotapi.extensions.api.send.sendMessage | ||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton | ||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup | ||
import dev.inmo.tgbotapi.types.message.MarkdownV2 | ||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage | ||
import dev.inmo.tgbotapi.types.message.content.TextContent | ||
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource | ||
import dev.inmo.tgbotapi.types.update.MessageUpdate | ||
import dev.inmo.tgbotapi.types.update.abstracts.Update | ||
import me.madhead.tyzenhaus.core.telegram.updates.UpdateProcessor | ||
import me.madhead.tyzenhaus.core.telegram.updates.UpdateReaction | ||
import me.madhead.tyzenhaus.core.telegram.updates.groupId | ||
import me.madhead.tyzenhaus.core.telegram.updates.help.HelpCommandUpdateProcessor | ||
import me.madhead.tyzenhaus.core.telegram.updates.help.HelpCommandUpdateProcessor.Companion | ||
import me.madhead.tyzenhaus.core.telegram.updates.lang.LangCallbackQueryUpdateProcessor.Companion.CALLBACK_PREFIX | ||
import me.madhead.tyzenhaus.core.telegram.updates.userId | ||
import me.madhead.tyzenhaus.entity.dialog.state.DialogState | ||
import me.madhead.tyzenhaus.entity.group.config.GroupConfig | ||
import me.madhead.tyzenhaus.i18.I18N | ||
import org.apache.logging.log4j.LogManager | ||
|
||
/** | ||
* /privacy command handler. | ||
*/ | ||
class PrivacyCommandUpdateProcessor( | ||
private val requestsExecutor: RequestsExecutor, | ||
) : UpdateProcessor { | ||
companion object { | ||
private val logger = LogManager.getLogger(PrivacyCommandUpdateProcessor::class.java)!! | ||
} | ||
|
||
@Suppress("DuplicatedCode") | ||
override suspend fun process(update: Update, groupConfig: GroupConfig?, dialogState: DialogState?): UpdateReaction? { | ||
@Suppress("NAME_SHADOWING") | ||
val update = update as? MessageUpdate ?: return null | ||
val message = update.data as? CommonMessage<*> ?: return null | ||
val content = (message as? CommonMessage<*>)?.content as? TextContent ?: return null | ||
|
||
return if (content.textSources.any { "privacy" == (it as? BotCommandTextSource)?.command }) { | ||
{ | ||
logger.debug("{} asked for privacy in {}", update.userId, update.groupId) | ||
|
||
requestsExecutor.sendMessage( | ||
chatId = update.data.chat.id, | ||
text = I18N(groupConfig?.language)["privacy"], | ||
parseMode = MarkdownV2, | ||
disableWebPagePreview = true, | ||
) | ||
} | ||
} else null | ||
} | ||
} |
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