public string getGMemberName(long group, long qq) { try { return(session.GetGroupMemberInfoAsync(qq, group).Result.Name); } catch { return(null); } }
public static async Task <string> GetName(this MiraiHttpSession session, long group, long qq) { try { return((await session.GetGroupMemberInfoAsync(qq, group)).Name); } catch (Exception e) { Log(LoggerLevel.Error, e.ToString()); return(qq.ToString()); } }
internal GameAPI(long group, long qqID, MiraiHttpSession Session) { this.Session = Session; groupPath = "com.coc.groupadmin\\" + group; MemberFile = "com.coc.groupadmin\\" + group + "\\" + qqID + ".bin"; if (!Directory.Exists(groupPath)) { Directory.CreateDirectory(groupPath); } if (!File.Exists(MemberFile)) { var Member = new GroupMemberInfo() { GroupId = group, QQId = qqID, Card = Session.GetGroupMemberInfoAsync(qqID, group).Result.Name }; GameMember gameMember; gameMember = new GameMember { Member = Member, Cash = 100, Exp = 100, Work = Work.给野蛮人刷背, Checked = DateTime.MinValue, Combo = 0, CurrentHP = 100, weapon = new None(), Robbed = DateTime.MinValue, PlayTime = DateTime.MinValue }; var writer = new XmlSerializer(typeof(GameMember)); using StreamWriter stream = new StreamWriter(MemberFile); writer.Serialize(stream, gameMember); } else { //Weird error if (File.ReadAllText(MemberFile).Contains("</GameMember>d>")) { File.WriteAllText(MemberFile, File.ReadAllText(MemberFile).Replace("</GameMember>d>", "")); } } try { XmlSerializer reader = new XmlSerializer(typeof(GameMember)); using (FileStream stream = new FileStream(MemberFile, FileMode.Open)) { this.Member = (GameMember)reader.Deserialize(stream); } foreach (Type type in Assembly.GetAssembly(typeof(Element)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(Element)))) { elements.Add((Element)Activator.CreateInstance(type)); } } catch (Exception ex) { Session.SendGroupMessage(group, new PlainMessage(qqID + "资料损毁,错误资料:" + ex.Message)); } }
public static Task <IGroupMemberCardInfo> GetGroupMemberCardAsync(long groupID, long qqID) => session.GetGroupMemberInfoAsync(qqID, groupID);