Skip to content

Commit

Permalink
revert backend changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lhcfl committed Jul 8, 2024
1 parent f2add7d commit 8df7684
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 147 deletions.
123 changes: 0 additions & 123 deletions app/lib/topic_op_admin_handle_new_posts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,127 +13,4 @@
end
end

# TODO: 开发Bot命令版本

# bot = TopicOpUserAdminBot.getBot()

# TopicOpUserAdminBot.botParseCmd(
# post.raw,
# {
# "@#{bot.username}" => ->(cmd) do
# guardian = Guardian.new(user)

# topic = BotLoggingTopic.find_by(id: post.topic_id)

# handles = {
# "silence" => ->(cmdlist) do
# target_user_at, seconds, *reasons = cmdlist.split(" ")

# puts "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n----------------------"
# puts reasons
# puts "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n----------------------"

# reasons = reasons.join(" ")

# puts reasons
# puts "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n----------------------"

# if seconds.to_i == 0
# reasons = (seconds || "") + " " + reasons
# seconds = nil
# else
# seconds = seconds.to_i * 60
# end

# guardian.ensure_can_see_topic!(topic)

# unless guardian.can_edit_topic_banned_user_list?(topic)
# TopicOpUserAdminBot.botSendPost(
# topic.id,
# I18n.t("topic_op_admin.no_perm"),
# reply_to_post_number: post.post_number,
# )
# return
# end

# target_user = User.find_by(username: target_user_at[1..])

# if target_user.nil? || target_user.admin? || target_user.moderator?
# TopicOpUserAdminBot.botSendPost(
# topic.id,
# I18n.t("topic_op_admin.bot_send_template.ban.failed"),
# reply_to_post_number: post.post_number,
# )
# return
# end

# TopicOpBannedUser.banUser(topic.id, target_user.id, seconds)

# if seconds.nil?
# TopicOpUserAdminBot.botSendPost(
# topic.id,
# I18n.t("topic_op_admin.bot_send_template.ban.success.forever") +
# " @#{target_user.username}\n\n" + I18n.t("topic_op_admin.log_template.reason") +
# " #{reasons}",
# reply_to_post_number: post.post_number,
# )
# else
# TopicOpUserAdminBot.botSendPost(
# topic.id,
# I18n.t("topic_op_admin.bot_send_template.ban.success.temp") +
# " @#{target_user.username} #{seconds / 60}" +
# I18n.t("topic_op_admin.bot_send_template.ban.success.min") + "\n\n" +
# I18n.t("topic_op_admin.log_template.reason") + " #{reasons}",
# reply_to_post_number: post.post_number,
# )
# end
# end,
# "unmute" => ->(cmdlist) do
# target_user_at, *reasons = cmdlist.split " "

# reasons = reasons.join(" ")

# unless guardian.can_edit_topic_banned_user_list?(topic)
# TopicOpUserAdminBot.botSendPost(
# topic.id,
# I18n.t("topic_op_admin.no_perm"),
# reply_to_post_number: post.post_number,
# )
# return
# end

# target_user = User.find_by(username: target_user_at[1..])

# if target_user.nil?
# TopicOpUserAdminBot.botSendPost(
# topic.id,
# I18n.t("topic_op_admin.bot_send_template.unmute.failed"),
# reply_to_post_number: post.post_number,
# )
# return
# end

# TopicOpBannedUser.cancelBanUser(topic.id, target_user.id)

# TopicOpUserAdminBot.botSendPost(
# topic.id,
# I18n.t("topic_op_admin.bot_send_template.unmute.success") +
# " @#{target_user.username}\n\n" + I18n.t("topic_op_admin.log_template.reason") +
# " #{reasons}",
# reply_to_post_number: post.post_number,
# )
# end,
# "help" => ->(cmdlist) do
# TopicOpUserAdminBot.botSendPost(
# topic.id,
# "你好鸭, @#{user.username}\n\n我是用户自治bot。目前我仅支持以下命令(reason是理由):\n\n@#{bot.username} silence `@xxx` minutes reason: 将xxx禁言minutes分钟\n@#{bot.username} unmute `@xxx` reason: 将xxx取消禁言",
# reply_to_post_number: post.post_number,
# )
# end,
# }

# TopicOpUserAdminBot.botParseCmd(cmd, handles)
# end,
# },
# ) if user.id != bot.id
end
11 changes: 0 additions & 11 deletions lib/user_autonomy_module/engine.rb

This file was deleted.

20 changes: 7 additions & 13 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,23 @@

enabled_site_setting :user_autonomy_plugin_enabled

module ::UserAutonomyModule
PLUGIN_NAME = "user-autonomy-plugin"
end

register_asset "stylesheets/topic-op-admin.scss"
if respond_to?(:register_svg_icon)
register_svg_icon "cog"
register_svg_icon "cogs"
register_svg_icon "envelope-open-text"
end

require_relative "app/lib/bot.rb"
require_relative "lib/user_autonomy_module/engine.rb"
require_relative "app/lib/bot"

after_initialize do
%w[
app/controllers/topic_op_admin_controller.rb
app/lib/bot.rb
app/models/topic_op_admin_status.rb
app/serializers/topic_op_admin_status_serializer.rb
app/models/bot_logging_topic.rb
app/lib/topic_op_admin_handle_new_posts.rb
app/models/topic_op_banned_user.rb
app/controllers/topic_op_admin_controller
app/models/topic_op_admin_status
app/serializers/topic_op_admin_status_serializer
app/models/bot_logging_topic
app/lib/topic_op_admin_handle_new_posts
app/models/topic_op_banned_user
].each { |f| require_relative File.expand_path("../#{f}", __FILE__) }

add_to_class(:user, :can_manipulate_topic_op_adminable?) do
Expand Down

0 comments on commit 8df7684

Please sign in to comment.