mirror of
https://github.com/nikoksr/notify.git
synced 2025-02-09 13:13:44 +02:00
fix: adjust code style
This commit is contained in:
parent
394a51da71
commit
720b9e73a3
@ -25,6 +25,7 @@ func New(channelSecret, channelAccessToken string) (*Line, error) {
|
||||
l := &Line{
|
||||
client: bot,
|
||||
}
|
||||
|
||||
return l, nil
|
||||
}
|
||||
|
||||
@ -40,15 +41,14 @@ func (l *Line) Send(ctx context.Context, subject, message string) error {
|
||||
Text: subject + "\n" + message,
|
||||
}
|
||||
|
||||
for _, destinationID := range l.receiverIDs {
|
||||
for _, receiverID := range l.receiverIDs {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
|
||||
default:
|
||||
_, err := l.client.PushMessage(destinationID, lineMessage).WithContext(ctx).Do()
|
||||
_, err := l.client.PushMessage(receiverID, lineMessage).WithContext(ctx).Do()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to send message to line. destination id: '%s'", destinationID)
|
||||
return errors.Wrapf(err, "failed to send message to LINE contact '%s'", receiverID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,14 @@ func main() {
|
||||
lineService.AddReceivers("userID1", "groupID1")
|
||||
|
||||
notifier := notify.New()
|
||||
|
||||
// Tell our notifier to use the line service. You can repeat the above process
|
||||
// for as many services as you like and just tell the notifier to use them.
|
||||
notifier.UseServices(lineService)
|
||||
|
||||
// Send a message
|
||||
err := notifier.Send(context.Background(),
|
||||
err := notifier.Send(
|
||||
context.Background(),
|
||||
"Welcome",
|
||||
"I am a bot written in Go!",
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user