Browse Source

update due to gumble API changes

master
Tim Cooper 10 years ago
parent
commit
b56133e033
3 changed files with 14 additions and 14 deletions
  1. +4
    -4
      client.go
  2. +4
    -4
      ui.go
  3. +6
    -6
      ui_tree.go

+ 4
- 4
client.go View File

@@ -11,8 +11,8 @@ func (b *Barnard) OnConnect(e *gumble.ConnectEvent) {
b.UiTree.Rebuild() b.UiTree.Rebuild()
b.Ui.Refresh() 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 != "" { if e.WelcomeMessage != "" {
b.AddOutputLine(fmt.Sprintf("Welcome message: %s", esc(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) { 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.UiTree.Rebuild()
b.Ui.Refresh() b.Ui.Refresh()


+ 4
- 4
ui.go View File

@@ -39,7 +39,7 @@ func (b *Barnard) AddOutputMessage(sender *gumble.User, message string) {
if sender == nil { if sender == nil {
b.AddOutputLine(message) b.AddOutputLine(message)
} else { } 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 == "" { if text == "" {
return 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 View File

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


func (ti TreeItem) String() string { func (ti TreeItem) String() string {
if ti.User != nil { if ti.User != nil {
return ti.User.Name()
return ti.User.Name
} }
if ti.Channel != nil { if ti.Channel != nil {
return ti.Channel.Name()
return ti.Channel.Name
} }
return "" 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) { func (b *Barnard) TreeItemSelect(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm.TreeItem) {
treeItem := item.(TreeItem) treeItem := item.(TreeItem)
if treeItem.Channel != nil { 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 { func (b *Barnard) TreeItem(item uiterm.TreeItem) []uiterm.TreeItem {
var treeItem TreeItem var treeItem TreeItem
if ti, ok := item.(TreeItem); !ok { if ti, ok := item.(TreeItem); !ok {
root := b.Client.Channels()[0]
root := b.Client.Channels[0]
if root == nil { if root == nil {
return nil return nil
} }
@@ -58,14 +58,14 @@ func (b *Barnard) TreeItem(item uiterm.TreeItem) []uiterm.TreeItem {
} }


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


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


Loading…
Cancel
Save