-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeals.py
49 lines (37 loc) · 1.12 KB
/
deals.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
41
42
43
44
45
46
47
48
49
import pyshorteners
import oz_teaser
import config
class Deals:
def __init__(self, deals):
self.deals = deals
self.teaser_instances = []
self.build_teaser_instances()
def build_teaser_instances(self):
for deal in self.deals:
self.teaser_instances.append( oz_teaser.OzTeaser(deal) )
def list(self):
result = []
for teaser in self.teaser_instances:
teaser_is_valid = teaser.title and teaser.link
if teaser_is_valid:
result.append(self.build_teaser_embed(teaser))
return result
def build_teaser_embed(self, teaser):
return {
"title": teaser.title,
# "url": pyshorteners.Shortener().tinyurl.short(teaser.link),
"url": teaser.link,
"thumbnail": {
"url": teaser.thumbnail_src,
}
}
def build_teaser_message(self, teaser):
result = '\n'
spacer = '\n'
result += teaser.title + ' - <' + pyshorteners.Shortener().tinyurl.short(teaser.link) + '>'
result += spacer
return result
def check_character_limit(self, payload):
return payload > config.discord_character_limit
def print(self):
print(self.list())