Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Apr 7, 2024
1 parent bd2798e commit ba76021
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion api/grpc/tgbot/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/awakari/bot-telegram/service"
"github.com/awakari/bot-telegram/service/chats"
"github.com/awakari/bot-telegram/service/messages"
"github.com/awakari/bot-telegram/service/subscriptions"
"github.com/awakari/client-sdk-go/api"
"github.com/awakari/client-sdk-go/model/subscription"
tgverifier "github.com/electrofocus/telegram-auth-verifier"
Expand Down Expand Up @@ -142,7 +143,7 @@ func (c controller) Subscribe(ctx context.Context, req *SubscribeRequest) (resp
var d subscription.Data
d, err = c.clientAwk.ReadSubscription(groupIdCtx, userId, subId)
if err == nil {
_ = tgCtx.Send(fmt.Sprintf("New subscription \"%s\" is linked to this chat", d.Description))
_ = tgCtx.Send(fmt.Sprintf(subscriptions.MsgFmtChatLinked, d.Description, intervalDefault), telebot.ModeHTML, telebot.NoPreview)
}
}
return
Expand Down
4 changes: 2 additions & 2 deletions service/chats/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ func (r *reader) checkExpiration(groupIdCtx context.Context) {
switch {
case sd.Expires.IsZero(): // never expires
case sd.Expires.Before(time.Now().UTC()):
_ = r.tgCtx.Send(msgExpired + fmt.Sprintf(msgFmtExtendSteps, sd.Description))
_ = r.tgCtx.Send(msgExpired + msgFmtExtendSteps)
case sd.Expires.Sub(time.Now().UTC()) < 168*time.Hour: // expires earlier than in 1 week
_ = r.tgCtx.Send(fmt.Sprintf(msgExpiresSoon, sd.Expires.Sub(time.Now().UTC()).Round(time.Minute)) + fmt.Sprintf(msgFmtExtendSteps, sd.Description))
_ = r.tgCtx.Send(fmt.Sprintf(msgExpiresSoon, sd.Expires.Sub(time.Now().UTC()).Round(time.Minute)) + msgFmtExtendSteps)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions service/subscriptions/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
)

const CmdStart = "sub_start"
const msgFmtChatLinked = "Linked the subscription \"%s\" to this chat. " +
"New matching messages will appear here with a minimum interval of %s. " +
"Use the <a href=\"https://awakari.com/login.html\" target=\"blank\">app</a> to manage own subscriptions."
const MsgFmtChatLinked = "Linked the subscription \"%s\" to this chat. " +
"New results will appear here. Min interval: %s. " +
"To manage own subscriptions use the <a href=\"https://awakari.com/login.html\" target=\"blank\">app</a>."

var deliveryIntervalRows = [][]string{
{
Expand Down Expand Up @@ -115,7 +115,7 @@ func start(
subData, err = clientAwk.ReadSubscription(groupIdCtx, userId, subId)
}
if err == nil {
err = tgCtx.Send(fmt.Sprintf(msgFmtChatLinked, subData.Description, minInterval), telebot.ModeHTML)
err = tgCtx.Send(fmt.Sprintf(MsgFmtChatLinked, subData.Description, minInterval), telebot.ModeHTML, telebot.NoPreview)
}
if err == nil {
r := chats.NewReader(tgCtx, clientAwk, chatStor, chat.Id, chat.SubId, groupId, userId, msgFmt, minInterval)
Expand Down

0 comments on commit ba76021

Please sign in to comment.