msg.go 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package block
  2. import (
  3. "fmt"
  4. model "go-common/app/admin/main/member/model/block"
  5. "go-common/library/log"
  6. )
  7. const (
  8. _creditLimit = `抱歉,你的账号因“%s%s”,现已进行封禁%d天处理,账号解封需要满足以下两个条件:1.账号封禁时间已满。2.完成解封答题( #{点击进入解封答题}{"http://www.bilibili.com/blackroom/releaseexame.html"} )全部完成后解封。封禁期间将无法投稿、发送及回复消息,无法发布评论、弹幕,无法对他人评论进行回复、赞踩操作,无法进行投币、编辑标签、添加关注、添加收藏操作。解封后恢复正常,还请遵守社区规范,共同维护良好的社区氛围!`
  9. _creditForever = `抱歉,你的账号因“%s%s”,现已进行永久封禁处理。封禁期间将无法投稿、发送及回复消息,无法发布评论、弹幕,无法对他人评论进行回复、赞踩操作,无法进行投币、编辑标签、添加关注、添加收藏操作。解封后恢复正常,还请遵守社区规范,共同维护良好的社区氛围!`
  10. _sysLimit = `抱歉,你的账号因“%s”,现已进行封禁%d天处理,账号解封需要满足以下两个条件:1.账号封禁时间已满。2.完成解封答题( #{点击进入解封答题}{"http://www.bilibili.com/blackroom/releaseexame.html"} )全部完成后解封。封禁期间将无法投稿、发送及回复消息,无法发布评论、弹幕,无法对他人评论进行回复、赞踩操作,无法进行投币、编辑标签、添加关注、添加收藏操作。解封后恢复正常,还请遵守社区规范,共同维护良好的社区氛围!`
  11. _sysForever = `抱歉,你的账号因“%s”,现已进行永久封禁处理。封禁期间将无法投稿、发送及回复消息,无法发布评论、弹幕,无法对他人评论进行回复、赞踩操作,无法进行投币、编辑标签、添加关注、添加收藏操作。解封后恢复正常,还请遵守社区规范,共同维护良好的社区氛围!`
  12. _remove = `你的账号已经解除封禁,封禁期间禁止使用的各项社区功能已经恢复。请遵守社区规范,共同维护良好的社区氛围。`
  13. )
  14. // MSGInfo get msg info
  15. func (s *Service) MSGInfo(source model.BlockSource, action model.BlockAction, area model.BlockArea, reason string, days int64) (code string, title, content string) {
  16. // 小黑屋封禁
  17. if source == model.BlockSourceBlackHouse {
  18. areaStr := area.String()
  19. if areaStr != "" {
  20. areaStr = fmt.Sprintf("在%s中", areaStr)
  21. }
  22. if action == model.BlockActionLimit {
  23. code = "2_3_2"
  24. title = "账号违规处理通知"
  25. content = fmt.Sprintf(_creditLimit, areaStr, s.convertReason(reason), days)
  26. return
  27. }
  28. if action == model.BlockActionForever {
  29. code = "2_3_3"
  30. title = "账号违规处理通知"
  31. content = fmt.Sprintf(_creditForever, areaStr, s.convertReason(reason))
  32. return
  33. }
  34. }
  35. // 系统封禁
  36. if source == model.BlockSourceSys {
  37. if action == model.BlockActionLimit {
  38. code = "2_3_4"
  39. title = "账号违规处理通知"
  40. content = fmt.Sprintf(_sysLimit, s.convertReason(reason), days)
  41. return
  42. }
  43. if action == model.BlockActionForever {
  44. code = "2_3_5"
  45. title = "账号违规处理通知"
  46. content = fmt.Sprintf(_sysForever, s.convertReason(reason))
  47. return
  48. }
  49. }
  50. if action == model.BlockActionAdminRemove || action == model.BlockActionSelfRemove {
  51. code = "2_3_6"
  52. title = "账号封禁解除通知"
  53. content = _remove
  54. return
  55. }
  56. log.Error("s.MSGInfo unkown source[%v] action[%v] area[%v] reason[%s] days[%d]", source, action, area, reason, days)
  57. return
  58. }
  59. func (s *Service) convertReason(reason string) string {
  60. switch reason {
  61. case "账号资料相关违规":
  62. return "账号资料违规"
  63. case "作品投稿违规":
  64. return "作品投稿违规"
  65. case "异常注册账号":
  66. return "异常注册"
  67. case "异常答题账号":
  68. return "异常答题"
  69. case "异常数据行为":
  70. return "异常数据行为"
  71. case "发布违规信息":
  72. return "发布违规信息"
  73. case "其他自动封禁", "手动封禁":
  74. return "违反社区规则"
  75. default:
  76. return reason
  77. }
  78. }