[type]`",
&tele.SendOptions{ParseMode: tele.ModeMarkdown},
tele.Silent,
)
}
resp, err := hostcmds.Dig(req)
if err != nil {
_ = c.Reply(stickerFromID(stickerPanic), tele.Silent)
return err
}
replyBuf := &strings.Builder{}
tw := tabwriter.NewWriter(replyBuf, 0, 0, 2, ' ', 0)
// Write header
if len(resp.Records) > 0 {
_, _ = tw.Write([]byte("Name\tTTL\tType\tData\n"))
}
// Write data
for _, r := range resp.Records {
_, _ = fmt.Fprintf(tw, "%s\t%d\t%s\t%s\n", r.Name, r.TTL, r.Type, r.Data)
}
_ = tw.Flush()
replyText := []string{
fmt.Sprintf("Status: %s\n", resp.Status),
fmt.Sprintf("Query Time: %s\n\n", resp.QueryTime),
"",
html.EscapeString(replyBuf.String()),
"
",
}
return c.Reply(strings.Join(replyText, ""), &tele.SendOptions{ParseMode: tele.ModeHTML}, tele.Silent)
}