github.com/line/line-bot-sdk-go/v7@v7.21.0/examples/delivery_helper/main.go (about) 1 // Copyright 2019 LINE Corporation 2 // 3 // LINE Corporation licenses this file to you under the Apache License, 4 // version 2.0 (the "License"); you may not use this file except in compliance 5 // with the License. You may obtain a copy of the License at: 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations 13 // under the License. 14 15 package main 16 17 import ( 18 "flag" 19 "log" 20 "os" 21 22 "github.com/line/line-bot-sdk-go/v7/linebot" 23 ) 24 25 func main() { 26 var ( 27 mode = flag.String("mode", "reply", "mode of delivery helper [multicast|reply|push]") 28 date = flag.String("date", "", "date the messages were sent, format 'yyyyMMdd'") 29 ) 30 flag.Parse() 31 bot, err := linebot.New( 32 os.Getenv("CHANNEL_SECRET"), 33 os.Getenv("CHANNEL_TOKEN"), 34 ) 35 if err != nil { 36 log.Fatal(err) 37 } 38 39 var res *linebot.MessagesNumberResponse 40 switch *mode { 41 case "multicast": 42 res, err = bot.GetNumberMulticastMessages(*date).Do() 43 case "push": 44 res, err = bot.GetNumberPushMessages(*date).Do() 45 case "reply": 46 res, err = bot.GetNumberReplyMessages(*date).Do() 47 case "broadcast": 48 res, err = bot.GetNumberBroadcastMessages(*date).Do() 49 default: 50 log.Fatal("implement me") 51 } 52 if err != nil { 53 log.Fatal(err) 54 } 55 log.Printf("%v", res) 56 }