From 226bb214b98ace0858b5f5ed6b6916e6bcfb656d Mon Sep 17 00:00:00 2001
From: Andrei Kurilov <18027129+akurilov@users.noreply.github.com>
Date: Tue, 11 Jun 2024 19:42:03 +0300
Subject: [PATCH] feat: rename subscriptions to interests
---
main.go | 4 ++--
service/chats/error.go | 2 +-
service/chats/handler.go | 4 ++--
service/messages/format.go | 4 ++--
service/messages/format_test.go | 2 +-
service/prices.go | 8 ++++----
service/subscriptions/condition.go | 2 +-
service/subscriptions/create.go | 14 +++++++-------
service/subscriptions/description.go | 2 +-
service/subscriptions/extend.go | 10 +++++-----
service/subscriptions/list.go | 4 ++--
service/subscriptions/start.go | 4 ++--
service/subscriptions/stop.go | 2 +-
service/usage/limits.go | 4 ++--
14 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/main.go b/main.go
index 92609cf..228c84b 100644
--- a/main.go
+++ b/main.go
@@ -209,7 +209,7 @@ func main() {
},
{
Text: "app",
- Description: "Manage Subscriptions and Publishing in Application",
+ Description: "Manage Interests and Publishing in the Application",
},
{
Text: "pub",
@@ -217,7 +217,7 @@ func main() {
},
{
Text: "sub",
- Description: "Subscribe for Keywords",
+ Description: "Follow a new basic interest",
},
{
Text: "donate",
diff --git a/service/chats/error.go b/service/chats/error.go
index ff0bd1a..7d3f72d 100644
--- a/service/chats/error.go
+++ b/service/chats/error.go
@@ -3,5 +3,5 @@ package chats
import "errors"
var ErrAlreadyExists = errors.New("chat already exists")
-var ErrNotFound = errors.New("chat or subscription not found")
+var ErrNotFound = errors.New("chat or interest not found")
var ErrInternal = errors.New("internal failure")
diff --git a/service/chats/handler.go b/service/chats/handler.go
index 10b28e4..f25d68d 100644
--- a/service/chats/handler.go
+++ b/service/chats/handler.go
@@ -231,9 +231,9 @@ func (h handler) handleFloodError(ctx context.Context, tgCtx telebot.Context, su
return tgCtx.Send(
"โ High message rate detected. "+
"Results streaming stopped to prevent a further flood. "+
- "Typical cause: subscription's conditions are too vague. "+
+ "Typical cause: interest conditions are too vague. "+
"Review the subscription and make it more specific. "+
+ "\">interest and make it more specific. "+
"Link it back to a chat later using the /start command of the bot.",
telebot.ModeHTML,
)
diff --git a/service/messages/format.go b/service/messages/format.go
index c369b89..f15fd22 100644
--- a/service/messages/format.go
+++ b/service/messages/format.go
@@ -147,9 +147,9 @@ func (f Format) convert(evt *pb.CloudEvent, subId, subDescr string, mode FormatM
//
switch mode {
case FormatModeHtml:
- txt += "Subscription: " + subDescr + "\n\n"
+ txt += "Interest: " + subDescr + "\n\n"
default:
- txt += "Subscription: " + subDescr + "\n\n"
+ txt += "Interest: " + subDescr + "\n\n"
}
//
var attrsTxt string
diff --git a/service/messages/format_test.go b/service/messages/format_test.go
index 26a3e1a..b7b1701 100644
--- a/service/messages/format_test.go
+++ b/service/messages/format_test.go
@@ -62,7 +62,7 @@ Increase your daily publication limit or nominate own sources for the dedicated
If you did not publish messages, check own publication sourcessub1 description
+Interest: sub1 description
id: 82f39262-5eb4-4f7f-9142-7c489d670907
source: https://bbs.archlinux.org/extern.php?action=feed&fid=32&type=atom
diff --git a/service/prices.go b/service/prices.go
index 4789d8b..f63f4c2 100644
--- a/service/prices.go
+++ b/service/prices.go
@@ -12,7 +12,7 @@ type PricesHandler struct {
}
const fmtMsgPrices = `Always Free:
-๐ 1 subscription that never expires.
+๐ Follow up to 1 interest forever.
๐ Up to 20 message publications daily ยน.
๐ Adding own publishing sources.
@@ -20,19 +20,19 @@ const fmtMsgPrices = `Always Free:
Payments are currently in the test mode. There are no real money transfer.
Committed Usage:
- - Subscriptions quota ยฒ:
+ - Interests quota ยฒ:
%.2f per item-day
- Message publications quota ยณ:
%.2f per item-day
On Demand:
- - Extend a subscription time:
+ - Extend an interest following time:
%.2f per day
- Publish a message after the current limit is reached:
%.2f per message
(1) Includes the messages been published from added sources.
-(2) Starting from 2nd subscription.
+(2) Starting from 2nd interest.
(3) Starting from 11th message per day.`
func (ph PricesHandler) Prices(tgCtx telebot.Context) (err error) {
diff --git a/service/subscriptions/condition.go b/service/subscriptions/condition.go
index 5056672..f5f310c 100644
--- a/service/subscriptions/condition.go
+++ b/service/subscriptions/condition.go
@@ -51,7 +51,7 @@ func (ch ConditionHandler) Update(tgCtx telebot.Context, args ...string) (err er
err = ch.ClientAwk.UpdateSubscription(groupIdCtx, userId, subId, sd)
}
if err == nil {
- _ = tgCtx.Send("Subscription updated.")
+ _ = tgCtx.Send("Interest updated.")
}
return
}
diff --git a/service/subscriptions/create.go b/service/subscriptions/create.go
index d4280fb..2923006 100644
--- a/service/subscriptions/create.go
+++ b/service/subscriptions/create.go
@@ -25,13 +25,13 @@ const maxTextCondTermsLength = 256
const expiresDefaultDuration = time.Hour * 24 * usage.ExpiresDefaultDays // ~ month
const ReqSubCreate = "sub_create"
-const msgSubCreate = "Creating a simple text subscription. " +
+const msgSubCreate = "Following a simple text interest. " +
"Reply a name followed by keywords to the next message. Example:\n" +
"Wishlist1 tesla iphone
"
const msgSubCreated = "If you want to read it in another chat, unlink it first using the /start
command."
-var errCreateSubNotEnoughArgs = errors.New("not enough arguments to create a text subscription")
-var errInvalidCondition = errors.New("invalid subscription condition")
+var errCreateSubNotEnoughArgs = errors.New("not enough arguments to create a text interest")
+var errInvalidCondition = errors.New("invalid interest condition")
var errLimitReached = errors.New("limit reached")
var whiteSpaceRegex = regexp.MustCompile(`\p{Zs}+`)
@@ -77,12 +77,12 @@ func CreateBasicReplyHandlerFunc(
if err == nil {
err = start(tgCtx, clientAwk, svcReader, urlCallbackBase, subId, groupId)
} else {
- err = fmt.Errorf("failed to create the subscription:\n%w", err)
+ err = fmt.Errorf("failed to register the interest:\n%w", err)
}
if err == nil {
err = tgCtx.Send(msgSubCreated, telebot.ModeHTML)
} else {
- err = fmt.Errorf("failed to link the created subscription to this chat:\n%w", err)
+ err = fmt.Errorf("failed to follow the interest to this chat:\n%w", err)
}
return
}
@@ -133,7 +133,7 @@ func decodeNumOp(src subscriptions.Operation) (dst condition.NumOp) {
func validateSubscriptionData(sd subscription.Data) (err error) {
if sd.Description == "" {
- err = errors.New("invalid subscription:\nempty description")
+ err = errors.New("invalid interest:\nempty description")
}
if err == nil {
err = validateCondition(sd.Condition)
@@ -148,7 +148,7 @@ func validateCondition(cond condition.Condition) (err error) {
countChildren := len(children)
if tc.GetLogic() == condition.GroupLogicOr && countChildren > limitGroupOrCondChildrenCount {
err = fmt.Errorf(
- "%w:\nchildren condition count for the group condition with \"Or\" logic is %d, limit is %d,\nconsider to use an additional subscription instead",
+ "%w:\nchildren condition count for the group condition with \"Or\" logic is %d, limit is %d,\nconsider to follow an additional interest instead",
errInvalidCondition,
countChildren,
limitGroupOrCondChildrenCount,
diff --git a/service/subscriptions/description.go b/service/subscriptions/description.go
index ddae0a3..5df3d80 100644
--- a/service/subscriptions/description.go
+++ b/service/subscriptions/description.go
@@ -51,7 +51,7 @@ func DescriptionReplyHandlerFunc(clientAwk api.Client, groupId string) service.A
}
if err == nil {
// force reply removes the keyboard, hence don't forget to restore it
- err = tgCtx.Send(fmt.Sprintf("Subscription description changed to \"%s\"", descr))
+ err = tgCtx.Send(fmt.Sprintf("Interest description changed to \"%s\"", descr))
}
return
}
diff --git a/service/subscriptions/extend.go b/service/subscriptions/extend.go
index c7f13f4..d0efc2a 100644
--- a/service/subscriptions/extend.go
+++ b/service/subscriptions/extend.go
@@ -29,7 +29,7 @@ const CmdExtend = "extend"
const ReqSubExtend = "sub_extend"
const daysMin = 10
const daysMax = 365
-const msgFmtRunOnceFailed = "failed to extend the subscription, id: %s, user id: %s, cause: %s, retrying in: %s"
+const msgFmtRunOnceFailed = "failed to extend the interest following, id: %s, user id: %s, cause: %s, retrying in: %s"
type ExtendHandler struct {
CfgPayment config.PaymentConfig
@@ -90,8 +90,8 @@ func (eh ExtendHandler) HandleExtensionReply(tgCtx telebot.Context, args ...stri
price := int(float64(countDays) * eh.CfgPayment.Price.Subscription.Extension * eh.CfgPayment.Currency.SubFactor)
invoice := telebot.Invoice{
Start: uuid.NewString(),
- Title: "Subscription Extension",
- Description: fmt.Sprintf("Subscription %s: extend by %d days", subId, countDays),
+ Title: "Interest Following Extension",
+ Description: fmt.Sprintf("Interest %s: extend following by %d days", subId, countDays),
Payload: string(orderData),
Currency: eh.CfgPayment.Currency.Code,
Prices: []telebot.Price{
@@ -146,12 +146,12 @@ func (eh ExtendHandler) ExtendPaid(tgCtx telebot.Context, args ...string) (err e
err = backoff.RetryNotify(e.runOnce, b, func(err error, d time.Duration) {
eh.Log.Warn(fmt.Sprintf(msgFmtRunOnceFailed, op.SubId, userId, err, d))
if d > 1*time.Second {
- _ = tgCtx.Send("Extending the subscription, please wait...")
+ _ = tgCtx.Send("Extending the interest following, please wait...")
}
})
}
if err == nil {
- err = tgCtx.Send(fmt.Sprintf("Subscription has been successfully extended by %d days", op.DaysAdd))
+ err = tgCtx.Send(fmt.Sprintf("Interest following has been successfully extended by %d days", op.DaysAdd))
}
return
}
diff --git a/service/subscriptions/list.go b/service/subscriptions/list.go
index 81faea3..d921e48 100644
--- a/service/subscriptions/list.go
+++ b/service/subscriptions/list.go
@@ -21,7 +21,7 @@ func ListOnGroupStartHandlerFunc(clientAwk api.Client, svcReader reader.Service,
m, err = listButtons(groupIdCtx, userId, clientAwk, svcReader, tgCtx.Chat().ID, CmdStart, "")
if err == nil {
err = tgCtx.Send(
- "Own subscriptions list. "+
+ "Own interests list. "+
"Use the app to manage. "+
"Select one or more to read in this chat:",
m, telebot.ModeHTML,
@@ -42,7 +42,7 @@ func PageNext(clientAwk api.Client, svcReader reader.Service, groupId string) se
var m *telebot.ReplyMarkup
m, err = listButtons(groupIdCtx, userId, clientAwk, svcReader, tgCtx.Chat().ID, args[0], cursor)
if err == nil {
- err = tgCtx.Send("Own subscriptions list page:", m, telebot.ModeHTML)
+ err = tgCtx.Send("Own interests list page:", m, telebot.ModeHTML)
}
return
}
diff --git a/service/subscriptions/start.go b/service/subscriptions/start.go
index 0acd9a9..e7475e7 100644
--- a/service/subscriptions/start.go
+++ b/service/subscriptions/start.go
@@ -14,9 +14,9 @@ import (
)
const CmdStart = "sub_start"
-const MsgFmtChatLinked = "Linked the subscription \"%s\" to this chat. " +
+const MsgFmtChatLinked = "Following the interest \"%s\" in this chat. " +
"New results will appear here. " +
- "To manage own subscriptions use the app."
+ "To manage own interests use the app."
func Start(
clientAwk api.Client,
diff --git a/service/subscriptions/stop.go b/service/subscriptions/stop.go
index f4f334d..bfd4f67 100644
--- a/service/subscriptions/stop.go
+++ b/service/subscriptions/stop.go
@@ -19,7 +19,7 @@ func Stop(svcReader reader.Service) service.ArgHandlerFunc {
err = svcReader.DeleteCallback(ctx, subId, cb.Url)
}
if err == nil {
- _ = tgCtx.Send("Unlinked the subscription from this chat")
+ _ = tgCtx.Send("Stopped following the interest in this chat")
}
return
}
diff --git a/service/usage/limits.go b/service/usage/limits.go
index ab8f9f2..41fdf23 100644
--- a/service/usage/limits.go
+++ b/service/usage/limits.go
@@ -57,7 +57,7 @@ func (lh LimitsHandler) RequestExtension(tgCtx telebot.Context, args ...string)
//case usage.SubjectSubscriptions:
// err = tgCtx.Send(
// fmt.Sprintf(
- // "The limit extension price is %s %.2f per day per subscription starting from 2nd. "+
+ // "The limit extension price is %s %.2f per day per interest starting from 2nd. "+
// "Reply with the count of days to add:",
// lh.CfgPayment.Currency.Code,
// lh.CfgPayment.Price.Subscription.CountLimit,
@@ -220,7 +220,7 @@ func formatUsageSubject(subj usage.Subject) (s string) {
case usage.SubjectPublishEvents:
s = "Message Daily Publications"
case usage.SubjectSubscriptions:
- s = "Subscriptions Count"
+ s = "Interests Count"
default:
s = "undefined"
}