Skip to content
This repository was archived by the owner on Oct 24, 2020. It is now read-only.
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions aioslacker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(
self,
token=None,
timeout=slacker.DEFAULT_TIMEOUT,
session=None,
*,
loop=None
):
Expand All @@ -29,12 +30,15 @@ def __init__(

self.loop = loop

self.session = aiohttp.ClientSession(
connector=aiohttp.TCPConnector(
use_dns_cache=False,
loop=self.loop,
),
)
if not isinstance(session, aiohttp.ClientSession):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check makes no sense, as well can hard to debug, just remove this check, please.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if session is None, then create default session

session = aiohttp.ClientSession(
connector=aiohttp.TCPConnector(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connector is not needed here

use_dns_cache=False,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can You remove use_dns_cache=False, as well, it is not needed anymore

loop=self.loop,
),
)

self.session = session

self.methods = {
requests.get: 'GET',
Expand Down Expand Up @@ -286,11 +290,14 @@ def __init__(
self,
url=None,
timeout=slacker.DEFAULT_TIMEOUT,
session=None,
*, loop=None
):
self.url = url

super().__init__(token=None, timeout=timeout, loop=loop)
super().__init__(
token=None, timeout=timeout, session=session, loop=loop
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can You place them one by one on each new line?

)

@asyncio.coroutine
def post(self, data):
Expand Down Expand Up @@ -327,6 +334,7 @@ def __init__(
token,
incoming_webhook_url=None,
timeout=slacker.DEFAULT_TIMEOUT,
session=None,
*, loop=None
):
if loop is None:
Expand All @@ -337,116 +345,139 @@ def __init__(
self.im = IM(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.api = API(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.dnd = DND(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.rtm = RTM(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.auth = Auth(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.bots = Bots(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.chat = Chat(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.team = Team(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.pins = Pins(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.mpim = MPIM(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.users = Users(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.files = Files(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.stars = Stars(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.emoji = Emoji(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.search = Search(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.groups = Groups(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.channels = Channels(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.presence = Presence(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.reminders = Reminders(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.reactions = Reactions(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.idpgroups = IDPGroups(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.usergroups = UserGroups(
token=token,
timeout=timeout,
session=session,
loop=self.loop,
)
self.incomingwebhook = IncomingWebhook(
url=incoming_webhook_url,
timeout=timeout,
session=session,
loop=self.loop,
)

Expand Down