func (account *account) createXMLConsoleItem(r *roster) gtki.MenuItem { consoleItem, _ := g.gtk.MenuItemNewWithMnemonic(i18n.Local("XML Console")) consoleItem.Connect("activate", func() { builder := newBuilder("XMLConsole") console := builder.getObj("XMLConsole").(gtki.Dialog) buf := builder.getObj("consoleContent").(gtki.TextBuffer) console.SetTransientFor(r.ui.window) console.SetTitle(strings.Replace(console.GetTitle(), "ACCOUNT_NAME", account.session.GetConfig().Account, -1)) log := account.session.GetInMemoryLog() buf.Delete(buf.GetStartIter(), buf.GetEndIter()) if log != nil { buf.Insert(buf.GetEndIter(), log.String()) } builder.ConnectSignals(map[string]interface{}{ "on_refresh_signal": func() { buf.Delete(buf.GetStartIter(), buf.GetEndIter()) if log != nil { buf.Insert(buf.GetEndIter(), log.String()) } }, "on_close_signal": func() { console.Destroy() }, }) console.ShowAll() }) return consoleItem }
func channelCheck(bot *irc.Conn, name string) (*query.Result, string, error) { log := bytes.NewBuffer([]byte{}) for _, method := range query.GetMethods() { res, err := method.Query(bot, name) if err == nil { return res, method.Name(), nil } fmt.Fprintf(log, "method %s failed: %s\n", method.Name(), err.Error()) } return nil, "", errors.New(log.String()) }