forked from Dsummers91/lisk-tip-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtipbot.go
35 lines (30 loc) · 904 Bytes
/
tipbot.go
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
package main
import (
"strings"
"./user"
"github.com/turnage/graw/reddit"
)
type liskTipBot struct {
bot reddit.Bot
}
func (r *liskTipBot) Comment(p *reddit.Comment) error {
if strings.Contains(p.Body, "!lisktip ") {
amount := strings.SplitAfter(p.Body, "!lisktip ")[1]
amount = strings.Split(amount, " ")[0]
initiateTip(p.Author, amount, p.ID)
return r.bot.Reply(p.Name, "This triggered lisk tip for an amout of "+amount+" LSK")
}
if strings.Contains(p.Body, "!tiplisk ") {
amount := strings.SplitAfter(p.Body, "!tiplisk ")[1]
amount = strings.Split(amount, " ")[0]
initiateTip(p.Author, amount, p.ID)
return r.bot.Reply(p.Name, "This triggered lisk tip for an amout of "+amount+" LSK")
}
return nil
}
func initiateTip(username string, amount string, commentID string) error {
usr := user.GetUser(username)
usr.GetUserData()
usr.SendLisk(amount, username)
return nil
}