소스 검색

okay fine

master
Noëlle Anthony 4 년 전
부모
커밋
c8b74fad60
1개의 변경된 파일19개의 추가작업 그리고 2개의 파일을 삭제
  1. 19
    2
      metananas.py

+ 19
- 2
metananas.py 파일 보기

@@ -6,6 +6,7 @@

import random, sys
from ananas import PineappleBot, hourly
from PIL import Image, ImageDraw, ImageFont

class MetroidState:
""" Stores the game state
@@ -833,5 +834,21 @@ class MetroidPoster(PineappleBot):
gs.createBitfield()
gs.generatePassword()
post_text = gs.toString()
self.mastodon.status_post(post_text, visibility = "unlisted", spoiler_text = "Metroid password: {}".format(gs.password))
print("Metroidgen scheduled: posted {}".format(gs.password))
img = self.createImage(gs.password)
media_id = self.mastodon.media_post(img, description=gs.password)
self.mastodon.status_post(post_text, visibility = "unlisted", spoiler_text = "Metroid password: {}".format(gs.password), media_ids = [media_id])
print("Metroidgen scheduled: posted {}".format(gs.password))

def createImage(self, pwd):
pwd_chunks = pwd.split(" ") # This is safe because we'll never generate a password with a space in it
pwd_lines = []
pwd_lines.append(" ".join([pwd_chunks[0], pwd_chunks[1]]))
pwd_lines.append(" ".join([pwd_chunks[2], pwd_chunks[3]]))
newpwd = "\n".join(pwd_lines)
fnt = ImageFont.truetype('narpasfw.ttf', size=18)
img = Image.new('RGB', (300, 100))
draw = ImageDraw.Draw(img)
draw.text((50, 35), newpwd, font=fnt, fill=(190, 210, 255))
filename = 'images/{}.png'.format("".join(pwd_chunks))
img.save(filename)
return filename

Loading…
취소
저장