Skip to content

Commit 114f4aa

Browse files
authored
Sunset factoid all (#1196)
1 parent 006cd69 commit 114f4aa

File tree

1 file changed

+1
-79
lines changed

1 file changed

+1
-79
lines changed

techsupport_bot/commands/factoids.py

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,85 +1808,7 @@ async def all_(self: Self, ctx: commands.Context) -> None:
18081808
Args:
18091809
ctx (commands.Context): Context of the invocation
18101810
"""
1811-
guild = str(ctx.guild.id)
1812-
1813-
# Gets the url from the cache if the invokation doesn't contain flags
1814-
if guild in self.factoid_all_cache:
1815-
url = self.factoid_all_cache[guild]["url"]
1816-
embed = auxiliary.prepare_confirm_embed(message=url)
1817-
embed.title = (
1818-
"WARNING: This command is deprecated, "
1819-
"please use /factoid all going forward"
1820-
)
1821-
await ctx.send(embed=embed)
1822-
return
1823-
1824-
factoids = await self.get_all_factoids(guild, list_hidden=False)
1825-
if not factoids:
1826-
await auxiliary.send_deny_embed(
1827-
message="No factoids found!", channel=ctx.channel
1828-
)
1829-
return
1830-
1831-
# Gets a dict of aliases where
1832-
# Aliased_factoid = ["list_of_aliases"]
1833-
aliases = {}
1834-
for factoid in factoids:
1835-
if factoid.alias not in [None, ""]:
1836-
# Append to aliases
1837-
if factoid.alias in aliases:
1838-
aliases[factoid.alias].append(factoid.name)
1839-
continue
1840-
1841-
aliases[factoid.alias] = [factoid.name]
1842-
1843-
try:
1844-
# -Tries calling the api-
1845-
html = await self.generate_html(ctx.guild, factoids, aliases)
1846-
# If there are no applicable factoids
1847-
if html is None:
1848-
await auxiliary.send_deny_embed(
1849-
message="No factoids found!", channel=ctx.channel
1850-
)
1851-
return
1852-
1853-
headers = {
1854-
"Content-Type": "text/plain",
1855-
}
1856-
response = await self.bot.http_functions.http_call(
1857-
"put",
1858-
self.bot.file_config.api.api_url.linx,
1859-
headers=headers,
1860-
data=io.StringIO(html),
1861-
get_raw_response=True,
1862-
)
1863-
url = response["text"]
1864-
filename = url.split("/")[-1]
1865-
url = url.replace(filename, f"selif/{filename}")
1866-
1867-
# Returns the url
1868-
embed = auxiliary.prepare_confirm_embed(message=url)
1869-
embed.title = (
1870-
"WARNING: This command is deprecated, "
1871-
"please use /factoid all going forward"
1872-
)
1873-
await ctx.send(embed=embed)
1874-
self.factoid_all_cache[str(ctx.guild.id)] = {}
1875-
self.factoid_all_cache[str(ctx.guild.id)]["url"] = url
1876-
1877-
# If an error happened while calling the api
1878-
except (gaierror, InvalidURL) as exception:
1879-
config = self.bot.guild_configs[str(ctx.guild.id)]
1880-
log_channel = config.get("logging_channel")
1881-
await self.bot.logger.send_log(
1882-
message="Could not render/send all-factoid HTML",
1883-
level=LogLevel.ERROR,
1884-
context=LogContext(guild=ctx.guild, channel=ctx.channel),
1885-
channel=log_channel,
1886-
exception=exception,
1887-
)
1888-
1889-
await self.send_factoids_as_file(ctx, factoids, aliases)
1811+
await ctx.send("Progress has to be made. `.factoid all` has been sunset.")
18901812

18911813
async def generate_html(
18921814
self: Self,

0 commit comments

Comments
 (0)