public void GoServerQuery(string clu, string str) { bool flag = false; string text = str.Trim(); string ip = string.Empty; string str2 = string.Empty; for (int i = 0; i < Config.serList.GetLength(0); i++) { bool flag2 = text.Equals(Config.serList[i, 1]); if (flag2) { ip = Config.serList[i, 2]; str2 = Config.serList[i, 0]; string content = Jx3OpenTell.IsOpen(ip, 3724) ? (str2 + " " + text + "\r\n开") : (str2 + " " + text + "\r\n关"); _mahuaApi.SendGroupMessage(clu, CQCode.SendLink("开服查询", CQCode.GetQQHead(_mahuaApi.GetLoginQq()), content)); flag = true; } else { bool flag3 = !flag && i == Config.serList.GetLength(0) - 1; if (flag3) { _mahuaApi.SendGroupMessage(clu, " 对不起,没有找到服务器 (づ╥﹏╥)づ"); } } } }
public void GoServerQuery(string clu, string serverstr) { string serName = serverstr.Trim(); string ip = string.Empty; string bigSer = string.Empty; for (int i = 0; i < Config.serList.GetLength(0); i++) { if (serName.Equals(Config.serList[i, 1])) { ip = Config.serList[i, 2]; bigSer = Config.serList[i, 0]; string content = Jx3OpenTell.IsOpen(ip, 3724) ? (bigSer + " " + serName + "\r\n开") : (bigSer + " " + serName + "\r\n关"); _mahuaApi.SendGroupMessage(clu, CQCode.SendLink("开服查询", CQCode.GetQQHead(_mahuaApi.GetLoginQq()), content)); return; } else { if (i == Config.serList.GetLength(0) - 1) { _mahuaApi.SendGroupMessage(clu, " 对不起,没有找到服务器 (づ╥﹏╥)づ"); } } } }
public void ProcessGroupMessage(GroupMessageReceivedContext context) { var ats = CQNumberHelper.GetAtQQ(context.Message)?.ToList(); if (ats != null && ats.Contains(_mahuaApi.GetLoginQq()) && (context.Message.Contains("--help") || context.Message.Contains("-h"))) { _mahuaApi.SendGroupMessageExtension(context.FromGroup, RuntimeConfig.Config.HelpText); } }
public void BanPostLotto(IMahuaApi _mahuaApi, string group, string qq) { mangerConfig = GraceGroupMangerConfig.Instance; int ret = QQinMangerConfig(group, mangerConfig); if (ret < 0) { GraceGroupConfig cfg = new GraceGroupConfig(); cfg.GroupQQ = group; mangerConfig.groupConfigs.Add(cfg); mangerConfig.ToJsonString().SaveToFile(GraceGroupMangerConfig.SavePath); } else { if (!GraceGroupMangerConfig.Instance.groupConfigs[ret].IsBanPostLotto) { Messenger.SendGroup(group, "禁言抽奖功能已被禁用,请输入[开启禁言抽奖]来启用此功能(需要管理员或群主权限)"); return; } } GroupMemberInfo botInfo = GetGroupMemberInfo(_mahuaApi, group, _mahuaApi.GetLoginQq()); GroupMemberAuthority botAuthority = botInfo.Authority; if (GroupMemberAuthority.Unknown == botAuthority || GroupMemberAuthority.Normal == botAuthority) { Messenger.SendGroup(group, "机器人的权限不足,想要使用禁言抽奖功能,请将机器人设置为管理员!"); return; } int hours = 0, minutes = 0, seconds = 0; Random rd = new Random(); minutes = rd.Next(1, 11); TimeSpan time = new TimeSpan(hours, minutes, seconds); GroupMemberInfo member = GetGroupMemberInfo(_mahuaApi, group, qq); if (member.Authority < botAuthority) { _mahuaApi.BanGroupMember(group, qq, time); string nick = member.InGroupName; if (nick == "") { nick = qq; } Messenger.SendGroup(group, $"恭喜 {nick} 抽中{minutes}分钟套餐"); } else { Messenger.SendGroup(group, $"[CQ:at,qq={qq}] ,权限不足,抽个鸡儿"); } }
public void ProcessGroupMessage(GroupMessageReceivedContext context) { var content = context.Message; var ats = CQNumberHelper.GetAtQQ(context.Message)?.ToList(); if (ats == null || !ats.Contains(_mahuaApi.GetLoginQq())) { return; } var m = regex_date.Match(content); if (!m.Success || m.Length == 0) { return; } DateTime date = DateTime.Now; string dateStr = m.Groups[1].Value; switch (dateStr) { case "今日": case "今天": date = DateTime.Today; break; case "昨日": case "昨天": date = DateTime.Today.AddDays(-1); break; default: date = new DateTime(date.Year, int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value)); break; } foreach (var item in RuntimeConfig.Config.GroupEventSerach) { if (!context.Message.Contains(item.Key)) { continue; } var logs = SearchEventLog(item, date, context.FromGroup); if (logs != null) { SendMessage(logs.Data?.Items, logs.Data?.Total ?? 0, item, date, context.FromGroup); } } }
public void ProcessGroupMessage(GroupMessageReceivedContext context) { var ats = CQNumberHelper.GetAtQQ(context.Message)?.ToList(); if (ats != null && ats.Contains(_mahuaApi.GetLoginQq())) { if (context.Message.Contains("上传图片")) { var result = UploadImageAsync(context).GetAwaiter().GetResult(); if (!string.IsNullOrEmpty(result)) { _mahuaApi.SendGroupMessageExtension(context.FromGroup, result); ILog logger = LogProvider.GetCurrentClassLogger(); logger.Info(result); } } } }
public void ProcessGroupMemberIncreased(GroupMemberIncreasedContext context) { if (context.JoinedQq.Equals(_mahuaApi.GetLoginQq())) // 排除机器人入群 { _mahuaApi.SendGroupMessage(context.FromGroup) .AtlAll() .Text("欢迎您加入技术交流群,我是Pikachu机器人,艾特我回复“指令”两个字可以为您提供服务哦。") .Done(); return; } else { _mahuaApi.SendGroupMessage(context.FromGroup) .At(context.JoinedQq) .Text("欢迎您加入技术交流群,我是Pikachu机器人,艾特我回复“指令”两个字可以为您提供服务哦。") .Done(); } // todo 填充处理逻辑 //throw new NotImplementedException(); // 不要忘记在MahuaModule中注册 }
public void ProcessGroupMessage(GroupMessageReceivedContext context) { Logger.Debug($"[receiver][group][msg][{context.FromGroup}]:{context.Message}"); var loginQq = _mahuaApi.GetLoginQq(); _ = GroupMsgCopy(context, loginQq); if (!GroupAuthService.Exists(context.FromGroup)) // 群号尚未授权 { return; } //if (context.Message.Contains($"[@{loginQq}]")) //{ // context.Message = context.Message.Replace($"[@{loginQq}]", "").Trim(); Run(context, loginQq).Wait(); //} //else //{ // _mahuaApi.SendGroupMessage(context.FromGroup).Text(context.Message).Done(); //} }
// private MessageController messageController = new MessageController(); public void ProcessGroupMessage(GroupMessageReceivedContext context) { String message = context.Message; message = message.Trim(); if (message == "" || message.Length == 0 || message == null) { return; } String myQQ = _mahuaApi.GetLoginQq(); String aiteQQ = "[CQ:at,qq=" + myQQ + "]"; if (message.Contains(aiteQQ)) { String sendMessage = "[CQ:at,qq=" + context.FromQq + "]"; message = message.Replace(aiteQQ, "").Replace("\"\"", "").Replace("“", "").Replace("”", "").Trim(); IDatabase redis = RedisHelper.getRedis(); // 判断用户是否在缓冲中 if (redis.StringGet(context.FromQq).IsNull) { redis.StringSet(context.FromQq, "flag"); redis.KeyExpire(context.FromQq, new TimeSpan(10000000 * Convert.ToInt16(Constants.sleepTime))); } else { string tmpStr = "为防止造成刷屏,您每次使用机器人的时间间隔" + Constants.sleepTime + "秒哦!"; sendMessage += tmpStr; _mahuaApi.SendGroupMessage(context.FromGroup, sendMessage); return; }; if (message == null || message == "" || message.Length == 0) { // } else { MessageModel messageModel = MessageController.main(message, context.FromQq); // 发送消息 string tmpStr = messageModel.SendMessage; if (messageModel.IsAdmin) { // 群数量 if (MessageConstant.QUN_TOTAL.Equals(messageModel.Code)) { ModelWithSourceString <IEnumerable <GroupInfo> > modelWithSourceString = _mahuaApi.GetGroupsWithModel(); IEnumerable <GroupInfo> groupInfo = modelWithSourceString.Model; int count = 0; foreach (var item in groupInfo) { count++; } _mahuaApi.SendGroupMessage(context.FromQq, "群数量:" + count.ToString()); } else { if (tmpStr != "" && tmpStr.Length > 0) { sendMessage += tmpStr; _mahuaApi.SendGroupMessage(context.FromQq, sendMessage); } } } else { if (tmpStr != "" && tmpStr.Length > 0) { sendMessage += tmpStr; _mahuaApi.SendGroupMessage(context.FromGroup, sendMessage); } } } } }
public void ProcessGroupMessage(GroupMessageReceivedContext context) { var managerQQ = RuntimeConfig.Config.ManagerQq.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var message = context.Message; var fromQQ = context.FromQq; var group = context.FromGroup; var loginQQ = _mahuaApi.GetLoginQq(); if (managerQQ.Any(x => x == fromQQ)) { var ats = CQNumberHelper.GetAtQQ(context.Message)?.ToList(); if (!ats?.Any(x => x == loginQQ) ?? false) { return; } //解除禁言 if (message.IndexOf("解除禁言") > -1) { foreach (var item in ats.Where(x => x != loginQQ)) { _mahuaApi.RemoveBanGroupMember(group, item); } } else { var m = banRegex.Match(message); //禁言 if (m.Success) { var time = Convert.ToDouble(m.Groups[1].Value); foreach (var item in ats?.Where(x => x != loginQQ)) { _mahuaApi.BanGroupMember(context.FromGroup, item, TimeSpan.FromMinutes(time)); } return; } //修改复读禁言时间 m = repeatBanTimeChangeRegex.Match(message); if (m.Success) { var time = Convert.ToDouble(m.Groups[1].Value); if (time > 0) { RuntimeConfig.Config.RepeatMessageBanDuration = time; RuntimeConfig.Save(AppSetting.ConfigFilePath, RuntimeConfig.Config.ToJosn()); } return; } //修改复读禁言概率 m = repeatBanProbabilityChangeRegex.Match(message); if (m.Success) { var time = Convert.ToDouble(m.Groups[1].Value); if (time > 0) { RuntimeConfig.Config.RepeatMessageBanProbability = time; RuntimeConfig.Save(AppSetting.ConfigFilePath, RuntimeConfig.Config.ToJosn()); } return; } } } }
public override void ProcessRequset(GroupMessageReceivedContext msg, AnalysisMsg nowModel) { if (Config.ConfigModel.IsFuncOpen("菜单")) { if (msg.Message.Trim() == "菜单") { _mahuaApi.SendGroupMessage(msg.FromGroup).Text(Config.ConfigModel.MenuStr).Done(); _mahuaApi.SendGroupMessage(msg.FromGroup).Text(CQCode.SendLink("小T完全手册", CQCode.GetQQHead(_mahuaApi.GetLoginQq()), "小T操作手册:最新最全的小T使用攻略", "https://traceless.site/index.php/archives/62/")).Done(); return; } } successor.ProcessRequset(msg, nowModel); }
public void Enabled(PluginEnabledContext context) { //基础配置 //机器人任务计划 Log.addLog("INIT", String.Format("插件启用,当前登录账号:{0}({1})", api.GetLoginNick(), api.GetLoginQq())); //初始化百度AI Conf.baiduAiInit(); //酷Q模拟重启初始化获取句柄 Log.info("开始尝试获取酷Q窗口句柄"); try { CQRestart.__init(); Log.info("获取酷Q窗口句柄成功,可以执行模拟重启功能"); } catch (Exception e) { Log.warning("获取酷Q窗口句柄失败:" + e.Message); } string qq = Conf.getStringConfig("global.restart", "qq", "0"); string group = Conf.getStringConfig("global.restart", "group", "0"); long time = Conf.getLongConfig("global.restart", "time", 0); if (qq != "0" || group != "0") { string s = ""; if (time != 0) { s = ",本次重启耗时:" + (Util.getTime() - time) + "秒"; } if (group == "0" && qq != "0") { //私聊 this.api.SendPrivateMessage(qq, CQ.shake()); this.api.SendPrivateMessage(qq, "酷Q已重启完成!" + s); } else if (group != "0") { if (qq == "0") { this.api.SendGroupMessage(group, "酷Q已重启完成!" + s); } else { this.api.SendGroupMessage(group, CQ.at(qq) + "酷Q已重启完成!" + s); } } else { Log.addLog("未知的请求人重启"); } Conf.setConfig("global.restart", "none"); } Task.Factory.StartNew(() => { using (var robotSession = MahuaRobotManager.Instance.CreateSession()) { var api = robotSession.MahuaApi; UdpServer server = new UdpServer(); server.run(api); } }); Task.Factory.StartNew(() => { string taskDir = Path.Combine(Directory.GetCurrentDirectory(), "bottask"); if (!Directory.Exists(taskDir)) { Directory.CreateDirectory(taskDir); } DirectoryInfo root = new DirectoryInfo(taskDir); foreach (FileInfo file in root.GetFiles()) { if (file.Name.Substring(file.Name.Length - 3) == ".xt") { Log.addLog("DEBUG", "---------------------" + file.Name + "------------------------------------"); Log.addLog("DEBUG", "载入【" + file.Name + "】脚本文件进行处理"); new BotTaskManager(file.FullName); } } }); }
public void ProcessGroupMemberIncreased(GroupMemberIncreasedContext context) { string liveQQ = api.GetLoginQq(); string joinQQ = context.JoinedQq; string group = context.FromGroup; if (group == "734717901") { api.SendPrivateMessage("2289453456", "已加入734717901群"); return; } int ac = CQAPI.getAuthCode();//获取authcode if (!liveQQ.Equals(joinQQ)) { //其他用户加入群 CQAPI.xtAddLog(ac, LogType.status.INFO, "新用户加入", String.Format("加入了群:{0}", group)); string text; //特殊群处理 if (group == "454493790" || group == "854270226") { //int count = CQ.getGroupUserListSize(long.Parse(group)); //api.SetGroupMemberCard(group, joinQQ, String.Format("卡秋莎{0}号",count)); //text = String.Format("欢迎{0}加入卡秋莎养殖中心,您是第{1}位卡秋莎,凡是中暑,打架,淋雨,吃太多,吃太少,不吃,受内伤的我们不如....", CQ.at(joinQQ),count); text = String.Format("欢迎{0}加入本群!", CQ.at(joinQQ)); } else { text = String.Format("欢迎{0}加入本群!", CQ.at(joinQQ)); } this.api.SendGroupMessage(group, text); } else { CQAPI.xtAddLog(ac, LogType.status.INFO, "自己加群", String.Format("加入了群:{0}", group)); //将该群添加白名单 //自己加入群 string text = String.Format("はじめまして、どうぞよろしくお願いします、ヾ(^▽^*)))"); this.api.SendGroupMessage(group, text); //载入允许群 List <string> allSendGroup = new List <string>(); //载入允许群 object allowgroup = Conf.getConfig("global.config", "group"); JArray jarr; try { jarr = (JArray)allowgroup; for (int i = 0; i < jarr.Count; i++) { try { string v = jarr[i].ToString(); if (!allSendGroup.Contains(v)) { allSendGroup.Add(v); } } catch (Exception e) { } } } catch (Exception e) { } bool isNoAllow = false; for (int i = 0; i < allSendGroup.Count; i++) { if (allSendGroup[i] == group) { isNoAllow = true; break; } } if (isNoAllow) { //该群已存在 CQAPI.xtAddLog(ac, LogType.status.INFO, "添加白名单群", String.Format("已存在白名单群:{0}", group)); return; } allSendGroup.Add(group); Conf.setConfig("global.config", "group", allSendGroup); CQAPI.xtAddLog(ac, LogType.status.SUCCESS, "添加白名单群", String.Format("添加白名单成功群:{0}", group)); } }
private async Task Run(PrivateMessageFromFriendReceivedContext context) { context.Message = context.Message.Trim(); var res = await _generatePrivateMsgDeal .Run(context.Message, context.FromQq, (new Lazy <string>((() => _mahuaApi.GetLoginQq())))); if (res != null) { foreach (var item in res.Data) { var msg = _mahuaApi.SendPrivateMessage(context.FromQq); if (item.CallTa) { msg.Shake().Done(); } msg.Text(item.Msg).Done(); } } }