diff --git a/src/main/kotlin/net/lz1998/zbot/plugin/ShowOrFlashPlugin b/src/main/kotlin/net/lz1998/zbot/plugin/ShowOrFlashPlugin new file mode 100644 index 0000000..5891e55 --- /dev/null +++ b/src/main/kotlin/net/lz1998/zbot/plugin/ShowOrFlashPlugin @@ -0,0 +1,195 @@ +package net.lz1998.zbot.plugin + +import net.lz1998.pbbot.alias.GroupMessageEvent +import net.lz1998.pbbot.bot.Bot +import net.lz1998.pbbot.bot.BotPlugin +import net.lz1998.pbbot.utils.Msg +import net.lz1998.zbot.aop.annotations.PrefixFilter +import net.lz1998.zbot.aop.annotations.SwitchFilter +//import net.lz1998.zbot.service.isAdmin +import org.springframework.stereotype.Component + +@Component +@SwitchFilter("闪秀图") +class ShowOrFlashPlugin: BotPlugin() { + + @PrefixFilter(".") + override fun onGroupMessage(bot: Bot, event: GroupMessageEvent): Int { + + val groupId = event.groupId +// val userId = event.userId + val rawMsg = event.rawMessage + +// if(isAdmin(event.sender)) { + if (rawMsg.startsWith("秀图")) { + // 40000 秀图 + // 40001 幻影 + // 40002 抖动 + // 40003 生日 + // 40004 爱你 + // 40005 征友 + val m = Regex("") + val r = showUrlMatch.find(rawMsg)?.value?.replace("\"/>", "") + if (r != null) { + Msg.builder().show(r, 40000).sendToGroup(bot, groupId) + return MESSAGE_BLOCK + } + } else { + bot.sendGroupMsg(groupId, "秀图图片只能为1张") + return MESSAGE_BLOCK + } + } + + if (rawMsg.startsWith("秀幻影")) { + // 40000 秀图 + // 40001 幻影 + // 40002 抖动 + // 40003 生日 + // 40004 爱你 + // 40005 征友 + val m = Regex("") + val r = showUrlMatch.find(rawMsg)?.value?.replace("\"/>", "") + if (r != null) { + Msg.builder().show(r, 40001).sendToGroup(bot, groupId) + return MESSAGE_BLOCK + } + } else { + bot.sendGroupMsg(groupId, "秀图图片只能为1张") + return MESSAGE_BLOCK + } + } + + if (rawMsg.startsWith("秀抖动")) { + // 40000 秀图 + // 40001 幻影 + // 40002 抖动 + // 40003 生日 + // 40004 爱你 + // 40005 征友 + val m = Regex("") + val r = showUrlMatch.find(rawMsg)?.value?.replace("\"/>", "") + if (r != null) { + Msg.builder().show(r, 40002).sendToGroup(bot, groupId) + return MESSAGE_BLOCK + } + } else { + bot.sendGroupMsg(groupId, "秀图图片只能为1张") + return MESSAGE_BLOCK + } + } + + if (rawMsg.startsWith("秀生日")) { + // 40000 秀图 + // 40001 幻影 + // 40002 抖动 + // 40003 生日 + // 40004 爱你 + // 40005 征友 + val m = Regex("") + val r = showUrlMatch.find(rawMsg)?.value?.replace("\"/>", "") + if (r != null) { + Msg.builder().show(r, 40003).sendToGroup(bot, groupId) + return MESSAGE_BLOCK + } + } else { + bot.sendGroupMsg(groupId, "秀图图片只能为1张") + return MESSAGE_BLOCK + } + } + + if (rawMsg.startsWith("秀爱你")) { + // 40000 秀图 + // 40001 幻影 + // 40002 抖动 + // 40003 生日 + // 40004 爱你 + // 40005 征友 + val m = Regex("") + val r = showUrlMatch.find(rawMsg)?.value?.replace("\"/>", "") + if (r != null) { + Msg.builder().show(r, 40004).sendToGroup(bot, groupId) + return MESSAGE_BLOCK + } + } else { + bot.sendGroupMsg(groupId, "秀图图片只能为1张") + return MESSAGE_BLOCK + } + } + + if (rawMsg.startsWith("秀征友")) { + // 40000 秀图 + // 40001 幻影 + // 40002 抖动 + // 40003 生日 + // 40004 爱你 + // 40005 征友 + val m = Regex("") + val r = showUrlMatch.find(rawMsg)?.value?.replace("\"/>", "") + if (r != null) { + Msg.builder().show(r, 40005).sendToGroup(bot, groupId) + return MESSAGE_BLOCK + } + } else { + bot.sendGroupMsg(groupId, "秀图图片只能为1张") + return MESSAGE_BLOCK + } + } + + if (rawMsg.startsWith("闪图")) { + val m = Regex("") + val r = showUrlMatch.find(rawMsg)?.value?.replace("\"/>", "") + if (r != null) { + Msg.builder().flash(r).sendToGroup(bot, groupId) + return MESSAGE_BLOCK + } + } else { + bot.sendGroupMsg(groupId, "闪图只能为1张") + return MESSAGE_BLOCK + } + } +// } + return MESSAGE_IGNORE + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f77fd95..bcc41d4 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -19,6 +19,7 @@ spring: - net.lz1998.zbot.plugin.SecurityPlugin # 网页验证码 - net.lz1998.zbot.plugin.PBlockPlugin # 个人永久屏蔽 - net.lz1998.zbot.plugin.SwitchPlugin # 开关 + - net.lz1998.zbot.plugin.ShowOrFlashPlugin # 闪秀图 - net.lz1998.zbot.plugin.ScramblePlugin # 打乱 - net.lz1998.zbot.plugin.WcaPlugin # WCA 成绩 - net.lz1998.zbot.plugin.RankPlugin # WCA 排名