Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Add the blockquote function formatting.py #2092

Closed
wants to merge 4 commits into from
Closed

Update Add the blockquote function formatting.py #2092

wants to merge 4 commits into from

Conversation

HACKS-EXE
Copy link

@HACKS-EXE HACKS-EXE commented Dec 3, 2023

For this code to work it needs the approval of #2091 and the other way around too

To make this change I researched formatting: https://markdown.net.br/sintaxe-basica/#blockquote-muiltiple-paragraphs

My tests are in the comments

image

@Badiboy
Copy link
Collaborator

Badiboy commented Dec 3, 2023

image

@Badiboy
Copy link
Collaborator

Badiboy commented Dec 3, 2023

  1. Where you got that
    > {}
    will make text citation? Any proofs?

@HACKS-EXE
Copy link
Author

  1. Where you got that
    > {}
    will make text citation? Ay proofs?

I made the code myself

@HACKS-EXE
Copy link
Author

  1. Where you got that
    > {}
    will make text citation? Ay proofs?

Here's the evidence

image

@HACKS-EXE
Copy link
Author

  1. Where you got that
    > {}
    will make text citation? Ay proofs?
Atualizando.o.telebot.mp4

@HACKS-EXE
Copy link
Author

  1. Where you got that
    > {}
    will make text citation? Ay proofs?

image

image

image

This is how I left it and made my script

@HACKS-EXE
Copy link
Author

image

To add this formatting I researched Markdown formatting here: https://markdown.net.br/sintaxe-basica/

@Badiboy
Copy link
Collaborator

Badiboy commented Dec 4, 2023

To add this formatting I researched Markdown formatting here: https://markdown.net.br/sintaxe-basica/

You cannot invent markdown yourself.

https://core.telegram.org/bots/api#sendmessage

Here are all markdown options, available for sending messages.

@HACKS-EXE
Copy link
Author

HACKS-EXE commented Dec 4, 2023

To add this formatting I researched Markdown formatting here: https://markdown.net.br/sintaxe-basica/

You cannot invent markdown yourself.

https://core.telegram.org/bots/api#sendmessage

Here are all markdown options, available for sending messages.

I didn't create something that doesn't exist, in the latest telegram updates, quote were added, which allows the user to format the message using the quote to highlight the message, what I did was just put the quote to work in the telebot library, I didn't create the quote it already exists in Markdown format, I just added the Markdown formatting quote to the formatting.py code that is located in the telebot folder.

Take a look at the example below.

Hello, this is how to put the quote in messages in telegram.

Hi, this is how to put quotes using the bot
To put quotes in the bot you have to leave a '>' at the beginning of each text.

image
image

Test my code and see for yourself if it works.

def mcite(content: str, escape: Optional[bool]=True) -> str:

"""
Returns a Markdown-formatted bold string.

:param content: The string to bold.
:type content: :obj:`str`

:param escape: True if you need to escape special characters. Defaults to True.
:type escape: :obj:`bool`

:return: The formatted string.
:rtype: :obj:`str`
"""
return '> {}'.format(escape_markdown(content) if escape else content)

Put this in formatting.py now put

formatting.mcite(message.from_user.first_name), 

Add quote inside formatting_example.py which is in git hub

bot = TeleBot('TOKEN')

@coder2020official
Copy link
Collaborator

Btw, since the bot api got released, we can think of this again

@coder2020official
Copy link
Collaborator

Could you also implement hcite before we merge it?

@coder2020official
Copy link
Collaborator

@Badiboy this should work according to bot doc, are you ok with this now?

@Badiboy
Copy link
Collaborator

Badiboy commented Jan 5, 2024

I did not tested it. If it confirms to the bot api - why not.

@coder2020official
Copy link
Collaborator

image Doc said to remove space too @Badiboy check out

@Badiboy
Copy link
Collaborator

Badiboy commented Jan 6, 2024

return '>{}'.format(escape_markdown(content) if escape else content)

image

I think the function mcite needs to check for /n and add ">" for every logical line. It can be made with splitting by /n, then add ">" and then join back.

Copy link
Collaborator

@Badiboy Badiboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commen is given above.

@HACKS-EXE
Copy link
Author

HACKS-EXE commented Jan 7, 2024

Could you also implement hcite before we merge it?

I've added https://github.com/HACKS-EXE/Zaquiles-PY-TeleBot-API/blob/master/telebot/formatting.py#L84-L112
https://github.com/HACKS-EXE/Zaquiles-PY-TeleBot-API/blob/master/examples/formatting_example.py#L35

def hcite(content: str, escape: Optional[bool]=True) -> str:
    """
    Returns an HTML-formatted blockquote string.

    :param content: The string to blockquote.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    """
    return '<blockquote>{}</blockquote>'.format(escape_html(content) if escape else content)

@HACKS-EXE HACKS-EXE closed this Jan 7, 2024
@HACKS-EXE HACKS-EXE deleted the patch-2 branch January 7, 2024 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants