Bläddra i källkod

update due to gumble API changes

master
Tim Cooper 10 år sedan
förälder
incheckning
b56133e033
3 ändrade filer med 14 tillägg och 14 borttagningar
  1. +4
    -4
      client.go
  2. +4
    -4
      ui.go
  3. +6
    -6
      ui_tree.go

+ 4
- 4
client.go Visa fil

@@ -11,8 +11,8 @@ func (b *Barnard) OnConnect(e *gumble.ConnectEvent) {
b.UiTree.Rebuild()
b.Ui.Refresh()

b.UpdateInputStatus(fmt.Sprintf("To: %s", e.Client.Self().Channel().Name()))
b.AddOutputLine(fmt.Sprintf("Connected to %s", b.Client.Conn().RemoteAddr()))
b.UpdateInputStatus(fmt.Sprintf("To: %s", e.Client.Self.Channel.Name))
b.AddOutputLine(fmt.Sprintf("Connected to %s", b.Client.Conn.RemoteAddr()))
if e.WelcomeMessage != "" {
b.AddOutputLine(fmt.Sprintf("Welcome message: %s", esc(e.WelcomeMessage)))
}
@@ -56,8 +56,8 @@ func (b *Barnard) OnTextMessage(e *gumble.TextMessageEvent) {
}

func (b *Barnard) OnUserChange(e *gumble.UserChangeEvent) {
if e.Type.Has(gumble.UserChangeChannel) && e.User == b.Client.Self() {
b.UpdateInputStatus(fmt.Sprintf("To: %s", e.User.Channel().Name()))
if e.Type.Has(gumble.UserChangeChannel) && e.User == b.Client.Self {
b.UpdateInputStatus(fmt.Sprintf("To: %s", e.User.Channel.Name))
}
b.UiTree.Rebuild()
b.Ui.Refresh()


+ 4
- 4
ui.go Visa fil

@@ -39,7 +39,7 @@ func (b *Barnard) AddOutputMessage(sender *gumble.User, message string) {
if sender == nil {
b.AddOutputLine(message)
} else {
b.AddOutputLine(fmt.Sprintf("%s: %s", sender.Name(), strings.TrimSpace(esc(message))))
b.AddOutputLine(fmt.Sprintf("%s: %s", sender.Name, strings.TrimSpace(esc(message))))
}
}

@@ -96,9 +96,9 @@ func (b *Barnard) OnTextInput(ui *uiterm.Ui, textbox *uiterm.Textbox, text strin
if text == "" {
return
}
if b.Client != nil && b.Client.Self() != nil {
b.Client.Self().Channel().Send(text, false)
b.AddOutputMessage(b.Client.Self(), text)
if b.Client != nil && b.Client.Self != nil {
b.Client.Self.Channel.Send(text, false)
b.AddOutputMessage(b.Client.Self, text)
}
}



+ 6
- 6
ui_tree.go Visa fil

@@ -12,10 +12,10 @@ type TreeItem struct {

func (ti TreeItem) String() string {
if ti.User != nil {
return ti.User.Name()
return ti.User.Name
}
if ti.Channel != nil {
return ti.Channel.Name()
return ti.Channel.Name
}
return ""
}
@@ -33,14 +33,14 @@ func (ti TreeItem) TreeItemStyle(fg, bg uiterm.Attribute, active bool) (uiterm.A
func (b *Barnard) TreeItemSelect(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm.TreeItem) {
treeItem := item.(TreeItem)
if treeItem.Channel != nil {
b.Client.Self().Move(treeItem.Channel)
b.Client.Self.Move(treeItem.Channel)
}
}

func (b *Barnard) TreeItem(item uiterm.TreeItem) []uiterm.TreeItem {
var treeItem TreeItem
if ti, ok := item.(TreeItem); !ok {
root := b.Client.Channels()[0]
root := b.Client.Channels[0]
if root == nil {
return nil
}
@@ -58,14 +58,14 @@ func (b *Barnard) TreeItem(item uiterm.TreeItem) []uiterm.TreeItem {
}

users := []uiterm.TreeItem{}
for _, user := range treeItem.Channel.Users() {
for _, user := range treeItem.Channel.Users {
users = append(users, TreeItem{
User: user,
})
}

channels := []uiterm.TreeItem{}
for _, subchannel := range treeItem.Channel.Channels() {
for _, subchannel := range treeItem.Channel.Children {
channels = append(channels, TreeItem{
Channel: subchannel,
})


Laddar…
Avbryt
Spara