Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update go version to 1.23 and line-bot-sdk-go to v8.10.0; enha… #30

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kkdai/LineBotTemplate

// +heroku goVersion go1.21
go 1.21
go 1.23

require github.com/line/line-bot-sdk-go/v8 v8.2.0
require github.com/line/line-bot-sdk-go/v8 v8.10.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/line/line-bot-sdk-go/v8 v8.2.0 h1:IFqwd3pKbA+o3pwV3nzamtWHt7n+ijSH3t/D8Q/vVQ0=
github.com/line/line-bot-sdk-go/v8 v8.2.0/go.mod h1:n9Ly8OHM6xCeQktLzRpQHe/yBda95kFgmQUefUQeFCs=
github.com/line/line-bot-sdk-go/v8 v8.10.0 h1:rdlb+Qp2UGPgAnt0CWTHfPDxmTtQ0taGuiPsqj6LCfU=
github.com/line/line-bot-sdk-go/v8 v8.10.0/go.mod h1:9U4mY4kLAFSCSwPl1YxtqmG0Db19DnclpuYS5VOkOZY=
26 changes: 26 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ func callbackHandler(w http.ResponseWriter, r *http.Request) {
switch message := e.Message.(type) {
// Handle only on text message
case webhook.TextMessageContent:
// If it is in group message, check if mention me.
switch e.Source.(type) {
case webhook.GroupSource:
case webhook.RoomSource:
for _, mention := range message.Mention.Mentionees {
botID := ""
botResponse, err := bot.GetBotInfo().Do()
if err != nil {
botID = botResponse.BasicID
fmt.Println("Bot ID=", botID)
}
switch mention.GetType() {
case "user":
botMention := mention.(*webhook.UserMentionee)
fmt.Println("Mentioned user ID=", botMention.UserId, " isSelf=", botMention.IsSelf)

if botMention.IsSelf {
if _, err = bot.ReplyMessage(e.ReplyToken, linebot.NewTextMessage("你找我嗎?")).Do(); err != nil {
log.Print(err)
}
return
}
}
}
}

// GetMessageQuota: Get how many remain free tier push message quota you still have this month. (maximum 500)
quota, err := bot.GetMessageQuota().Do()
if err != nil {
Expand Down
Loading