-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLineNotify.py
36 lines (31 loc) · 1.38 KB
/
LineNotify.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
import requests
class LineNotify:
def __init__(self, notify_token):
self.url = 'https://notify-api.line.me/api/notify'
self.headers = {'Authorization':'Bearer '+notify_token}
def Send_Text(self, text):
try:
session_post = requests.post(self.url, headers=self.headers , data = {'message':text})
# print(session_post.text)
except Exception as ex:
print(ex)
def Send_Image(self, text, image_path):
try:
file_img = {'imageFile': open(image_path, 'rb')}
session = requests.Session()
session_post = session.post(self.url, headers=self.headers, files=file_img, data= {'message': text})
# print(session_post.text)
except Exception as ex:
print(ex)
def Send_Sticker(self, text, stickerPackageId, stickerId):
try:
session_post = requests.post(self.url, headers=self.headers, data= {'message': text,'stickerPackageId': stickerPackageId, 'stickerId': stickerId})
# print(session_post.text)
except Exception as ex:
print(ex)
def Send_Emoji(self, text_emoji):
try:
session_post = requests.post(self.url, headers=self.headers , data = {'message':text_emoji})
# print(session_post.text)
except Exception as ex:
print(ex)