Exemple #1
0
 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))
Exemple #2
0
 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))
Exemple #3
0
 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))
Exemple #4
0
 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
Exemple #5
0
 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))