Completed
Pull Request — master (#527)
by
unknown
02:48
created

WechatClient   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sendTextMessage() 0 8 2
A __init__() 0 2 1
1
from lib.wechatutil.sendmessages import send_msg
2
from lib.wechatutil.wechatrequest import WechatRequest
3
from lib.wechatutil.message import *
0 ignored issues
show
Coding Style introduced by
The usage of wildcard imports like lib.wechatutil.message should generally be avoided.
Loading history...
Unused Code introduced by
Message was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
MpNewsMessage was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
ImageMessage was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
MpNewsResourceMessage was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
NewsMessage was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
FileMessage was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
ResourceMessage was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
VoiceMessage was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
VideoMessage was imported with wildcard, but is not used.
Loading history...
4
5
6
class WechatClient:
7
    def __init__(self, corpId, corpSecret):
8
        self.connfactory = WechatRequest(corpId, corpSecret)
9
10
    def sendTextMessage(self, agentid, content, **receivers):
11
        msg = TextMessage()
12
        msg.setagentid(agentid)
13
        msg.setcontent(content)
14
        msg.setreceiver(**receivers)
15
        rc, msg = send_msg(msg, self.connfactory)
16
        if rc != 0:
17
            raise ValueError(msg)
18
19
20
21
22
23
24
25