Skip to content

Commit

Permalink
chore(language/en): add topic related string
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMissx committed Dec 3, 2022
1 parent 41ead08 commit 44f4bc6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
16 changes: 16 additions & 0 deletions anjani/language/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,19 @@ spamshield-view: |
Spam shield setting: **{}**.
Spam shield is a usefull plugin to help protect your group from spammers and trollers.
#endregion
#region topic
topic-button: Topic
topic-help: |
Telegram Topics makes your group divided into different chats within the group (or forum).
This plugin help you manage your topic on Anjani.
A Topic group need to set a default "action topic" that will be used for greetings and more other action by Anjani.
**Admin Commands:**
× /setactiontopic | /setdefaulttopic: Set the current topic as the action topic of this forum.
topic-non-topic: This is not a topic group!
topic-set: This topic will be used for action topic.
#endregion
#region greetings
greetings-button: Greetings
greetings-help: |
Expand All @@ -528,6 +541,9 @@ greetings-help: |
Example: `/welcome noformat`
Check /markdownhelp and /fillinghelp for formatting details.
greetings-topic-disabled: |
Greetings in this chat is currently disabled because of some missing configuration.
To enable greetings, please set a default action topic as mentioned in this [topic help]({}).
greetings-no-input: Please provide the text you want to set!
bot-added: |
Hi... Thanks for inviting me.
Expand Down
8 changes: 4 additions & 4 deletions anjani/plugins/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


class Topics(plugin.Plugin):
name: ClassVar[str] = "Topics"
name: ClassVar[str] = "Topic"

db: util.db.AsyncCollection

Expand All @@ -31,13 +31,13 @@ async def on_load(self) -> None:
async def cmd_setactiontopic(self, ctx: command.Context) -> Optional[str]:
"""Set action topic"""
if not ctx.chat.is_forum:
return "This is not a forum chat."
return await self.text(ctx.chat.id, "topic-non-topic")

await self.db.update_one(
{"chat_id": ctx.chat.id},
{"$set": {"action_topic": ctx.msg.message_thread_id}},
upsert=True,
)
return "This topic will be used for action topic."
return await self.text(ctx.chat.id, "topic-set")

# TODO: Add command to create topic
# TODO: Add command to create, delete, edit topic
12 changes: 10 additions & 2 deletions anjani/plugins/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,11 @@ async def cmd_resetgoodbye(self, ctx: command.Context) -> str:
async def cmd_welcome(self, ctx: command.Context) -> Optional[str]:
"""View current welcome message"""
if ctx.chat.is_forum and not await self.get_action_topic(ctx.chat):
return "Greetings disabled in forums with action topic, use /setactiontopic first to setup a default topic for Greetings messages"
return await self.text(
ctx.chat.id,
"greetings-topic-disabled",
f"https://t.me/{self.bot.user.username}?start=help_topic",
)

chat = ctx.chat
param = ctx.input.lower()
Expand Down Expand Up @@ -382,7 +386,11 @@ async def cmd_welcome(self, ctx: command.Context) -> Optional[str]:
async def cmd_goodbye(self, ctx: command.Context) -> Optional[str]:
"""View current goodbye message"""
if ctx.chat.is_forum and not await self.get_action_topic(ctx.chat):
return "Greetings disabled in forums with action topic, use /setactiontopic first to setup a default topic for Greetings messages"
return await self.text(
ctx.chat.id,
"greetings-topic-disabled",
f"https://t.me/{self.bot.user.username}?start=help_topic",
)

chat = ctx.chat
param = ctx.input.lower()
Expand Down

0 comments on commit 44f4bc6

Please sign in to comment.