mirror of
https://github.com/boticord/boticordpy.git
synced 2024-11-13 20:07:28 +03:00
maybe pep-8?
This commit is contained in:
parent
f05ac66591
commit
8cd4555f18
6 changed files with 36 additions and 36 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,3 +7,4 @@ __pycache__
|
||||||
dist
|
dist
|
||||||
docs/_build
|
docs/_build
|
||||||
boticordpy.egg-info
|
boticordpy.egg-info
|
||||||
|
test.py
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from aiohttp import ClientResponse
|
|
||||||
|
|
||||||
from typing import Union
|
from typing import Union
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from aiohttp import ClientResponse
|
||||||
|
|
||||||
from . import exceptions
|
from . import exceptions
|
||||||
from . import types
|
from . import types
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import aiohttp
|
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
|
||||||
from ..config import Config, _json_or_text
|
from ..config import Config, _json_or_text
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,18 +22,18 @@ class Bots:
|
||||||
self.loop = kwargs.get('loop') or asyncio.get_event_loop()
|
self.loop = kwargs.get('loop') or asyncio.get_event_loop()
|
||||||
self.session = kwargs.get('session') or aiohttp.ClientSession(loop=self.loop)
|
self.session = kwargs.get('session') or aiohttp.ClientSession(loop=self.loop)
|
||||||
|
|
||||||
async def get_bot_info(self, botID: int):
|
async def get_bot_info(self, bot_id: int):
|
||||||
"""
|
"""
|
||||||
Returns information about discord bot with the given ID.
|
Returns information about discord bot with the given ID.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
botID : :class:`int`
|
bot_id : :class:`int`
|
||||||
Discord Bot's ID
|
Discord Bot's ID
|
||||||
"""
|
"""
|
||||||
headers = {"Authorization": self.token}
|
headers = {"Authorization": self.token}
|
||||||
|
|
||||||
async with self.session.get(f'{Config.general_api}/bot/{botID}', headers=headers) as resp:
|
async with self.session.get(f'{Config.general_api}/bot/{bot_id}', headers=headers) as resp:
|
||||||
data = await _json_or_text(resp)
|
data = await _json_or_text(resp)
|
||||||
status = Config.http_exceptions.get(resp.status)
|
status = Config.http_exceptions.get(resp.status)
|
||||||
|
|
||||||
|
@ -41,18 +41,18 @@ class Bots:
|
||||||
raise status(resp)
|
raise status(resp)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def get_bot_comments(self, botID: int):
|
async def get_bot_comments(self, bot_id: int):
|
||||||
"""
|
"""
|
||||||
Returns comments of the discord bot with the given ID.
|
Returns comments of the discord bot with the given ID.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
botID : :class:`int`
|
bot_id : :class:`int`
|
||||||
Discord Bot's ID
|
Discord Bot's ID
|
||||||
"""
|
"""
|
||||||
headers = {"Authorization": self.token}
|
headers = {"Authorization": self.token}
|
||||||
|
|
||||||
async with self.session.get(f'{Config.general_api}/bot/{botID}/comments', headers=headers) as resp:
|
async with self.session.get(f'{Config.general_api}/bot/{bot_id}/comments', headers=headers) as resp:
|
||||||
data = await _json_or_text(resp)
|
data = await _json_or_text(resp)
|
||||||
status = Config.http_exceptions.get(resp.status)
|
status = Config.http_exceptions.get(resp.status)
|
||||||
if status is not None:
|
if status is not None:
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
import asyncio
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from ..config import Config, _json_or_text
|
from ..config import Config, _json_or_text
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,36 +23,36 @@ class Servers:
|
||||||
self.loop = kwargs.get('loop') or asyncio.get_event_loop()
|
self.loop = kwargs.get('loop') or asyncio.get_event_loop()
|
||||||
self.session = kwargs.get('session') or aiohttp.ClientSession(loop=self.loop)
|
self.session = kwargs.get('session') or aiohttp.ClientSession(loop=self.loop)
|
||||||
|
|
||||||
async def get_server_info(self, serverID: int):
|
async def get_server_info(self, server_id: int):
|
||||||
"""
|
"""
|
||||||
Returns information about discord server with the given ID.
|
Returns information about discord server with the given ID.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
serverID : :class:`int`
|
server_id : :class:`int`
|
||||||
Discord Server's ID
|
Discord Server's ID
|
||||||
"""
|
"""
|
||||||
headers = {"Authorization": self.token}
|
headers = {"Authorization": self.token}
|
||||||
|
|
||||||
async with self.session.get(f'{Config.general_api}/server/{serverID}', headers=headers) as resp:
|
async with self.session.get(f'{Config.general_api}/server/{server_id}', headers=headers) as resp:
|
||||||
data = await _json_or_text(resp)
|
data = await _json_or_text(resp)
|
||||||
status = Config.http_exceptions.get(resp.status)
|
status = Config.http_exceptions.get(resp.status)
|
||||||
if status is not None:
|
if status is not None:
|
||||||
raise status(resp)
|
raise status(resp)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def get_server_comments(self, serverID: int):
|
async def get_server_comments(self, server_id: int):
|
||||||
"""
|
"""
|
||||||
Returns comments of the discord server with the given ID.
|
Returns comments of the discord server with the given ID.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
serverID : :class:`int`
|
server_id : :class:`int`
|
||||||
Discord Server's ID
|
Discord Server's ID
|
||||||
"""
|
"""
|
||||||
headers = {"Authorization": self.token}
|
headers = {"Authorization": self.token}
|
||||||
|
|
||||||
async with self.session.get(f'{Config.general_api}/server/{serverID}/comments', headers=headers) as resp:
|
async with self.session.get(f'{Config.general_api}/server/{server_id}/comments', headers=headers) as resp:
|
||||||
data = await _json_or_text(resp)
|
data = await _json_or_text(resp)
|
||||||
status = Config.http_exceptions.get(resp.status)
|
status = Config.http_exceptions.get(resp.status)
|
||||||
if status is not None:
|
if status is not None:
|
||||||
|
@ -78,7 +78,7 @@ class Servers:
|
||||||
guild_owner = guild.owner
|
guild_owner = guild.owner
|
||||||
|
|
||||||
stats = {
|
stats = {
|
||||||
"serverID": str(guild.id),
|
"server_id": str(guild.id),
|
||||||
"up": 1,
|
"up": 1,
|
||||||
"status": 1,
|
"status": 1,
|
||||||
"serverName": guild.name,
|
"serverName": guild.name,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import aiohttp
|
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
|
||||||
from ..config import Config, _json_or_text
|
from ..config import Config, _json_or_text
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,54 +16,54 @@ class Users:
|
||||||
self.loop = kwargs.get('loop') or asyncio.get_event_loop()
|
self.loop = kwargs.get('loop') or asyncio.get_event_loop()
|
||||||
self.session = kwargs.get('session') or aiohttp.ClientSession(loop=self.loop)
|
self.session = kwargs.get('session') or aiohttp.ClientSession(loop=self.loop)
|
||||||
|
|
||||||
async def get_user(self, userID: int):
|
async def get_user(self, user_id: int):
|
||||||
"""
|
"""
|
||||||
Returns information about discord user with the given ID.
|
Returns information about discord user with the given ID.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
userID : :class:`int`
|
user_id : :class:`int`
|
||||||
Discord User's ID
|
Discord User's ID
|
||||||
"""
|
"""
|
||||||
headers = {"Authorization": self.token}
|
headers = {"Authorization": self.token}
|
||||||
|
|
||||||
async with self.session.get(f'{Config.general_api}/profile/{userID}', headers=headers) as resp:
|
async with self.session.get(f'{Config.general_api}/profile/{user_id}', headers=headers) as resp:
|
||||||
data = await _json_or_text(resp)
|
data = await _json_or_text(resp)
|
||||||
status = Config.http_exceptions.get(resp.status)
|
status = Config.http_exceptions.get(resp.status)
|
||||||
if status is not None:
|
if status is not None:
|
||||||
raise status(resp)
|
raise status(resp)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def get_user_comments(self, userID: int):
|
async def get_user_comments(self, user_id: int):
|
||||||
"""
|
"""
|
||||||
Returns comments of discord user with the given ID.
|
Returns comments of discord user with the given ID.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
userID : :class:`int`
|
user_id : :class:`int`
|
||||||
Discord User's ID
|
Discord User's ID
|
||||||
"""
|
"""
|
||||||
headers = {"Authorization": self.token}
|
headers = {"Authorization": self.token}
|
||||||
|
|
||||||
async with self.session.get(f'{Config.general_api}/profile/{userID}/comments', headers=headers) as resp:
|
async with self.session.get(f'{Config.general_api}/profile/{user_id}/comments', headers=headers) as resp:
|
||||||
data = await _json_or_text(resp)
|
data = await _json_or_text(resp)
|
||||||
status = Config.http_exceptions.get(resp.status)
|
status = Config.http_exceptions.get(resp.status)
|
||||||
if status is not None:
|
if status is not None:
|
||||||
raise status(resp)
|
raise status(resp)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def get_user_bots(self, userID: int):
|
async def get_user_bots(self, user_id: int):
|
||||||
"""
|
"""
|
||||||
Returns bots of discord user with the given ID.
|
Returns bots of discord user with the given ID.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
userID : :class:`int`
|
user_id : :class:`int`
|
||||||
Discord User's ID
|
Discord User's ID
|
||||||
"""
|
"""
|
||||||
headers = {"Authorization": self.token}
|
headers = {"Authorization": self.token}
|
||||||
|
|
||||||
async with self.session.get(f'{Config.general_api}/bots/{userID}', headers=headers) as resp:
|
async with self.session.get(f'{Config.general_api}/bots/{user_id}', headers=headers) as resp:
|
||||||
data = await _json_or_text(resp)
|
data = await _json_or_text(resp)
|
||||||
status = Config.http_exceptions.get(resp.status)
|
status = Config.http_exceptions.get(resp.status)
|
||||||
if status is not None:
|
if status is not None:
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
from discord.ext.commands import Bot, AutoShardedBot
|
|
||||||
from aiohttp.web_urldispatcher import _WebHandler
|
|
||||||
from aiohttp import web
|
|
||||||
import aiohttp
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
from typing import Dict, Union
|
||||||
|
|
||||||
if sys.version_info >= (3, 8):
|
if sys.version_info >= (3, 8):
|
||||||
from typing import TypedDict
|
from typing import TypedDict
|
||||||
else:
|
else:
|
||||||
from typing_extensions import TypedDict
|
from typing_extensions import TypedDict
|
||||||
|
|
||||||
from typing import Dict, Union
|
from discord.ext.commands import Bot, AutoShardedBot
|
||||||
|
from aiohttp.web_urldispatcher import _WebHandler
|
||||||
|
from aiohttp import web
|
||||||
|
import aiohttp
|
||||||
|
|
||||||
from . import BoticordClient
|
from . import BoticordClient
|
||||||
from . import config
|
from . import config
|
||||||
|
|
Loading…
Reference in a new issue