mirror of
https://github.com/RGBCube/VReplBot
synced 2025-05-31 05:08:11 +00:00
B
This commit is contained in:
parent
7a9706ee0d
commit
271706db7e
3 changed files with 21 additions and 17 deletions
|
@ -25,8 +25,8 @@ class ReplBot(CommandsBot):
|
||||||
session: AIOHTTPSession
|
session: AIOHTTPSession
|
||||||
|
|
||||||
def __init__(self, *, token: str, webhook_url: str) -> None:
|
def __init__(self, *, token: str, webhook_url: str) -> None:
|
||||||
self.token = token
|
self.__token = token
|
||||||
self.webhook_url = webhook_url
|
self.__webhook_url = webhook_url
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
command_prefix = when_mentioned_or("&"),
|
command_prefix = when_mentioned_or("&"),
|
||||||
|
@ -78,10 +78,10 @@ class ReplBot(CommandsBot):
|
||||||
async def runner() -> None:
|
async def runner() -> None:
|
||||||
async with self, AIOHTTPSession() as self.session:
|
async with self, AIOHTTPSession() as self.session:
|
||||||
self.log_webhook = Webhook.from_url(
|
self.log_webhook = Webhook.from_url(
|
||||||
self.webhook_url, session = self.session, bot_token = self.token
|
self.__webhook_url, session = self.session, bot_token = self.__token
|
||||||
)
|
)
|
||||||
await self.load_extensions()
|
await self.load_extensions()
|
||||||
await self.start(self.token)
|
await self.start(self.__token)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
asyncio.run(runner())
|
asyncio.run(runner())
|
||||||
|
|
|
@ -53,9 +53,12 @@ class Miscellaneous(
|
||||||
await ctx.reply(
|
await ctx.reply(
|
||||||
strip(
|
strip(
|
||||||
f"""
|
f"""
|
||||||
__**Bot Info**__
|
```
|
||||||
**Python Version:** v{python_version()}
|
Bot Info
|
||||||
**Uptime:** `{TimeDelta(seconds = int(get_time() - self.bot.ready_timestamp))}`
|
========
|
||||||
|
Python Version: v{python_version()}
|
||||||
|
Uptime: {TimeDelta(seconds = int(get_time() - self.bot.ready_timestamp))}
|
||||||
|
```
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -41,21 +41,22 @@ class Playground(
|
||||||
*,
|
*,
|
||||||
type: Literal["run"] | Literal["run_test"]
|
type: Literal["run"] | Literal["run_test"]
|
||||||
) -> None:
|
) -> None:
|
||||||
if (c_stripped := code.lstrip("https://")).startswith("play.vlang.io/?query="):
|
if not code:
|
||||||
query = c_stripped.lstrip("play.vlang.io/?query=").split(" ", 1)[0]
|
|
||||||
code = await self.get_query_content(query)
|
|
||||||
|
|
||||||
if not code:
|
|
||||||
await ctx.reply("Invalid query.")
|
|
||||||
return
|
|
||||||
|
|
||||||
elif not code:
|
|
||||||
if not (reply := ctx.message.reference):
|
if not (reply := ctx.message.reference):
|
||||||
await ctx.reply("No code provided.")
|
await ctx.reply("No code provided.")
|
||||||
return
|
return
|
||||||
|
|
||||||
content = await get_message_content(ctx.channel, reply)
|
content = await get_message_content(ctx.channel, reply)
|
||||||
code = codeblock_converter(content).content
|
|
||||||
|
if (c_stripped := content.lstrip("https://")).startswith("play.vlang.io/?query="):
|
||||||
|
query = c_stripped.lstrip("play.vlang.io/?query=").split(" ", 1)[0]
|
||||||
|
code = await self.get_query_content(query)
|
||||||
|
|
||||||
|
if not code:
|
||||||
|
await ctx.reply("Invalid query.")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
code = codeblock_converter(content).content
|
||||||
|
|
||||||
async with await self.bot.session.post(
|
async with await self.bot.session.post(
|
||||||
f"https://play.vlang.io/{type}",
|
f"https://play.vlang.io/{type}",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue