Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesBreslin committed Jul 4, 2019
1 parent 2b22e42 commit d6c4a9a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func main() {
rock, err := rocket.NewConnectionConfig("rb.cfg")

rock.UserTemporaryStatus(rocket.STATUS_AWAY)
rock.ListEmojis()

// If there was an error connecting, panic
if err != nil {
Expand Down Expand Up @@ -65,4 +64,4 @@ func main() {
msg.React(":grinning:")
}
}
}
}
14 changes: 8 additions & 6 deletions rocket/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ func (rock *rocketCon) handleMessageObject(obj map[string] interface{}) message
if attachments, ok := obj["attachments"]; ok && attachments != nil {
msg.Attachments = make([]attachment,0)
for _, val := range attachments.([]interface{}) {
var attach attachment
attach.Description = val.(map[string] interface{})["description"].(string)
attach.Title = val.(map[string] interface{})["title"].(string)
attach.Link = val.(map[string] interface{})["title_link"].(string)
attach.Type = val.(map[string] interface{})["type"].(string)
msg.Attachments = append(msg.Attachments, attach)
if _, ok := val.(map[string] interface{})["description"]; ok {
var attach attachment
attach.Description = val.(map[string] interface{})["description"].(string)
attach.Title = val.(map[string] interface{})["title"].(string)
attach.Link = val.(map[string] interface{})["title_link"].(string)
attach.Type = val.(map[string] interface{})["type"].(string)
msg.Attachments = append(msg.Attachments, attach)
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions rocket/rocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ const STATUS_BUSY string = "busy"
const STATUS_AWAY string = "away"
const STATUS_OFFLINE string = "offline"

func NewConnection(username string, password string) (rocketCon, error) {
func NewConnection(domain string, username string, password string) (rocketCon, error) {
var rock rocketCon
rock.HostName = domain
rock.UserName = username
rock.Password = password
rock.init()
return rock, nil
}

func NewConnectionAuthToken(authtoken string) (rocketCon, error) {
func NewConnectionAuthToken(domain string, authtoken string) (rocketCon, error) {
var rock rocketCon
rock.HostName = domain
rock.AuthToken = authtoken
rock.init()
return rock, nil
Expand Down

0 comments on commit d6c4a9a

Please sign in to comment.