From 054a9d22ca2fbe1673e240aa59b90a3b4ee66833 Mon Sep 17 00:00:00 2001 From: Ashok Bishnoi Date: Sun, 28 Jul 2024 12:20:03 +0530 Subject: [PATCH] None: just improve texts --- FallenSub/modules/fSub.go | 7 ++++++- FallenSub/modules/start.go | 20 ++++++++++++++++---- FallenSub/modules/watcher.go | 4 ++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/FallenSub/modules/fSub.go b/FallenSub/modules/fSub.go index 56d333b..aced8ff 100644 --- a/FallenSub/modules/fSub.go +++ b/FallenSub/modules/fSub.go @@ -62,7 +62,12 @@ func handleCommand(ctx *ext.Context, b *gotgbot.Bot) error { } var text string if len(ctx.Args()) == 1 { + if fSub.ForceSubChannel == 0 { + text = fmt.Sprintf("Force Sub is %s in %s. \nNo channel set.", onOff(fSub.ForceSub), ctx.EffectiveChat.Title) + } + text = fmt.Sprintf("Force Sub is %s in %s. \nChannelID: %d", onOff(fSub.ForceSub), ctx.EffectiveChat.Title, fSub.ForceSubChannel) + } else { switch ctx.Args()[1] { case "enable", "on", "true", "y", "yes": @@ -72,7 +77,7 @@ func handleCommand(ctx *ext.Context, b *gotgbot.Bot) error { text = "Force Sub is already enabled." case "disable", "off", "false", "n", "no": if fSub.ForceSub { - if err := db.SetFSub(ctx.EffectiveChat.Id, false); err != nil { + if err = db.SetFSub(ctx.EffectiveChat.Id, false); err != nil { return logError("Error disabling Force Sub", err) } text = "Force Sub disabled." diff --git a/FallenSub/modules/start.go b/FallenSub/modules/start.go index 979ef45..7f58e22 100644 --- a/FallenSub/modules/start.go +++ b/FallenSub/modules/start.go @@ -11,10 +11,22 @@ import ( func start(b *gotgbot.Bot, ctx *ext.Context) error { text := fmt.Sprintf("Hello, %s!\n\nI am a bot that can help you manage your group by forcing users to join a channel before they can send messages in the group.\n\nTo get started, add me to your group and make me an admin with ban users permission. Then, set the channel that you want users to join using /fsub command.\n\nFor more information, click the button below.", ctx.EffectiveMessage.From.FirstName) button := gotgbot.InlineKeyboardMarkup{ - InlineKeyboard: [][]gotgbot.InlineKeyboardButton{{{ - Text: "Help", - Url: "https://abishnoi69.github.io/Force-Sub-Bot/", - }}}, + InlineKeyboard: [][]gotgbot.InlineKeyboardButton{ + {{ + Text: "Add Me To Your Group", + Url: fmt.Sprintf("https://t.me/%s?startgroup=true", b.Username), + }}, + { + { + Text: "Update Channel", + Url: "https://t.me/FallenProjects", + }, + { + Text: "Help", + Url: "https://abishnoi69.github.io/Force-Sub-Bot/#commands", + }, + }, + }, } if _, err := ctx.EffectiveMessage.Reply(b, text, &gotgbot.SendMessageOpts{ReplyMarkup: button}); err != nil { diff --git a/FallenSub/modules/watcher.go b/FallenSub/modules/watcher.go index d43e2a4..ad1f4cc 100644 --- a/FallenSub/modules/watcher.go +++ b/FallenSub/modules/watcher.go @@ -26,7 +26,7 @@ func isUserExempt(ctx *ext.Context, fSub db.FSub) bool { func handleGetChatMemberError(b *gotgbot.Bot, chat *gotgbot.Chat, fSub db.FSub, err error) error { _ = db.SetFSub(chat.Id, false) - text := "Force Sub disabled because I can't get your chat member status. Please add me as an admin." + text := "Force Sub disabled because I can't get your chat member status. Please add me as an admin in your channel and enable force sub again." _, _ = b.SendMessage(chat.Id, text, nil) return logError(fmt.Sprintf("[fSubWatcher]Error getting chat member: %s [chatId: %d]", err, fSub.ForceSubChannel), err) } @@ -40,7 +40,7 @@ func restrictUser(b *gotgbot.Bot, chat *gotgbot.Chat, user *gotgbot.User) error } func sendJoinChannelMessage(b *gotgbot.Bot, msg *gotgbot.Message, chat *gotgbot.Chat, user *gotgbot.User, inviteLink string) error { - text := "You must join the channel to continue using this group." + text := fmt.Sprintf("🚫 Dear %s,\n\nTo send messages in this group, you must join our channel first. Please click the 'Join Channel' button below to join the channel. After joining, click the 'Unmute Me' button to regain your messaging privileges.\n\nThank you for your cooperation!", user.FirstName) button := gotgbot.InlineKeyboardMarkup{ InlineKeyboard: [][]gotgbot.InlineKeyboardButton{{ {