mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 09:52:30 -05:00
[V3 Everything] Package bot and write setup scripts (#964)
Ya'll are gonna hate me. * Initial modifications * Add initial setup.py * working setup py help * Modify setup file to package stuff * Move a bunch of shit and fix imports * Fix or skip tests * Must add init files for find_packages to work * Move main to scripts folder and rename * Add shebangs * Copy over translation files * WORKING PIP INSTALL * add dependency information * Hardcoded version for now, will need to figure out a better way to do this * OKAY ITS FINALLY FUCKING WORKING * Add this guy * Fix stuff * Change readme to rst * Remove double sentry opt in * Oopsie * Fix this thing * Aaaand fix test * Aaaand fix test * Fix core cog importing and default cog install path * Adjust readme * change instance name from optional to required * Ayyy let's do more dependency injection
This commit is contained in:
0
redbot/core/utils/__init__.py
Normal file
0
redbot/core/utils/__init__.py
Normal file
79
redbot/core/utils/chat_formatting.py
Normal file
79
redbot/core/utils/chat_formatting.py
Normal file
@@ -0,0 +1,79 @@
|
||||
def error(text):
|
||||
return "\N{NO ENTRY SIGN} {}".format(text)
|
||||
|
||||
|
||||
def warning(text):
|
||||
return "\N{WARNING SIGN} {}".format(text)
|
||||
|
||||
|
||||
def info(text):
|
||||
return "\N{INFORMATION SOURCE} {}".format(text)
|
||||
|
||||
|
||||
def question(text):
|
||||
return "\N{BLACK QUESTION MARK ORNAMENT} {}".format(text)
|
||||
|
||||
|
||||
def bold(text):
|
||||
return "**{}**".format(text)
|
||||
|
||||
|
||||
def box(text, lang=""):
|
||||
ret = "```{}\n{}\n```".format(lang, text)
|
||||
return ret
|
||||
|
||||
|
||||
def inline(text):
|
||||
return "`{}`".format(text)
|
||||
|
||||
|
||||
def italics(text):
|
||||
return "*{}*".format(text)
|
||||
|
||||
|
||||
def pagify(text, delims=["\n"], *, escape_mass_mentions=True, shorten_by=8,
|
||||
page_length=2000):
|
||||
"""DOES NOT RESPECT MARKDOWN BOXES OR INLINE CODE"""
|
||||
in_text = text
|
||||
page_length -= shorten_by
|
||||
while len(in_text) > page_length:
|
||||
this_page_len = page_length
|
||||
if escape_mass_mentions:
|
||||
this_page_len -= (in_text.count("@here", 0, page_length) +
|
||||
in_text.count("@everyone", 0, page_length))
|
||||
closest_delim = max([in_text.rfind(d, 1, this_page_len)
|
||||
for d in delims])
|
||||
closest_delim = closest_delim if closest_delim != -1 else this_page_length
|
||||
if escape_mass_mentions:
|
||||
to_send = escape(in_text[:closest_delim], mass_mentions=True)
|
||||
else:
|
||||
to_send = in_text[:closest_delim]
|
||||
if len(to_send.strip()) > 0:
|
||||
yield to_send
|
||||
in_text = in_text[closest_delim:]
|
||||
|
||||
if len(in_text.strip()) > 0:
|
||||
if escape_mass_mentions:
|
||||
yield escape(in_text, mass_mentions=True)
|
||||
else:
|
||||
yield in_text
|
||||
|
||||
|
||||
def strikethrough(text):
|
||||
return "~~{}~~".format(text)
|
||||
|
||||
|
||||
def underline(text):
|
||||
return "__{}__".format(text)
|
||||
|
||||
|
||||
def escape(text, *, mass_mentions=False, formatting=False):
|
||||
if mass_mentions:
|
||||
text = text.replace("@everyone", "@\u200beveryone")
|
||||
text = text.replace("@here", "@\u200bhere")
|
||||
if formatting:
|
||||
text = (text.replace("`", "\\`")
|
||||
.replace("*", "\\*")
|
||||
.replace("_", "\\_")
|
||||
.replace("~", "\\~"))
|
||||
return text
|
||||
Reference in New Issue
Block a user