def sendFlexImage(self, to, imageUrl, animated=False): main = ["dark", "red", "cyan", "yellow", "green", "white"] color = random.choice(main) xyz = LiffChatContext(to) xyzz = LiffContext(chat=xyz) view = LiffViewRequest('1602876096-e9QWgjyo', xyzz) token = self.liff.issueLiffView(view) url = 'https://api.line.me/message/v3/share' headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer %s' % token.accessToken } data = { 'messages': [{ 'type': 'image', 'originalContentUrl': imageUrl, 'previewImageUrl': imageUrl, 'animated': animated, 'extension': 'jpg', 'sentBy': { 'label': 'IMJUSTGOOD.COM', 'iconUrl': f'https://imjustgood.com/img/{color}-logo.png', 'linkUrl': 'https://{}'.format(self.crawl(self.wm["justGood"])) } }] } return requests.post(url, headers=headers, data=json.dumps(data))
def sendTemp(self, to, data): xyz = LiffChatContext(to) xyzz = LiffContext(chat=xyz) view = LiffViewRequest('1602876096-e9QWgjyo', xyzz) token = self.liff.issueLiffView(view) url = 'https://api.line.me/message/v3/share' headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer %s' % token.accessToken } data = {"messages": [data]} requests.post(url, headers=headers, data=json.dumps(data))
def sendFlex(self, to, data): xyz = LiffChatContext(to) xyzz = LiffContext(chat=xyz) view = LiffViewRequest('1602876096-e9QWgjyo', xyzz) token = self.liff.issueLiffView(view) url = 'https://api.line.me/message/v3/share' headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer %s' % token.accessToken } data = { 'messages': [{ 'type': 'flex', 'altText': 'IMJUSTGOOD HERE.', 'contents': data }] } return requests.post(url, headers=headers, data=json.dumps(data))
def sendFlexAudio(self, to, link): xyz = LiffChatContext(to) xyzz = LiffContext(chat=xyz) view = LiffViewRequest('1602876096-e9QWgjyo', xyzz) token = self.liff.issueLiffView(view) url = 'https://api.line.me/message/v3/share' headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer %s' % token.accessToken } data = { 'messages': [{ 'type': 'audio', 'originalContentUrl': link, 'duration': 250000 }] } res = requests.post(url, headers=headers, data=json.dumps(data)) return res
def sendFlexVideo(self, to, videoUrl, thumbnail='dark'): main = ["dark", "red", "cyan", "yellow", "green", "white"] if thumbnail in main: thumbnail = f"https://imjustgood.com/img/{thumbnail}-logo.png" xyz = LiffChatContext(to) xyzz = LiffContext(chat=xyz) view = LiffViewRequest('1602876096-e9QWgjyo', xyzz) token = self.liff.issueLiffView(view) url = 'https://api.line.me/message/v3/share' headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer %s' % token.accessToken } data = { 'messages': [{ 'type': 'video', 'originalContentUrl': videoUrl, 'previewImageUrl': thumbnail, }] } return requests.post(url, headers=headers, data=json.dumps(data))