Compare commits

..

No commits in common. "a19c366fa4af9db480422211c966741a5c97ec54" and "4f0ea22656faf071c1b1ea703c6753a752746dc3" 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 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"

View File

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