-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathline_client.py
40 lines (29 loc) · 1 KB
/
line_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from line import LineClient, LineContact
import ConfigParser
import os
class Line(object):
def __init__(self):
config = ConfigParser.ConfigParser()
config.read(os.path.join(os.path.dirname(__file__), 'config.ini'))
email = config.get('LINE', 'email')
password = config.get('LINE', 'password')
try:
self.client = LineClient(email, password)
except:
print("Line login failed")
def updateAuthToken(self):
self.client.updateAuthToken()
def send(self, target_id, message):
try:
target = self.client._client.findContactByUserid(target_id)
c = LineContact(self.client, target)
c.sendMessage(message)
except:
print("line id not found")
def exist_id(self, target_id):
try:
target = self.client._client.findContactByUserid(target_id)
result = True if target else False
except:
result = False
return result