private void OnGroupMemberIncreased(IQqBot sender, GroupMemberIncreaseEventArgs e) { // debug新成员事件 string debug = $"gr:{e.GroupId}, us:{e.UserId}, op:{e.OperatorId}\r\n{e.Time}"; sender.SendGroupMessageAsync(72318078, debug, true); // 欢迎(在新人群) if (e.GroupId == GroupId) { Logger.Log("start welcome"); long newUser = e.UserId; long?uid = FindUid(newUser).Result; if (uid == 0) { return; } string username = null; if (uid.HasValue) { username = FindUsername(uid.Value).Result; } sender.SendGroupMessageAsync(e.GroupId, (username != null ? username + "," : "") + "你好,欢迎来到新人群"); Logger.Log("end welcome"); } }
public OsuQqBot(IQqBot qqBot) { qq = qqBot; QqApi = qq; CurrentQq = qq.GetLoginQq(); Config config = JsonConvert.DeserializeObject <Config>(File.ReadAllText(Paths.JsonConfigPath)); id_Kamisama = config.Kamisama; IdWhoLovesInt100Best = id_Kamisama; GroupId = config.MainGroup; foreach (var item in config.ValidGroups) { ValidGroups.Add(item); } try { var ignoreLines = File.ReadAllLines(Paths.IgnoreListPath); if (ignoreLines.Length == 2) { ignoreList = JsonConvert.DeserializeObject <HashSet <long> >(ignoreLines[0]); ignorePPList = JsonConvert.DeserializeObject <HashSet <long> >(ignoreLines[1]); } } catch (FileNotFoundException) { } if (ignoreList == null) { ignoreList = new HashSet <long>(); } if (ignorePPList == null) { ignorePPList = new HashSet <long>(); } osuApiKey = config.ApiKey; apiClient = new OsuApiClient(config.ApiKey); qq.GroupAdminChange += OnGroupAdminChanged; qq.GroupMemberIncrease += OnGroupMemberIncreased; }
private static void OnGroupAdminChanged(IQqBot sender, GroupAdminChangeEventArgs e) { string message; switch (e.Type) { case GroupAdminChangeEventArgs.GroupAdminChangeType.Set: message = "新的狗管理诞生了"; break; case GroupAdminChangeEventArgs.GroupAdminChangeType.Unset: message = "从现在起,你就是狗群员了,给我老实点"; break; default: return; } message = sender.At(e.UserId) + " " + message; sender.SendGroupMessageAsync(e.GroupId, message); e.Handled = true; }