public virtual void Run(CommandArgs args) { var splits = args.Arg.Trim().Split(' '); var config = Configuration.GetConfig <T>(); switch (splits[0]) { case "add": config.hash.Add(long.Parse(splits[1])); config.Save(); args.Callback($"successfully added {splits[1]}"); break; case "del": config.hash.Remove(long.Parse(splits[1])); config.Save(); args.Callback($"successfully removed {splits[1]}"); break; case "list": var no = 0; args.Callback(string.Concat(config.hash.Select((g) => $"{++no}. {g}\n"))); break; } }
public static void Main(CommandArgs args, string username, string password) { var binding = Configuration.GetConfig <AccountBinding>().list; var serverbinding = Configuration.GetConfig <ServerManager>().bindings; if (binding.Any((o) => (string)o["username"] == username && (int)o["group"] == Configuration.GetConfig <ServerManager>().GetServer(args).group)) { args.Callback("已经绑定过了!"); return; } var result = Configuration.GetConfig <ServerManager>().GetServer(args) .RunCommand($"/user add \"{username}\" \"{password}\" default"); if ((int)result["status"] != 200) { args.Callback(result.ToString()); return; } binding.Add(new JObject { ["username"] = username, ["qq"] = args.Source.FromQQ, ["group"] = Configuration.GetConfig <ServerManager>().GetServer(args).group }); Configuration.GetConfig <AccountBinding>().Save(); args.Callback($"已绑定 {username}<=>{args.Source.FromQQ}"); }
protected override void Run(CommandArgs args) { var splits = args.Arg.Trim().Split(' '); Team[] teams; if (splits.Length != 5) { args.Callback("必须有且只有五个角色!"); return; } try { teams = JJCManager.Instance.Callapi(splits); } catch (Exception e) { args.Callback(e.Message); return; } var img = JJCManager.Instance.GetImage(teams.Take(10).ToArray()).Resize(0.5f); args.Callback($"{args.Arg.Trim()}的解法:\n" + Utils.GetImageCode(img)); }
public async Task Run(CommandArgs args) { var arg = args.Arg.Trim(); if (args.Source.FromGroup == 0) { var type = Enum.Parse <CarType>(arg); config[$"q{args.Source.FromQQ}"] = type; await args.Callback($"subscribe type of account {args.Source.FromQQ} set to {type}"); } else { if (!await args.Source.CheckPermission(args.Source.FromGroup)) { await args.Callback("access denied."); return; } var type = Enum.Parse <CarType>(arg); config[$"g{args.Source.FromGroup}"] = type; await args.Callback($"subscribe type of group {args.Source.FromGroup} set to {type}"); } }
public async Task Run(CommandArgs args) { int damage; try { damage = int.Parse(args.Arg.Trim()); if (damage < 0) { await args.Callback("伤害不能是负数!"); return; } } catch { await args.Callback("格式错误,请输入数字!"); return; } try { await args.Callback(string.Format(Configuration.GetConfig <PCRConfig>().Add(args.Source.FromQQ, damage), args.Source.Session.GetName(args.Source.FromGroup, args.Source.FromQQ))); } catch (Exception e) { await args.Callback(e.Message); return; } }
public async Task Run(CommandArgs args) { var evt = MasterData.Instance.events.Last(); RankData data; lock (Program.SekaiFile) data = RankData.FromFile($"sekai_event{evt.id}.csv"); int.TryParse(args.Arg, out int rank); if (!data.ranks.ContainsKey(rank)) { await args.Callback("排名数据不存在"); return; } var x = data.timestamp.Select(l => (double)l).ToArray(); var y = data.ranks[rank].Select(l => (double)l).ToArray(); var fit = LSE(x, y); var fit2 = PassZero(x.Select(l => l - evt.startAt).ToArray(), y); await args.Callback($"排名{rank}的预测分数为\n{(int)(fit.Item1 * evt.aggregateAt + fit.Item2)} (LSE)\n{(int)(fit2 * (evt.aggregateAt - evt.startAt))} (过原点)"); }
public async Task Run(CommandArgs args) { var mgr = AssetController.manager; var a = args.Arg.Trim().Split(' '); if (long.TryParse(a[0], out var val)) { a = new[] { "update_query", a[0] } } ; if (a[0].IndexOf("update") >= 0) { var client = new AssetController.PCRClient(); client.urlroot = "http://l3-qa2-all-gs-gzlj.bilibiligame.net/"; var manifest = client.Callapi("source_ini/get_resource_info", new JObject { ["viewer_id"] = "0" }); await masterContextCache.instance.DisposeAsync(); await mgr.Initialize(a[1], (string)manifest["movie_ver"], (string)manifest["sound_ver"], manifest["resource"][0].ToString(), true); masterContextCache.instance = new masterContext(); await args.Callback($"manifest updated to {a[1]}\n"); } if (a[0].IndexOf("query") >= 0) { var now = DateTime.Now; var res = "公主连结半月刊:\n" + string.Join("\n", ISchedule.Schedules.SelectMany(sch => { try { return(sch.AsEnumerable().ToArray()); } catch (Exception e) { return(Array.Empty <ISchedule>()); } }) .Where(s => DateTime.Parse(s.StartTime) > now && s.Enabled) .Select(s => (( $"{DateTime.Parse(s.StartTime).ToShortDateString()}-{DateTime.Parse(s.EndTime).ToShortDateString()}", DateTime.Parse(s.StartTime), s.GetDescription()))) .GroupBy(t => t.Item1) .OrderBy(g => g.First().Item2) .Select(g => $"{g.Key}\n{string.Join("\n", g.Select(s => $" {s.Item3}"))}")); if (a[0].IndexOf("text") >= 0) { await args.Callback(res); } else { await args.Callback(res.ToImageText()); } } } }
public void Run(CommandArgs args) { string[] splits = args.Arg.Trim().Split(' '); if (string.IsNullOrWhiteSpace(args.Arg.Trim())) { args.Callback("/reply <add/del/list>[1234] ...\n1 is string comparision\n2 is regex match\n3 is regex match without at(requires admin).\n4 is c# code"); return; } var config = Configuration.GetConfig <ReplyHandler>(); var qq = args.Source.FromQQ; switch (splits[0]) { case "save": if (args.IsAdmin) { config.Save(); args.Callback("configuration has been saved successfully."); } break; case "add2": case "add3": case "add4": { if (splits.Length < 3) { args.Callback("Invalid argument count."); return; } try { new Regex($"^{Utils.FixRegex(splits[1])}$"); } catch { args.Callback("Invalid regular expression format."); return; } var reply = new Reply { qq = qq, reply = string.Concat(splits.Skip(2).Select((s) => s + ' ')).Trim() }; var data = config[int.Parse(splits[0].Substring(3))]; if (splits[0] == "add4" && !args.IsAdmin) { args.Callback("Access denied!"); return; } var t = data.SingleOrDefault(data => data.Item1.ToString()[1..^ 1] == splits[1]);
public virtual async Task Run(CommandArgs args) { var splits = args.Arg.Trim().Split(' '); var config = Configuration.GetConfig <T>(); var key = splits[1].ParseTo <TKey>(); switch (splits[0]) { case "add": case "del": var val = splits[2].ParseTo <TValue>(); var isadd = splits[0] == "add"; if (!await HasPermission(args.Source, key, val)) { await args.Callback("access denied."); break; } if (isadd) { if (!config.t.ContainsKey(key)) { config.t[key] = new HashSet <TValue>(); } config.t[key].Add(val); config.Save(); await args.Callback($"successfully added {splits[1]} => {splits[2]}"); } else { config.t[key].Remove(val); if (config.t[key].Count == 0) { config.t.Remove(key); } config.Save(); await args.Callback($"successfully removed {splits[1]} => {splits[2]}"); } break; case "list": if (!await args.Source.HasPermission(Permission, -1)) { await args.Callback("access denied."); break; } var no = 0; await args.Callback(string.Concat(config.t[key].Select((g) => $"{++no}. {g}\n"))); break; } }
public async Task Run(CommandArgs args) { return; var flag = Configuration.GetConfig <NormalAllowed>().hash.Contains(args.Source.FromGroup); var flag2 = Configuration.GetConfig <R18Allowed>().hash.Contains(args.Source.FromGroup); if (string.IsNullOrWhiteSpace(args.Arg)) { var pics = Configuration.GetConfig <SetuConfig>().t.Where(pic => pic.r18 ? flag2 : flag).ToArray(); if (pics.Length == 0) { await args.Callback("图片库为空或者你所在的群没有权限!"); return; } var pic = pics[rand.Next(pics.Length)]; var client = new HttpClient(); client.Timeout = new TimeSpan(0, 0, 20); var imgres = Image.FromStream(client.GetStreamAsync(pic.url .Replace("img-original", "c/540x540_70/img-master") .Split("_p0.").First() + "_p0_master1200.jpg").Result); await args.Callback($"作品id: {pic.pid}\n" + $"画师id: {pic.uid}\n" + $"神秘链接: {pic.url}\n" + Utils.GetImageCode(imgres)); return; } var result = await SearchAll(args.Arg.Trim()); result = result.Where(t => t.sanity == 2 && flag || t.sanity != 2 && flag2).ToList(); if (result.Count == 0) { await args.Callback($"找不到\"{args.Arg.Trim()}\"的图片!"); return; } var piece = result[new Random().Next(result.Count)]; var img = GetImage(piece.uri).Result; await args.Callback($"{args.Arg.Trim()}:\n" + $"作品id: {piece.pid}\n" + $"画师id: {piece.uid}\n" + $"神秘链接: {piece.origin.Replace("i.pximg.net", "i.pixiv.cat")}\n" + Utils.GetImageCode(img)); }
protected override void Run(CommandArgs args) { var trimed = args.Arg.Trim(); var sp = trimed.IndexOf(" "); try { args.Callback(PCRManager.Instance.client.Callapi(trimed.Substring(0, sp), JObject.Parse(trimed.Substring(sp))).ToString(Formatting.Indented)); } catch (ApiException e) { args.Callback(e.Message); } }
public async Task Run(CommandArgs args) { var trimed = args.Arg.Trim(); var sp = trimed.IndexOf(" "); try { await args.Callback(PCRManager.Instance.client.Callapi(trimed.Substring(0, sp), JObject.Parse(trimed.Substring(sp))).ToString(Formatting.Indented)); } catch (ApiException e) { await args.Callback(e.Message); PCRManager.Instance.Do_Login(); } }
public void Run(CommandArgs args) { if (!string.IsNullOrEmpty(args.Arg)) { return; } List <Car> cars = Configuration.GetConfig <CarTypeConfig>()[args.Source.FromGroup] switch { CarType.Bandori => listener.Cars, CarType.Sekai => CarHandler.Cars, _ => null }; string result = ""; HashSet <int> indexes = new HashSet <int>(); foreach (Car car in cars) { if (indexes.Contains(car.index)) { continue; } indexes.Add(car.index); result += car.rawmessage + $"({(int)(DateTime.Now - car.time).TotalSeconds}秒前)" + "\n"; } args.Callback(string.IsNullOrEmpty(result) ? "myc" : result.Substring(0, result.Length - 1)); } }
public async Task Run(CommandArgs args) { if (!string.IsNullOrEmpty(args.Arg)) { return; } List <Car> cars = Configuration.GetConfig <CarTypeConfig>()[args.Source.FromGroup] switch { CarType.Bandori => listener.Cars, CarType.Sekai => CarHandler.Cars, _ => null }; string result = ""; HashSet <int> indexes = new HashSet <int>(); var now = DateTime.Now; foreach (Car car in cars) { if (indexes.Contains(car.index)) { continue; } indexes.Add(car.index); result += car.ToString(now) + "\n"; } await args.Callback(string.IsNullOrEmpty(result)? "myc" : result.Substring(0, result.Length - 1)); } }
public async Task Run(CommandArgs args) { string[] splits = args.Arg.Trim().Split('-'); DateTime start = DateTime.ParseExact(splits[0], "MMddHH", CultureInfo.CurrentCulture); DateTime end = DateTime.ParseExact(splits[1], "MMddHH", CultureInfo.CurrentCulture); await args.Callback(Configuration.GetConfig <PCRConfig>().Query(start, end, qq => args.Source.Session.GetName(args.Source.FromGroup, qq).Result)); }
public async Task Run(CommandArgs args) { var splits = args.Arg.Trim().Split(' '); string code; if (splits.Length != 5) { await args.Callback("必须有且只有五个角色!"); return; } code = await JJCManager.Instance.Callapi(splits); await args.Callback($"{args.Arg.Trim()}的解法:\n" + code); }
public void Run(CommandArgs args) { long arg; try { arg = long.Parse(args.Arg.Trim()); } catch { return; } try { var result = (arg > int.MaxValue ? client.CallUserApi($"/event/{eventId}/ranking?targetUserId={arg}", HttpMethod.Get, null) : client.CallUserApi($"/event/{eventId}/ranking?targetRank={arg}", HttpMethod.Get, null)).Result; var rank = result["rankings"].SingleOrDefault(); args.Callback(rank == null ? "找不到玩家" : $"排名为{rank["rank"]}的玩家是`{rank["name"]}`(uid={rank["userId"]}),分数为{rank["score"]}"); } catch (Exception e) { this.Log(LoggerLevel.Debug, e.ToString()); ClientReady().Wait(); } }
public async Task Run(CommandArgs args) { var cfg = Configuration.GetConfig <TokenConfig>(); cfg.t[args.Source.FromQQ] = args.Arg.Trim(); cfg.Save(); await args.Callback($"token of {args.Source.FromQQ} set to {args.Arg.Trim()}"); }
public async Task Run(CommandArgs args) { if (!await args.Source.HasPermission("chatrecord", -1)) { return; } await args.Callback(RecordDatabaseManager.CountContains(args.Arg).ToString()); }
public async Task Run(CommandArgs args) { var splits = args.Arg.Trim().Split(' '); string code; code = await JJCManager.Instance.Callapi(args.Arg.Trim()); await args.Callback($"{args.Arg.Trim()}的解法:\n" + code); }
public static void Main(CommandArgs args) { args.Callback(string.Join("\n", Configuration.GetConfig <ServerManager>().servers.Select((server) => { var arr = server.Value.RunRest("/v2/users/activelist")["activeusers"] .ToString().Split('\t').Where((s) => !string.IsNullOrWhiteSpace(s)).ToArray(); return($"当前{server.Key}在线的玩家有{arr.Length}个:\n{string.Join(" ", arr.Select(s => $"[{s}]"))}"); }))); }
public async Task Run(CommandArgs args) { var arg = args.Arg.Trim().Split(' '); var group = long.Parse(arg[0]); if (!await args.Source.CheckPermission(group)) { await args.Callback("access denied."); return; } var type = Enum.Parse <CarType>(arg[1]); Configuration.GetConfig <CarTypeConfig>()[group] = type; await args.Callback($"car type of {group} set to {type}"); }
public async Task Run(CommandArgs args) { string[] arg = args.Arg.Trim().Split(' '); long group = long.Parse(arg[0]); if (!await args.Source.HasPermission("management.cartype", group)) { await args.Callback("access denied."); return; } CarType type = Enum.Parse <CarType>(arg[1]); Configuration.GetConfig <CarTypeConfig>()[group] = type; await args.Callback($"car type of {group} set to {type}"); }
public async Task Run(CommandArgs args) { args.Arg = args.Arg.Trim(); if (args.Arg.Length == 0) { Configuration.GetConfig <Activation>()[args.Source.FromQQ] = Status; await args.Callback($"个人车牌转发已{GetTrans(Status)}"); } else { long group; try { if (args.Arg == "~" && args.Source.FromGroup > 0) { group = args.Source.FromGroup; } else { List <GroupMemberInfo> source; group = long.Parse(args.Arg); if (!await args.Source.CheckPermission()) { source = (await args.Source.Session.GetMemberList(group)).Where((GroupMemberInfo info) => (info.QQId == args.Source.FromQQ)).ToList(); if (source.Count == 0 || source[0].PermitType == PermitType.None) { await args.Callback("权限不足"); return; } } } } catch (Exception) { await args.Callback("群号错误"); return; } Configuration.GetConfig <Activation>()[group] = Status; await args.Callback($"{group}的车牌转发已{GetTrans(Status)}"); } }
public async Task Run(CommandArgs args) { var match = new Regex(@"^\[mirai:at=(.*?)\] (.*)$").Match(args.Arg.Trim()); if (!match.Success) { await args.Callback("代刀 @xxx 伤害"); return; } int damage; long qq = long.Parse(match.Groups[1].Value); try { damage = int.Parse(match.Groups[2].Value); if (damage < 0) { await args.Callback("伤害不能是负数!"); return; } } catch { await args.Callback("格式错误,请输入数字!"); return; } try { await args.Callback(string.Format(Configuration.GetConfig <PCRConfig>().Add(qq, damage), args.Source.Session.GetName(args.Source.FromGroup, qq))); } catch (Exception e) { await args.Callback(e.Message); return; } }
public void Run(CommandArgs args) { try { int expected = int.Parse(args.Arg.Trim()); expected = Math.Max(0, Math.Min(60, expected)); Configuration.GetConfig <Config.Delay>()[args.Source.FromQQ] = expected; args.Callback($"车牌转发延迟已更改为{expected}秒"); } catch { } }
public static void Main(CommandArgs args, string username, long qq, string server) { var binding = Configuration.GetConfig <AccountBinding>().list; if (binding.Any((o) => (string)o["username"] == username || (long)o["qq"] == qq)) { args.Callback("已经绑定过了!"); return; } binding.Add(new JObject { ["username"] = username, ["qq"] = qq, ["group"] = Configuration.GetConfig <ServerManager>().servers[server].group }); Configuration.GetConfig <AccountBinding>().Save(); args.Callback($"已绑定 {username}<=>{qq}"); }
public async Task Run(CommandArgs args) { string[] splits = args.Arg.Trim().Split('-'); DateTime start = DateTime.ParseExact(splits[0], "MMddHH", CultureInfo.CurrentCulture); DateTime end = DateTime.ParseExact(splits[1], "MMddHH", CultureInfo.CurrentCulture); var name = args.Arg.Trim() + ".csv"; File.WriteAllText(name, Configuration.GetConfig <PCRConfig>().GetCSV(start, end, qq => args.Source.Session.GetName(args.Source.FromGroup, qq).Result), Encoding.UTF8); await args.Callback($"数据已保存到{args.Arg.Trim() + ".csv"}"); }
protected sealed override void Run(CommandArgs args) { args.Arg = args.Arg.Trim(); if (args.Arg.Length == 0) { Configuration.GetConfig <Activation>()[args.Source.FromQQ] = Status; args.Callback($"个人车牌转发已{GetTrans(Status)}"); } else { long group; try { if (args.Arg == "~" && args.Source.FromGroup > 0) { group = args.Source.FromGroup; } else { List <GroupMemberInfo> source; group = long.Parse(args.Arg); if (!args.IsAdmin) { source = Common.CqApi.GetMemberList(group).Where((GroupMemberInfo info) => (info.QQId == args.Source.FromQQ)).ToList(); if (source.Count == 0 || source[0].PermitType == PermitType.None) { args.Callback("权限不足"); return; } } } } catch (Exception) { args.Callback("群号错误"); return; } Configuration.GetConfig <Activation>()[group] = Status; args.Callback($"{group}的车牌转发已{GetTrans(Status)}"); } }
public async Task Run(CommandArgs args) { var splits = args.Arg.Trim().Split(' '); var group = long.Parse(splits[0]); var qq = long.Parse(splits[1]); var id = int.Parse(splits[2]); if (!await args.Source.HasPermission("management.antirevoke", group) && qq != args.Source.FromQQ) { return; } await args.Callback(RecordDatabaseManager.GetRecords().Where(r => r.qq == qq && r.group == group).SkipLast(id).LastOrDefault()?.message ?? ""); }