Passed
Push — main ( 3493fc...06758f )
by
unknown
01:40 queued 11s
created

pincer.client   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 19
dl 0
loc 59
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Client.event_handler() 0 7 1
A Client.__init__() 0 11 1
1
# -*- coding: utf-8 -*-
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# MIT License
3
#
4
# Copyright (c) 2021 Pincer
5
#
6
# Permission is hereby granted, free of charge, to any person obtaining
7
# a copy of this software and associated documentation files
8
# (the "Software"), to deal in the Software without restriction,
9
# including without limitation the rights to use, copy, modify, merge,
10
# publish, distribute, sublicense, and/or sell copies of the Software,
11
# and to permit persons to whom the Software is furnished to do so,
12
# subject to the following conditions:
13
#
14
# The above copyright notice and this permission notice shall be
15
# included in all copies or substantial portions of the Software.
16
#
17
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
from websockets.legacy.client import WebSocketClientProtocol
25
26
from pincer._config import GatewayConfig
27
from pincer.core.dispatch import GatewayDispatch
28
from pincer.core.gateway import Dispatcher
29
from pincer.core.http import HTTPClient
30
31
32
class Client(Dispatcher):
33
    """
34
    The main instance which the user will interact with.
35
    """
36
37
    def __init__(self, token: str):
38
        # TODO: Write docs
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
39
        # TODO: Implement intents
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
40
        super().__init__(
41
            token,
42
            handlers={
43
                0: self.event_handler
44
            }
45
        )
46
47
        self.http = HTTPClient(token, GatewayConfig.version)
48
49
    async def event_handler(
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
50
            self,
51
            socket: WebSocketClientProtocol,
0 ignored issues
show
Unused Code introduced by
The argument socket seems to be unused.
Loading history...
52
            payload: GatewayDispatch
53
    ):
54
        # TODO: Implement events
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
55
        print(payload)
56
57
58
Bot = Client
59