private void CacheGroupRoles(object sender, GroupRolesDataReplyEventArgs e) { //MHE(MessageHandler.Destinations.DEST_LOCAL, UUID.Zero, "[debug] role_reply"); if (!Directory.Exists("GroupCache")) { Directory.CreateDirectory("GroupCache"); // this should be purged at every bot restart!!! } //MHE(MessageHandler.Destinations.DEST_LOCAL, UUID.Zero, "[debug] generating groupcache file"); OCGroupCaches newCache = new OCGroupCaches(); OCGroupCaches.GroupMemoryData gmd = new OCGroupCaches.GroupMemoryData(); foreach (KeyValuePair <UUID, GroupRole> roleData in e.Roles) { gmd.roleID = roleData.Value.ID; gmd.RoleName = roleData.Value.Name; gmd.Title = roleData.Value.Title; gmd.Powers = roleData.Value.Powers; newCache.GMD.Add(gmd); } newCache.GroupID = e.GroupID; newCache.Save(e.GroupID.ToString()); RoleReply.Set(); FileInfo fi = new FileInfo("GroupCache/" + e.GroupID.ToString() + ".json"); //MHE(MessageHandler.Destinations.DEST_LOCAL, UUID.Zero, "[debug] Roles for secondlife:///app/group/" + e.GroupID.ToString() + "/about have been saved to: GroupCache/" + e.GroupID.ToString() + ".bdf\nFileSize: "+fi.Length.ToString(), 55); }
public static OCGroupCaches Reload(string CustomName) { if (!File.Exists("GroupCache/" + CustomName + ".json")) { return(new OCGroupCaches()); } SerialManager sm = new SerialManager(); OCGroupCaches ocb = sm.Read <OCGroupCaches>("GroupCache/" + CustomName); if (ocb == null) { return(new OCGroupCaches()); } return(ocb); }
public void InviteToGroup(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCGroupCaches gc = new OCGroupCaches(); UUID groupID = UUID.Parse(additionalArgs[0]); UUID user = UUID.Parse(additionalArgs[1]); if (!File.Exists("GroupCache/" + additionalArgs[0] + ".json")) { BotSession.Instance.grid.Groups.RequestGroupRoles(groupID); } List <UUID> roles = new List <UUID>(); roles.Add(UUID.Zero); BotSession.Instance.grid.Groups.Invite(groupID, roles, user); }