MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    mirai 有退群 协议吗?假如,复读机

    使用交流
    2
    4
    164
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kixeb23099 last edited by

      mirai 有退群 协议吗?假如,复读机 在群甲, 当群里管理

      @复读机 有缘再会,
      复读机 就应该 自动离开,

      1 Reply Last reply Reply Quote 0
      • MrXiaoM
        MrXiaoM 童心未泯 last edited by

        监听 GroupMessageEvent
        判断发送者的身份和发送的内容,如果符合你指定的条件就

        event.getGroup().quit();
        
        K 1 Reply Last reply Reply Quote 0
        • MrXiaoM
          MrXiaoM 童心未泯 last edited by MrXiaoM

          我的代码质量老低了… 仅供参考

          
          		if(event.getSender().getPermission() == MemberPermission.ADMINISTRATOR||
          				event.getSender().getPermission() == MemberPermission.OWNER) {
          			boolean atFlag = false;
          			for(int i = 0;i<event.getMessage().size();i++) {
          				SingleMessage single = event.getMessage().get(i);
          				if(!atFlag) {
          					if(single instanceof At) {
          						if(((At)single).getTarget() == event.getBot().getId()) {
          							atFlag = true;
          						}
          					}
          				}
          				else {
          					if(single.contentToString().contains("有缘再会")) {
          						event.getGroup().sendMessage("拜拜了您嘞");
          						event.getGroup().quit();
          						break;
          					}
          				}
          			}
          		}
          
          1 Reply Last reply Reply Quote 0
          • K
            kixeb23099 @MrXiaoM last edited by

            @mrxiaom 给力!

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact