1
mirror of git://git.acid.vegas/scroll.git synced 2024-11-21 23:56:39 +00:00

Added .ascii play <url> command to play art off of Pastebin

This commit is contained in:
Dionysus 2023-06-07 00:17:40 -04:00
parent a669fec7a5
commit 24a3e1b1fc
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
2 changed files with 23 additions and 13 deletions

View File

@ -12,11 +12,12 @@ There is no API key needed, no local art files needed, & no reason to not setup
## Commands
| Command | Description |
| ------------------------ | --------------------------------------------------------- |
| ------------------------ | ---------------------------------------------------------- |
| `@scroll` | information about scroll |
| `.ascii <name>` | play the \<name> art file |
| `.ascii dirs` | list of art directories |
| `.ascii list` | list of art filenames |
| `.ascii play <url>` | play the contents of \<url> *(must be a raw pastebin url)* |
| `.ascii random [dir]` | play random art, optionally from the [dir] directory only |
| `.ascii search <query>` | search for art diles that match \<query> |
| `.ascii stop` | stop playing art |

View File

@ -29,6 +29,7 @@ class throttle:
max_lines = 300 # maximum number of lines in art file to be played outside of #scroll
message = 0.03 # delay between each line sent
results = 25 # maximum number of results returned from search
pastes = True # toggle the .ascii play command
# Formatting Control Characters / Color Codes
bold = '\x02'
@ -141,9 +142,11 @@ class Bot():
finally:
self.db = cache
async def play(self, chan, name):
async def play(self, chan, name, paste=None):
try:
print(name)
if paste:
ascii = urllib.request.urlopen(name), timeout=10)
else:
ascii = urllib.request.urlopen(f'https://raw.githubusercontent.com/ircart/ircart/master/ircart/{name}.txt', timeout=10)
if ascii.getcode() == 200:
ascii = ascii.readlines()
@ -232,6 +235,12 @@ class Bot():
elif msg == '.ascii sync':
await self.sync()
await self.sendmsg(chan, bold + color('database synced', light_green))
elif args[1] == 'play' and len(args) == 3 and throttle.pastes:
url = args[2]
if url.startswith('https://pastebin.com/raw/') and len(url.split('raw/')) > 1:
self.loops[chan] = asyncio.create_task(self.play(chan, url, paste=True))
else:
await self.irc_error(chan 'invalid pastebin url', paste)
elif args[1] == 'random' and len(args) == 3:
dir = args[2]
if dir in self.db: