mirror of
git://git.acid.vegas/scroll.git
synced 2024-11-07 08:46:45 +00:00
Added .ascii play <url> command to play art off of Pastebin
This commit is contained in:
parent
a669fec7a5
commit
24a3e1b1fc
21
README.md
21
README.md
@ -11,16 +11,17 @@ There is no API key needed, no local art files needed, & no reason to not setup
|
|||||||
* [chardet](https://pypi.org/project/chardet/) *(`pip install chardet`)*
|
* [chardet](https://pypi.org/project/chardet/) *(`pip install chardet`)*
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| ------------------------ | --------------------------------------------------------- |
|
| ------------------------ | ---------------------------------------------------------- |
|
||||||
| `@scroll` | information about scroll |
|
| `@scroll` | information about scroll |
|
||||||
| `.ascii <name>` | play the \<name> art file |
|
| `.ascii <name>` | play the \<name> art file |
|
||||||
| `.ascii dirs` | list of art directories |
|
| `.ascii dirs` | list of art directories |
|
||||||
| `.ascii list` | list of art filenames |
|
| `.ascii list` | list of art filenames |
|
||||||
| `.ascii random [dir]` | play random art, optionally from the [dir] directory only |
|
| `.ascii play <url>` | play the contents of \<url> *(must be a raw pastebin url)* |
|
||||||
| `.ascii search <query>` | search for art diles that match \<query> |
|
| `.ascii random [dir]` | play random art, optionally from the [dir] directory only |
|
||||||
| `.ascii stop` | stop playing art |
|
| `.ascii search <query>` | search for art diles that match \<query> |
|
||||||
| `.ascii sync` | sync the ascii database to pump the newest art |
|
| `.ascii stop` | stop playing art |
|
||||||
|
| `.ascii sync` | sync the ascii database to pump the newest art |
|
||||||
|
|
||||||
**NOTE**: You can do `.ascii help` to play the [help.txt](https://github.com/ircart/ircart/blob/master/ircart/doc/help.txt) file in your channel.
|
**NOTE**: You can do `.ascii help` to play the [help.txt](https://github.com/ircart/ircart/blob/master/ircart/doc/help.txt) file in your channel.
|
||||||
|
|
||||||
|
15
scroll.py
15
scroll.py
@ -29,6 +29,7 @@ class throttle:
|
|||||||
max_lines = 300 # maximum number of lines in art file to be played outside of #scroll
|
max_lines = 300 # maximum number of lines in art file to be played outside of #scroll
|
||||||
message = 0.03 # delay between each line sent
|
message = 0.03 # delay between each line sent
|
||||||
results = 25 # maximum number of results returned from search
|
results = 25 # maximum number of results returned from search
|
||||||
|
pastes = True # toggle the .ascii play command
|
||||||
|
|
||||||
# Formatting Control Characters / Color Codes
|
# Formatting Control Characters / Color Codes
|
||||||
bold = '\x02'
|
bold = '\x02'
|
||||||
@ -141,10 +142,12 @@ class Bot():
|
|||||||
finally:
|
finally:
|
||||||
self.db = cache
|
self.db = cache
|
||||||
|
|
||||||
async def play(self, chan, name):
|
async def play(self, chan, name, paste=None):
|
||||||
try:
|
try:
|
||||||
print(name)
|
if paste:
|
||||||
ascii = urllib.request.urlopen(f'https://raw.githubusercontent.com/ircart/ircart/master/ircart/{name}.txt', timeout=10)
|
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:
|
if ascii.getcode() == 200:
|
||||||
ascii = ascii.readlines()
|
ascii = ascii.readlines()
|
||||||
if len(ascii) > throttle.max_lines and chan != '#scroll':
|
if len(ascii) > throttle.max_lines and chan != '#scroll':
|
||||||
@ -232,6 +235,12 @@ class Bot():
|
|||||||
elif msg == '.ascii sync':
|
elif msg == '.ascii sync':
|
||||||
await self.sync()
|
await self.sync()
|
||||||
await self.sendmsg(chan, bold + color('database synced', light_green))
|
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:
|
elif args[1] == 'random' and len(args) == 3:
|
||||||
dir = args[2]
|
dir = args[2]
|
||||||
if dir in self.db:
|
if dir in self.db:
|
||||||
|
Loading…
Reference in New Issue
Block a user