leadguru-jobs 0.404.0__py3-none-any.whl → 0.405.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {leadguru_jobs-0.404.0.dist-info → leadguru_jobs-0.405.0.dist-info}/METADATA +5 -10
- leadguru_jobs-0.405.0.dist-info/RECORD +26 -0
- lgt_jobs/__init__.py +4 -4
- lgt_jobs/jobs/analytics.py +1 -1
- lgt_jobs/jobs/archive_leads.py +2 -2
- lgt_jobs/jobs/bot_stats_update.py +11 -10
- lgt_jobs/jobs/chat_history.py +6 -6
- lgt_jobs/jobs/inbox_leads.py +6 -5
- lgt_jobs/jobs/mass_message.py +2 -2
- lgt_jobs/jobs/send_code.py +1 -1
- lgt_jobs/jobs/send_slack_message.py +5 -5
- lgt_jobs/jobs/update_slack_profile.py +14 -12
- lgt_jobs/jobs/user_balance_update.py +5 -5
- lgt_jobs/jobs/workspace_connect.py +5 -7
- lgt_jobs/main.py +11 -9
- lgt_jobs/runner.py +9 -6
- lgt_jobs/smtp.py +1 -1
- leadguru_jobs-0.404.0.dist-info/RECORD +0 -49
- lgt_jobs/lgt_common/__init__.py +0 -0
- lgt_jobs/lgt_common/discord_client/__init__.py +0 -0
- lgt_jobs/lgt_common/discord_client/discord_client.py +0 -58
- lgt_jobs/lgt_common/discord_client/methods.py +0 -15
- lgt_jobs/lgt_common/enums/__init__.py +0 -0
- lgt_jobs/lgt_common/enums/slack_errors.py +0 -6
- lgt_jobs/lgt_common/helpers.py +0 -18
- lgt_jobs/lgt_common/lgt_logging.py +0 -15
- lgt_jobs/lgt_common/pubsub/__init__.py +0 -0
- lgt_jobs/lgt_common/pubsub/command.py +0 -14
- lgt_jobs/lgt_common/pubsub/messages.py +0 -37
- lgt_jobs/lgt_common/pubsub/pubsubfactory.py +0 -51
- lgt_jobs/lgt_common/slack_client/__init__.py +0 -0
- lgt_jobs/lgt_common/slack_client/methods.py +0 -46
- lgt_jobs/lgt_common/slack_client/slack_client.py +0 -392
- lgt_jobs/lgt_common/slack_client/web_client.py +0 -164
- lgt_jobs/lgt_data/__init__.py +0 -0
- lgt_jobs/lgt_data/analytics.py +0 -723
- lgt_jobs/lgt_data/engine.py +0 -223
- lgt_jobs/lgt_data/enums.py +0 -68
- lgt_jobs/lgt_data/helpers.py +0 -2
- lgt_jobs/lgt_data/model.py +0 -964
- lgt_jobs/lgt_data/mongo_repository.py +0 -980
- {leadguru_jobs-0.404.0.dist-info → leadguru_jobs-0.405.0.dist-info}/WHEEL +0 -0
- {leadguru_jobs-0.404.0.dist-info → leadguru_jobs-0.405.0.dist-info}/top_level.txt +0 -0
@@ -1,164 +0,0 @@
|
|
1
|
-
import requests
|
2
|
-
from google.cloud import storage
|
3
|
-
from datetime import datetime, timedelta
|
4
|
-
from lgt_jobs.lgt_data.model import SlackHistoryMessageModel
|
5
|
-
from .slack_client import SlackClient
|
6
|
-
|
7
|
-
|
8
|
-
def get_file_url(blob_path):
|
9
|
-
storage_client = storage.Client()
|
10
|
-
bucket = storage_client.get_bucket(SlackFilesClient.bucket_name)
|
11
|
-
blob = bucket.get_blob(blob_path)
|
12
|
-
if not blob:
|
13
|
-
return None
|
14
|
-
# valid for 3 days
|
15
|
-
return blob.generate_signed_url(timedelta(3))
|
16
|
-
|
17
|
-
|
18
|
-
class SlackMessageConvertService:
|
19
|
-
@staticmethod
|
20
|
-
def from_slack_response(user_email, bot_name, bot_token, dic, cookies=None):
|
21
|
-
|
22
|
-
"""
|
23
|
-
:rtype: SlackHistoryMessageModel
|
24
|
-
"""
|
25
|
-
result = SlackHistoryMessageModel()
|
26
|
-
result.text = dic.get('text', '')
|
27
|
-
result.type = dic.get('type', '')
|
28
|
-
result.user = dic.get('user', '')
|
29
|
-
result.ts = dic.get('ts', '')
|
30
|
-
result.attachments = dic.get('attachments', [])
|
31
|
-
result.files = []
|
32
|
-
|
33
|
-
if 'files' in dic:
|
34
|
-
for file in dic.get('files'):
|
35
|
-
if file.get('mode', '') == "tombstone" or not file.get('url_private_download'):
|
36
|
-
continue
|
37
|
-
new_file = SlackHistoryMessageModel.SlackFileModel()
|
38
|
-
new_file.id = file.get('id')
|
39
|
-
new_file.name = file.get('name')
|
40
|
-
new_file.title = file.get('title')
|
41
|
-
new_file.filetype = file.get('filetype')
|
42
|
-
new_file.size = file.get('size')
|
43
|
-
new_file.mimetype = file.get('mimetype')
|
44
|
-
|
45
|
-
url_private_download = file.get('url_private_download')
|
46
|
-
new_file.download_url = SlackFilesClient.get_file_url(user_email, bot_name, bot_token,
|
47
|
-
new_file.id, url_private_download,
|
48
|
-
new_file.mimetype, cookies)
|
49
|
-
result.files.append(new_file)
|
50
|
-
|
51
|
-
js_ticks = int(result.ts.split('.')[0] + result.ts.split('.')[1][3:])
|
52
|
-
result.created_at = datetime.fromtimestamp(js_ticks / 1000.0)
|
53
|
-
return result
|
54
|
-
|
55
|
-
|
56
|
-
class SlackFilesClient:
|
57
|
-
bucket_name = 'lgt_service_file'
|
58
|
-
|
59
|
-
# Consider to cache these file somewhere in the super-fast cache solution
|
60
|
-
@staticmethod
|
61
|
-
def get_file_url(user_email, bot_name, bot_token, file_id, url_private_download, mimetype, cookies=None):
|
62
|
-
storage_client = storage.Client()
|
63
|
-
bucket = storage_client.get_bucket(SlackFilesClient.bucket_name)
|
64
|
-
blob_path = f'slack_files/{user_email}/{bot_name}/{file_id}'
|
65
|
-
blob = bucket.get_blob(blob_path)
|
66
|
-
|
67
|
-
if not blob:
|
68
|
-
res = requests.get(url_private_download, headers={'Authorization': f'Bearer {bot_token}'}, cookies=cookies)
|
69
|
-
if res.status_code != 200:
|
70
|
-
raise Exception(
|
71
|
-
f'Failed to download file: {url_private_download} from slack due to response: '
|
72
|
-
f'Code: {res.status_code} Error: {res.content}')
|
73
|
-
blob = bucket.blob(blob_path)
|
74
|
-
blob.upload_from_string(res.content, content_type=mimetype)
|
75
|
-
|
76
|
-
blob = bucket.get_blob(blob_path)
|
77
|
-
# valid for 3 days
|
78
|
-
return blob.generate_signed_url(timedelta(3))
|
79
|
-
|
80
|
-
|
81
|
-
class SlackWebClient:
|
82
|
-
def __init__(self, token, cookies=None):
|
83
|
-
if isinstance(cookies, list):
|
84
|
-
cookies = {c['name']: c['value'] for c in cookies}
|
85
|
-
|
86
|
-
self.client = SlackClient(token, cookies)
|
87
|
-
|
88
|
-
def delete_message(self, channel: str, ts: str):
|
89
|
-
return self.client.delete_message(channel, ts)
|
90
|
-
|
91
|
-
def update_message(self, channel: str, ts: str, text: str, file_ids=''):
|
92
|
-
return self.client.update_message(channel, ts, text, file_ids)
|
93
|
-
|
94
|
-
def get_profile(self, user_id):
|
95
|
-
return self.client.user_info(user_id)
|
96
|
-
|
97
|
-
def get_im_list(self):
|
98
|
-
return self.client.get_im_list()
|
99
|
-
|
100
|
-
def chat_history(self, channel):
|
101
|
-
return self.client.conversations_history(channel)
|
102
|
-
|
103
|
-
def post_message(self, to, text):
|
104
|
-
return self.client.post_message(to, text)
|
105
|
-
|
106
|
-
def user_list(self):
|
107
|
-
return self.client.users_list()
|
108
|
-
|
109
|
-
def channels_list(self):
|
110
|
-
return self.client.get_conversations_list()
|
111
|
-
|
112
|
-
def im_open(self, sender_id):
|
113
|
-
return self.client.im_open(sender_id)
|
114
|
-
|
115
|
-
def update_profile(self, profile):
|
116
|
-
return self.client.update_profile(profile)
|
117
|
-
|
118
|
-
def channel_join(self, channels):
|
119
|
-
return self.client.join_channels(channels)
|
120
|
-
|
121
|
-
def channel_leave(self, channels):
|
122
|
-
return self.client.leave_channels(channels)
|
123
|
-
|
124
|
-
def get_reactions(self, channel, ts):
|
125
|
-
return self.client.get_reactions(channel, ts)
|
126
|
-
|
127
|
-
def upload_file(self, file, file_name):
|
128
|
-
return self.client.upload_file(file, file_name)
|
129
|
-
|
130
|
-
def download_file(self, file_url):
|
131
|
-
return self.client.download_file(file_url)
|
132
|
-
|
133
|
-
def delete_file(self, file_id):
|
134
|
-
return self.client.delete_file(file_id)
|
135
|
-
|
136
|
-
def share_files(self, files_ids: list, channel: str, text: str = None) -> dict:
|
137
|
-
return self.client.share_files(files_ids, channel, text)
|
138
|
-
|
139
|
-
def check_email(self, email: str, user_agent: str) -> bool:
|
140
|
-
return self.client.check_email(email, user_agent)
|
141
|
-
|
142
|
-
def confirm_email(self, email: str, user_agent: str, locale: str = 'en-US') -> bool:
|
143
|
-
return self.client.confirm_email(email, user_agent, locale)
|
144
|
-
|
145
|
-
def confirm_code(self, email: str, code: str, user_agent: str, ) -> requests.Response:
|
146
|
-
return self.client.confirm_code(email, code, user_agent)
|
147
|
-
|
148
|
-
def find_workspaces(self, user_agent: str, ) -> requests.Response:
|
149
|
-
return self.client.find_workspaces(user_agent)
|
150
|
-
|
151
|
-
def conversation_replies(self, channel: str, ts: str) -> dict:
|
152
|
-
return self.client.conversations_replies(channel, ts)
|
153
|
-
|
154
|
-
def create_shared_invite(self):
|
155
|
-
return self.client.create_shared_invite()
|
156
|
-
|
157
|
-
def send_slack_invite_to_workspace(self, email: str):
|
158
|
-
return self.client.send_slack_invite_to_workspace(email=email)
|
159
|
-
|
160
|
-
def test_auth(self):
|
161
|
-
return self.client.test_auth()
|
162
|
-
|
163
|
-
def get_team_info(self):
|
164
|
-
return self.client.get_team_info()
|
lgt_jobs/lgt_data/__init__.py
DELETED
File without changes
|