mirror of
https://github.com/myned/modufur.git
synced 2024-12-25 06:37:29 +00:00
STUFF AND THINGS OKAY
This commit is contained in:
parent
0f9c961966
commit
3c2f5c5cc0
2 changed files with 15 additions and 2 deletions
|
@ -37,7 +37,7 @@ import requests
|
||||||
import traceback
|
import traceback
|
||||||
from discord import reaction
|
from discord import reaction
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import errors
|
from discord import errors as err
|
||||||
from misc import checks
|
from misc import checks
|
||||||
from misc import exceptions as exc
|
from misc import exceptions as exc
|
||||||
from utils import formatter, scraper
|
from utils import formatter, scraper
|
||||||
|
@ -101,6 +101,10 @@ class MsG:
|
||||||
await ctx.send('❌ `' + str(e) + '` **out of bounds.**', delete_after=10)
|
await ctx.send('❌ `' + str(e) + '` **out of bounds.**', delete_after=10)
|
||||||
except exc.TagBoundsError as e:
|
except exc.TagBoundsError as e:
|
||||||
await ctx.send('❌ `' + str(e) + '` **out of bounds.** Tags limited to 5, currently.', delete_after=10)
|
await ctx.send('❌ `' + str(e) + '` **out of bounds.** Tags limited to 5, currently.', delete_after=10)
|
||||||
|
except ValueError:
|
||||||
|
await ctx.send('❌ `' + args[-1] + '` **not a valid limit.**', delete_after=10)
|
||||||
|
except exc.NotFound:
|
||||||
|
await ctx.send('❌ **Tag(s) not found.**', delete_after=10)
|
||||||
except Exception:
|
except Exception:
|
||||||
await ctx.send(exc.base)
|
await ctx.send(exc.base)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
@ -125,6 +129,10 @@ class MsG:
|
||||||
await ctx.send('❌ `' + str(e) + '` **out of bounds.**', delete_after=10)
|
await ctx.send('❌ `' + str(e) + '` **out of bounds.**', delete_after=10)
|
||||||
except exc.TagBoundsError as e:
|
except exc.TagBoundsError as e:
|
||||||
await ctx.send('❌ `' + str(e) + '` **out of bounds.** Tags limited to 5, currently.', delete_after=10)
|
await ctx.send('❌ `' + str(e) + '` **out of bounds.** Tags limited to 5, currently.', delete_after=10)
|
||||||
|
except ValueError:
|
||||||
|
await ctx.send('❌ `' + args[-1] + '` **not a valid limit.**', delete_after=10)
|
||||||
|
except exc.NotFound:
|
||||||
|
await ctx.send('❌ **Tag(s) not found.**', delete_after=10)
|
||||||
except Exception:
|
except Exception:
|
||||||
await ctx.send(exc.base)
|
await ctx.send(exc.base)
|
||||||
traceback.print_exc(limit=1)
|
traceback.print_exc(limit=1)
|
||||||
|
@ -156,7 +164,10 @@ class MsG:
|
||||||
raise exc.BoundsError(args[-1])
|
raise exc.BoundsError(args[-1])
|
||||||
# Checks for blacklisted tags in endpoint blacklists - try/except is for continuing the parent loop
|
# Checks for blacklisted tags in endpoint blacklists - try/except is for continuing the parent loop
|
||||||
while len(urls) < limit:
|
while len(urls) < limit:
|
||||||
request = requests.get('https://' + booru + '.net/post/index.json?limit=6&tags=order:random' + formatter.tostring_commas(args)).json()
|
headers = {'user-agent': 'Modumind/0.0.1 (Myned)'}
|
||||||
|
request = requests.get('https://' + booru + '.net/post/index.json?limit=6&tags=order:random' + formatter.tostring_commas(args), headers=headers).json()
|
||||||
|
if not request:
|
||||||
|
raise exc.NotFound
|
||||||
for post in request:
|
for post in request:
|
||||||
if 'swf' in post['file_ext'] or 'webm' in post['file_ext']:
|
if 'swf' in post['file_ext'] or 'webm' in post['file_ext']:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -20,5 +20,7 @@ class FlagError(Exception):
|
||||||
pass
|
pass
|
||||||
class BlacklistError(Exception):
|
class BlacklistError(Exception):
|
||||||
pass
|
pass
|
||||||
|
class NotFound(Exception):
|
||||||
|
pass
|
||||||
class Continue(Exception):
|
class Continue(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue