public static async Task eventVcUserList(HttpListenerContext c) { var auth = c.GetEventManagerAuth(); if (auth == null) { return; } // Get the users var users = EventVCHandler.CurrentVcUsers; string html = ""; foreach (var user in users) { string pfp = user.GetAvatarUrl(Discord.ImageFormat.Jpeg); if (pfp == null) { pfp = user.GetDefaultAvatarUrl(); } html += Properties.Resources.VoicekickPopupUser .Replace("{user.profile}", pfp) .Replace("{user.id}", user.Id.ToString()) .Replace("{user.displayName}", user.Nickname != null ? user.Nickname : user.Username); } c.Response.ContentType = "text/html"; c.Response.OutputStream.Write(Encoding.UTF8.GetBytes(html)); c.Response.ContentEncoding = Encoding.UTF8; c.Response.StatusCode = 200; c.Response.Close(); }
public static async Task eventManagerPage(HttpListenerContext c) { var user = c.GetEventManagerAuth(); if (user == null) { return; } if (user.ID == 619241308912877609) { c.Response.ContentType = "text/html"; c.Response.ContentEncoding = Encoding.UTF8; c.Response.OutputStream.Write(Encoding.UTF8.GetBytes("<h1>No liege</h1>")); c.Response.StatusCode = 200; c.Response.Close(); return; } // Serve the page string html = Properties.Resources.EventManager; c.Response.ContentType = "text/html"; c.Response.ContentEncoding = Encoding.UTF8; c.Response.OutputStream.Write(Encoding.UTF8.GetBytes(html)); c.Response.StatusCode = 200; c.Response.Close(); }
public static async Task json(HttpListenerContext c) { // This will be used to populate the javascript arrays on the page load var user = c.GetEventManagerAuth(); if (user == null) { return; } // Generate the json EventJson json = new EventJson(); json.users = EventVCHandler.users; json.kicks = VoiceKickHandler.CurrentVoiceKicked; string jsonString = JsonConvert.SerializeObject(json); c.Response.ContentEncoding = Encoding.UTF8; c.Response.ContentType = "text/json"; c.Response.OutputStream.Write(Encoding.UTF8.GetBytes(jsonString)); c.Response.StatusCode = 200; c.Response.Close(); }
public static async Task eventVoicekickUser(HttpListenerContext c, MatchCollection m) { // Check auth var user = c.GetEventManagerAuth(); if (user == null) { return; } // Get the id var id = c.Request.QueryString["id"]; var vcUser = VoiceKickHandler.CurrentVoiceKicked.FirstOrDefault(x => x.id == id); if (vcUser == null) { c.Response.StatusCode = 404; c.Response.Close(); return; } string html = vcUser.ToHTML(); c.Response.ContentType = "text/html"; c.Response.ContentEncoding = Encoding.UTF8; c.Response.OutputStream.Write(Encoding.UTF8.GetBytes(html)); c.Response.StatusCode = 200; c.Response.Close(); }
public static async Task eventVc(HttpListenerContext c, MatchCollection m) { var user = c.GetEventManagerAuth(); if (user == null) { return; } // Get the requested user id var id = ulong.Parse(m[0].Groups[1].Value); // Get the user var gm = await Global.GetSwissbotUser(id); if (gm == null) { c.Response.StatusCode = 404; c.Response.Close(); return; } var pfp = gm.GetAvatarUrl(Discord.ImageFormat.Jpeg, 256); if (pfp == null) { pfp = gm.GetDefaultAvatarUrl(); } string displayName = gm.Username; if (gm.Nickname != null) { displayName = gm.Nickname; } var html = Properties.Resources.eventUser .Replace("{user.id}", gm.Id.ToString()) .Replace("{user.profile}", pfp) .Replace("{user.displayName}", displayName); c.Response.ContentType = "text/html"; c.Response.ContentEncoding = Encoding.UTF8; c.Response.OutputStream.Write(Encoding.UTF8.GetBytes(html)); c.Response.StatusCode = 200; }