Mercurial > codedump
annotate pixivimageposter.py @ 129:8c39820da60a
add decode-mixed-mode.c
this decodes macintosh mixed-mode procedure types. It currently
only supports stack-based procedures :)
| author | Paper <paper@tflc.us> | 
|---|---|
| date | Sun, 19 Oct 2025 22:48:24 -0400 | 
| parents | 2aa9614cb39a | 
| children | 
| rev | line source | 
|---|---|
| 40 | 1 import glob | 
| 2 import random | |
| 3 import discord | |
| 
22
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
4 from discord.ext import commands | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
5 | 
| 
24
 
7eccf59ddec0
Update pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents: 
22 
diff
changeset
 | 
6 help_command = commands.DefaultHelpCommand(no_category="Commands") | 
| 40 | 7 client = commands.Bot(command_prefix='!!', help_command=help_command) | 
| 8 | |
| 
22
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
9 | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
10 @client.event | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
11 async def on_ready(): | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
12 print("Ready!") | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
13 | 
| 40 | 14 | 
| 15 @client.command(help="Posts a random image from my pixiv bookmarks") | |
| 
22
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
16 async def pixiv(ctx): | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
17 files = glob.glob("*.png") | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
18 files.extend(glob.glob("*.jpg")) | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
19 files.extend(glob.glob("*.gif")) | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
20 file = random.choice(files) | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
21 ''' | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
22 filenames are the default to pixivutil2, being | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
23 "(id)_p(imgnumber) - (title).(ext)" | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
24 | 
| 40 | 25 link1 takes "file" and splits it with the character "_", | 
| 26 giving you the id and the rest of the file | |
| 
22
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
27 | 
| 40 | 28 link2 takes the rest of the file and splits it with a space, | 
| 29 giving you the image number and other stuff we don't need | |
| 30 it then removes "p" which just gets in the way, converts it to an integer, | |
| 31 and adds 1 to it because pixivutil2 uses an initial zero in numbering | |
| 
22
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
32 ''' | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
33 link1 = file.split("_", 1)[0] | 
| 
24
 
7eccf59ddec0
Update pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents: 
22 
diff
changeset
 | 
34 link2 = int(file.split("_", 1)[1].split(" ", 1)[0].replace('p', ''))+1 | 
| 40 | 35 await ctx.send(f"https://pixiv.net/member_illust.php?mode=medium&illust_id={link1}, Image {str(link2)}", file=discord.File(file)) | 
| 
22
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
36 | 
| 
 
9782a1f6c1a6
Update and rename randomimageposter.py to pixivimageposter.py
 
Paper <37962225+mrpapersonic@users.noreply.github.com> 
parents:  
diff
changeset
 | 
37 client.run("token") | 
