Spaces:
Running
Running
File size: 7,318 Bytes
53c95e5 1b5719b 69e35c8 1b5719b 0189974 98ab4e9 53c95e5 1b5719b eef97a7 7956eb0 1b5719b 7956eb0 53c95e5 7956eb0 2e265b6 53c95e5 2e265b6 4056428 2e265b6 4056428 2e265b6 4056428 2e265b6 4056428 2e265b6 4056428 2e265b6 4056428 2e265b6 4056428 2e265b6 4056428 2e265b6 4056428 69e35c8 53c95e5 2e265b6 69e35c8 2e265b6 058dd88 2e265b6 7956eb0 53c95e5 7956eb0 0206afd 7956eb0 53c95e5 7956eb0 0206afd 7956eb0 53c95e5 89c3556 53c95e5 7956eb0 818d601 d76971a 809532c 818d601 b002286 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
from random import choice
from pyrogram import enums, filters
from pyrogram.errors import MediaCaptionTooLong
from pyrogram.types import CallbackQuery, Message
from Powers.bot_class import Gojo
from Powers.utils.custom_filters import command
from Powers.utils.extras import StartPic
from Powers.utils.kbhelpers import ikb
async def gen_formatting_kb(m):
return ikb(
[
[
("Markdown Formatting", "formatting.md_formatting"),
("Fillings", "formatting.fillings"),
],
[("Random Content", "formatting.random_content")],
],
True,
"commands"
)
@Gojo.on_message(
command(["markdownhelp", "formatting"]) & filters.private,
)
async def markdownhelp(_, m: Message):
await m.reply_photo(
photo=str(choice(StartPic)),
caption=f"{__HELP__}",
quote=True,
reply_markup=(await gen_formatting_kb(m)),
)
return
md_txt = """<b>Markdown Formatting</b>
You can format your message using <b>bold</b>, <i>italic</i>, <u>underline</u>, <strike>strike</strike> and much more. Go ahead and experiment!
**Note**: It supports telegram user based formatting as well as html and markdown formattings.
<b>Supported markdown</b>:
- <code>`code words`</code>: Backticks are used for monospace fonts. Shows as: <code>code words</code>.
- <code>__italic__</code>: Underscores are used for italic fonts. Shows as: <i>italic words</i>.
- <code>**bold**</code>: Asterisks are used for bold fonts. Shows as: <b>bold words</b>.
- <code>```pre```</code>: To make the formatter ignore other formatting characters inside the text formatted with '```', like: <code>**bold** | *bold*</code>.
- <code>--underline--</code>: To make text <u>underline</u>.
- <code>~~strike~~</code>: Tildes are used for strikethrough. Shows as: <strike>strike</strike>.
- <code>||spoiler||</code>: Double vertical bars are used for spoilers. Shows as: <spoiler>Spoiler</spoiler>.
- <code>[hyperlink](example.com)</code>: This is the formatting used for hyperlinks. Shows as: <a href="https://example.com/">hyperlink</a>.
- <code>[My Button](buttonurl://example.com)</code>: This is the formatting used for creating buttons. This example will create a button named "My button" which opens <code>example.com</code> when clicked.
If you would like to send buttons on the same row, use the <code>:same</code> formatting.
<b>Example:</b>
<code>[button 1](buttonurl:example.com)</code>
<code>[button 2](buttonurl://example.com:same)</code>
<code>[button 3](buttonurl://example.com)</code>
This will show button 1 and 2 on the same line, while 3 will be underneath."""
async def get_splited_formatting(msg, page=1):
msg = msg.split("\n")
l = len(msg)
new_msg = ""
total = l // 10
first = 10 * (page - 1)
last = 10 * page
if not first:
for i in msg[first:last]:
new_msg += f"{i}\n"
kb = [
[
("Next page ▶️", f"next_format_{page + 1}")
]
]
else:
first += 1
if page == total:
for i in msg[first:]:
new_msg += f"{i}\n"
kb = [
[
("◀️ Previous page", f"next_format_{page - 1}")
]
]
else:
for i in msg[first:last]:
new_msg += f"{i}\n"
kb = [
[
("◀️ Previous page", f"next_format_{page - 1}"),
("Next page ▶️", f"next_format_{page + 1}")
]
]
kb = ikb(kb, True, "back.formatting")
return new_msg, kb
@Gojo.on_callback_query(filters.regex(r"^next_format_.*[0-9]$"))
async def change_formatting_page(c: Gojo, q: CallbackQuery):
page = q.data.split("_")[-1]
txt, kb = await get_splited_formatting(md_txt, int(page))
await q.edit_message_caption(txt, reply_markup=kb, parse_mode=enums.ParseMode.HTML, )
return
@Gojo.on_callback_query(filters.regex("^formatting."))
async def get_formatting_info(c: Gojo, q: CallbackQuery):
cmd = q.data.split(".")[1]
kb = ikb([[("Back", "back.formatting")]])
if cmd == "md_formatting":
try:
await q.edit_message_caption(
caption=md_txt,
reply_markup=kb,
parse_mode=enums.ParseMode.HTML,
)
except MediaCaptionTooLong:
txt, kb = await get_splited_formatting(md_txt)
await q.edit_message_caption(
caption=txt,
reply_markup=kb,
parse_mode=enums.ParseMode.HTML,
)
elif cmd == "fillings":
await q.edit_message_caption(
caption="""<b>Fillings</b>
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!
<b>Supported fillings:</b>
- <code>{first}</code>: The user's first name.
- <code>{last}</code>: The user's last name.
- <code>{fullname}</code>: The user's full name.
- <code>{username}</code>: The user's username. If they don't have one, mentions the user instead.
- <code>{mention}</code>: Mentions the user with their firstname.
- <code>{id}</code>: The user's ID.
- <code>{chatname}</code>: The chat's name.""",
reply_markup=kb,
parse_mode=enums.ParseMode.HTML,
)
elif cmd == "random_content":
await q.edit_message_caption(
caption="""<b>Random Content</b>
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:
<code>hello
%%%
how are you</code>
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 <code>{first}</code>!
%%%
Ooooh, <code>{first}</code> how are you?
%%%
Sup? <code>{first}</code>""",
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.edit_message_caption(
caption="""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!"""
|