from Powers import LOGGER
from Powers.bot_class import Gojo
from pyrogram import enums, filters
from Powers.utils.kbhelpers import ikb
from Powers.utils.custom_filters import command
from pyrogram.types import Message, CallbackQuery
async def gen_formatting_kb(m):
return ikb(
[
[
("Markdown Formatting", "formatting.md_formatting"),
("Fillings", "formatting.fillings"),
],
[("Random Content", "formatting.random_content")],
[("« " + "Back", "commands")],
],
)
@Gojo.on_message(
command(["markdownhelp", "formatting"]) & filters.private,
)
async def markdownhelp(_, m: Message):
await m.reply_text(
text=f"plugins.{__PLUGIN__}.help",
quote=True,
reply_markup=(await gen_formatting_kb(m)),
)
LOGGER.info(f"{m.from_user.id} used cmd '{m.command}' in {m.chat.id}")
return
@Gojo.on_callback_query(filters.regex("^formatting."))
async def get_formatting_info(_, q: CallbackQuery):
cmd = q.data.split(".")[1]
kb = ikb([[("Back", "back.formatting")]])
if cmd == "md_formatting":
await q.message.edit_text(
text="""Markdown Formatting
You can format your message using bold, italic, underline, strike and much more. Go ahead and experiment!
**Note**: It supports telegram user based formatting as well as html and markdown formattings.
Supported markdown:
- `code words`
: Backticks are used for monospace fonts. Shows as: code words
.
- __italic__
: Underscores are used for italic fonts. Shows as: italic words.
- **bold**
: Asterisks are used for bold fonts. Shows as: bold words.
- ```pre```
: To make the formatter ignore other formatting characters inside the text formatted with '```', like: **bold** | *bold*
.
- --underline--
: To make text underline.
- ~~strike~~
: Tildes are used for strikethrough. Shows as: strike.
- ||spoiler||
: Double vertical bars are used for spoilers. Shows as: Spoiler.
- [hyperlink](example.com)
: This is the formatting used for hyperlinks. Shows as: hyperlink.
- [My Button](buttonurl://example.com)
: This is the formatting used for creating buttons. This example will create a button named "My button" which opens example.com
when clicked.
If you would like to send buttons on the same row, use the :same
formatting.
Example:
[button 1](buttonurl:example.com)
[button 2](buttonurl://example.com:same)
[button 3](buttonurl://example.com)
This will show button 1 and 2 on the same line, while 3 will be underneath.""",
reply_markup=kb,
parse_mode=enums.ParseMode.HTML,
)
elif cmd == "fillings":
await q.message.edit_text(
text="""Fillings
You can also customise the contents of your message with contextual data. For example, you could mention a user by name in the welcome message, or mention them in a filter!
You can use these to mention a user in notes too!
Supported fillings:
- {first}
: The user's first name.
- {last}
: The user's last name.
- {fullname}
: The user's full name.
- {username}
: The user's username. If they don't have one, mentions the user instead.
- {mention}
: Mentions the user with their firstname.
- {id}
: The user's ID.
- {chatname}
: The chat's name.""",
reply_markup=kb,
parse_mode=enums.ParseMode.HTML,
)
elif cmd == "random_content":
await q.message.edit_text(
text="""Random Content
Another thing that can be fun, is to randomise the contents of a message. Make things a little more personal by changing welcome messages, or changing notes!
How to use random contents:
- %%%: This separator can be used to add "random" replies to the bot.
For example:
hello
%%%
how are you
This will randomly choose between sending the first message, "hello", or the second message, "how are you".
Use this to make Gojo feel a bit more customised! (only works in filters/notes)
Example welcome message::
- Every time a new user joins, they'll be presented with one of the three messages shown here.
-> /filter "hey"
hello there {first}
!
%%%
Ooooh, {first}
how are you?
%%%
Sup? {first}
""",
reply_markup=kb,
parse_mode=enums.ParseMode.HTML,
)
await q.answer()
return
@Gojo.on_callback_query(filters.regex("^back."))
async def send_mod_help(_, q: CallbackQuery):
await q.message.edit_text(
text="""Formatting
Gojo supports a large number of formatting options to make your messages more expressive. Take a look by clicking the buttons below!""",
reply_markup=(await gen_formatting_kb(q.message)),
)
await q.answer()
return
__PLUGIN__ = "formatting"
__alt_name__ = ["formatting", "markdownhelp", "markdown"]
__buttons__ = [
[
("Markdown Formatting", "formatting.md_formatting"),
("Fillings", "formatting.fillings"),
],
[("Random Content", "formatting.random_content")],
]
__HELP__ = """
***Formatting***
Gojo supports a large number of formatting options to make your messages more expressive. Take a look by clicking the buttons below!"""