updating maubot to use new API #1
@@ -1,6 +1,6 @@
|
|||||||
maubot: 0.1.0
|
maubot: 0.1.0
|
||||||
id: nearfuture.maubot.r34
|
id: nearfuture.maubot.r34
|
||||||
version: 0.1.0
|
version: 0.1.2
|
||||||
modules:
|
modules:
|
||||||
- r34bot
|
- r34bot
|
||||||
main_class: R34Bot
|
main_class: R34Bot
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
|
import os
|
||||||
|
|
||||||
from typing import Type, Optional
|
from typing import Type, Optional
|
||||||
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
|
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
|
||||||
@@ -8,6 +9,9 @@ from maubot.handlers import command
|
|||||||
|
|
||||||
from urllib.parse import urlparse, parse_qs
|
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):
|
class R34Bot(Plugin):
|
||||||
|
|
||||||
@command.new("r34")
|
@command.new("r34")
|
||||||
@@ -15,7 +19,7 @@ class R34Bot(Plugin):
|
|||||||
async def r34(self, evt: MessageEvent, pattern: Optional[str]) -> None:
|
async def r34(self, evt: MessageEvent, pattern: Optional[str]) -> None:
|
||||||
if (pattern):
|
if (pattern):
|
||||||
tags=pattern.replace(' ','+')
|
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:
|
async with self.http.get(api_url) as resp:
|
||||||
response_json = await resp.json()
|
response_json = await resp.json()
|
||||||
|
|||||||
Reference in New Issue
Block a user