private async Task GetHAVersion() { HomeAssistantVersion ha = GetHAVersions(); var embed = new EmbedBuilder(); embed.WithTitle("Estas são as versões mais recentes do Home Assistant.\n"); embed.WithColor(Helper.GetRandomColor()); if (null != ha) { // embed.AddInlineField("As of", DateTime.Now.ToShortDateString()); embed.AddInlineField("Stable", ha.Stable); embed.AddInlineField("Beta", ha.Beta); } // mention users if any string mentionedUsers = base.MentionedUsers(); if (string.Empty != mentionedUsers) { embed.AddInlineField("FYI", mentionedUsers); } await ReplyAsync(string.Empty, false, embed); }
private async Task GetHAVersion() { HomeAssistantVersion ha = GetHAVersions(); string emoji = Constants.EMOJI_HOMEASSISTANT; string title = "Here are the current Home Assistant software versions."; string body = null; var inline = new List <Tuple <string, string> >(); if (null != ha) { inline.Add(new Tuple <string, string>("Stable", ha.Stable)); inline.Add(new Tuple <string, string>("Beta", ha.Beta)); } // mention users if any string mentionedUsers = base.MentionedUsers(); if (string.Empty != mentionedUsers) { body = string.Format("FYI {0} \n", mentionedUsers) + body; } // Send response await Helper.CreateEmbed(Context, emoji, title, body, inline, true); }
public static HomeAssistantVersion GetHAVersions() { string json = HassBotUtils.Utils.DownloadURLString(HA_STABLE); if (json == string.Empty) { logger.Error("Empty data received when downloading " + HA_STABLE); return null; } HomeAssistantVersion ha = new HomeAssistantVersion(); try { dynamic entries = JsonConvert.DeserializeObject(json); foreach (dynamic item in entries) { if (item.prerelease == false && item.draft == false) { ha.Stable = item.name; break; } } foreach (dynamic item in entries) { if (item.prerelease == true && item.draft == false) { ha.Beta = item.name; break; } } } catch (Exception e) { logger.Error(e); } return ha; }
private async Task GetHAVersion() { HomeAssistantVersion ha = GetHAVersions(); string emoji = Constants.EMOJI_HOMEASSISTANT; string title = "Here are the current Home Assistant software versions."; string body = null; var inline = new List <Tuple <string, string> >(); if (null != ha) { inline.Add(new Tuple <string, string>("Stable", ha.Stable)); inline.Add(new Tuple <string, string>("Beta", ha.Beta)); } // Send response await CreateEmbed(Context, emoji, title, body, inline, true); }