Compare commits

...

No commits in common. "4f0ea22656faf071c1b1ea703c6753a752746dc3" and "a19c366fa4af9db480422211c966741a5c97ec54" have entirely different histories.

2 changed files with 5 additions and 5 deletions

View File

@ -1 +1 @@
0 * * * * python misskey-szuru-bot.py --instance misskey.io --token token_here --booru szurubooru.com --username my-username --apiKey szuru-login-token --query "sort:random"
0 * * * * python misskey-szuru-bot.py --instance misskey.io --token token_here --booru szurubooru.com --username my-username --apiKey szuru-login-token

View File

@ -2,6 +2,7 @@
import argparse
import pyszuru
import requests
import random
from misskey import Misskey
# arguments
@ -18,14 +19,13 @@ parser.add_argument('-u', '--username', metavar='username', type=str,
help='Username for szurubooru account', required=True)
parser.add_argument('-a', '--apiKey', metavar='apiKey', type=str,
help='API key for szurubooru account', required=True)
parser.add_argument('-q', '--query', metavar='query', type=str,
help='Query to search szurubooru', default="sort:random")
args = parser.parse_args()
# get post
# get truly random post
booru = pyszuru.API(f"https://{args.booru}", username=args.username, token=args.apiKey)
post = next(booru.search_post(args.query))
highest_post = next(booru.search_post("sort:id", page_size=1))
post = booru.getPost(random.randint(0, highest_post.id_))
# compose note
text = f"link: {post.content}"