-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessages.go
More file actions
37 lines (30 loc) · 794 Bytes
/
messages.go
File metadata and controls
37 lines (30 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"fmt"
"strings"
utopiago "github.com/Sagleft/utopialib-go"
)
func (app *solution) onContactMessage(m utopiago.InstantMessage) {
fmt.Println("[CONTACT] " + m.Nick + ": " + m.Text) // placeholder
}
func (app *solution) onChannelMessage(m utopiago.ChannelMessage) {
if m.Text == "" {
return
}
if strings.ToLower(m.Text) == "crypton rate" {
rate, err := app.getCryptonPrice()
if err != nil {
app.onError(err)
return
}
msg := "1 [diamond] = " + formatFloat(float64(rate), 2) + "$"
_, err = app.Config.Utopia.SendChannelMessage(m.ChannelID, msg)
if err != nil {
app.onError(err)
return
}
}
}
func (app *solution) onPrivateChannelMessage(m utopiago.ChannelMessage) {
fmt.Println("[PRIVATE] " + m.Nick + ": " + m.Text) // placeholder
}