Mercurial > codedump
comparison pixivimageposter.py @ 24:7eccf59ddec0
Update pixivimageposter.py
- replace "No Category" with "Commands"
- replace english pixiv link with a more non-english speaker friendly link (nobody who uses this will speak anything but english anyway but who knows)
committer: GitHub <noreply@github.com>
author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
---|---|
date | Fri, 09 Apr 2021 23:31:47 -0400 |
parents | 9782a1f6c1a6 |
children | 2aa9614cb39a |
comparison
equal
deleted
inserted
replaced
23:f29f1441f146 | 24:7eccf59ddec0 |
---|---|
1 import glob, os, random, discord | 1 import glob, os, random, discord |
2 from discord.ext import commands | 2 from discord.ext import commands |
3 | 3 |
4 client = commands.Bot(command_prefix = '!!') | 4 help_command = commands.DefaultHelpCommand(no_category="Commands") |
5 client = commands.Bot(command_prefix = '!!',help_command = help_command) | |
5 | 6 |
6 @client.event | 7 @client.event |
7 async def on_ready(): | 8 async def on_ready(): |
8 print("Ready!") | 9 print("Ready!") |
9 | 10 |
10 @client.command() | 11 @client.command(help = "Posts a random image from my pixiv bookmarks") |
11 async def pixiv(ctx): | 12 async def pixiv(ctx): |
12 files = glob.glob("*.png") | 13 files = glob.glob("*.png") |
13 files.extend(glob.glob("*.jpg")) | 14 files.extend(glob.glob("*.jpg")) |
14 files.extend(glob.glob("*.gif")) | 15 files.extend(glob.glob("*.gif")) |
15 file = random.choice(files) | 16 file = random.choice(files) |
21 | 22 |
22 link2 takes the rest of the file and splits it with a space, giving you the image number and other stuff we don't need | 23 link2 takes the rest of the file and splits it with a space, giving you the image number and other stuff we don't need |
23 it then removes "p" which just gets in the way, converts it to an integer, and adds 1 to it because pixivutil2 uses an initial zero in numbering | 24 it then removes "p" which just gets in the way, converts it to an integer, and adds 1 to it because pixivutil2 uses an initial zero in numbering |
24 ''' | 25 ''' |
25 link1 = file.split("_", 1)[0] | 26 link1 = file.split("_", 1)[0] |
26 link2 = int(file.split("_", 1)[1].split(" ", 1)[0].replace('p', '')) + 1 | 27 link2 = int(file.split("_", 1)[1].split(" ", 1)[0].replace('p', ''))+1 |
27 await ctx.send("https://pixiv.net/en/artworks/" + link1 + ", Image " + str(link2),file = discord.File(file)) | 28 await ctx.send("https://pixiv.net/member_illust.php?mode=medium&illust_id=" + link1 + ", Image " + str(link2),file = discord.File(file)) |
28 | 29 |
29 client.run("token") | 30 client.run("token") |