updating maubot to use new API
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import random
|
||||
import os
|
||||
|
||||
from typing import Type, Optional
|
||||
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
|
||||
@@ -8,6 +9,9 @@ from maubot.handlers import command
|
||||
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
|
||||
api_key = os.environ.get('R34_API_KEY')
|
||||
api_user = os.environ.get('R34_UID')
|
||||
|
||||
class R34Bot(Plugin):
|
||||
|
||||
@command.new("r34")
|
||||
@@ -15,7 +19,7 @@ class R34Bot(Plugin):
|
||||
async def r34(self, evt: MessageEvent, pattern: Optional[str]) -> None:
|
||||
if (pattern):
|
||||
tags=pattern.replace(' ','+')
|
||||
api_url='https://api.rule34.xxx/index.php?page=dapi&s=post&q=index&tags='+tags+"&limit=100&json=1"
|
||||
api_url='https://api.rule34.xxx/index.php?page=dapi&api_key='+api_key+'&user_id='+api_user+'&s=post&q=index&tags='+tags+"&limit=100&json=1"
|
||||
|
||||
async with self.http.get(api_url) as resp:
|
||||
response_json = await resp.json()
|
||||
|
||||
Reference in New Issue
Block a user