leadguru-jobs 0.256.0__py3-none-any.whl → 0.258.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.256.0.dist-info → leadguru_jobs-0.258.0.dist-info}/METADATA +3 -3
- {leadguru_jobs-0.256.0.dist-info → leadguru_jobs-0.258.0.dist-info}/RECORD +5 -5
- lgt_jobs/jobs/bot_stats_update.py +15 -7
- {leadguru_jobs-0.256.0.dist-info → leadguru_jobs-0.258.0.dist-info}/WHEEL +0 -0
- {leadguru_jobs-0.256.0.dist-info → leadguru_jobs-0.258.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: leadguru-jobs
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.258.0
|
4
4
|
Summary: LGT jobs builds
|
5
5
|
Author-email: developer@leadguru.co
|
6
6
|
Classifier: Development Status :: 5 - Production/Stable
|
@@ -20,8 +20,8 @@ Classifier: Topic :: Internet
|
|
20
20
|
Requires-Dist: loguru
|
21
21
|
Requires-Dist: pydantic
|
22
22
|
Requires-Dist: cachetools >=3.1.0
|
23
|
-
Requires-Dist: leadguru-common ==0.
|
24
|
-
Requires-Dist: leadguru-data ==0.
|
23
|
+
Requires-Dist: leadguru-common ==0.316.0
|
24
|
+
Requires-Dist: leadguru-data ==0.323.0
|
25
25
|
Requires-Dist: wheel
|
26
26
|
Requires-Dist: setuptools
|
27
27
|
Requires-Dist: twine
|
@@ -8,7 +8,7 @@ lgt_jobs/smtp.py,sha256=W9OIkckBORAWEsNgIG3nVKs6OTU6esZNnq09WDsj8Lc,1352
|
|
8
8
|
lgt_jobs/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
lgt_jobs/jobs/analytics.py,sha256=bNQpYBPz6CMN0i-wXDzQKcc1L8UYUvyiVGJbUeGdf9Q,1307
|
10
10
|
lgt_jobs/jobs/archive_leads.py,sha256=wZ4LwbuC9G7NB16AO15YiMemEV40LoJVjd8VRqaFv9o,831
|
11
|
-
lgt_jobs/jobs/bot_stats_update.py,sha256=
|
11
|
+
lgt_jobs/jobs/bot_stats_update.py,sha256=o4aSm7byBpnaIRMiVeSijif99nyJXjzWHHldvEK-lCQ,3466
|
12
12
|
lgt_jobs/jobs/chat_history.py,sha256=z9_WfmCyDc-r_qK-Eze4tnEG3ek-HUxyHa8ywSSraA4,5620
|
13
13
|
lgt_jobs/jobs/clear_user_analytics.py,sha256=sP90jhOcZqs67hJV-lJyFJH9Iciqai8IsbNs5fSc90U,2478
|
14
14
|
lgt_jobs/jobs/conversation_replied.py,sha256=pMkalznkVt_j20VfXzZcaGIMXxkIknxDlHKvu4_yrrs,2584
|
@@ -25,7 +25,7 @@ lgt_jobs/jobs/workspace_connect.py,sha256=-EL6YrUhAOAR3dv1HZ12D9xvxL1JHP5208eh6s
|
|
25
25
|
lgt_jobs/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
26
|
lgt_jobs/services/web_client.py,sha256=SZogxjM0jyACRqBOP5EJvtqwe44og8B5B6TMWLpYmKM,1878
|
27
27
|
lgt_jobs/templates/new_message_mail_template.html,sha256=82XdDPtmkJVUWUcZtgd8bv_9-viAG2WWOnf3AhR6PeY,3635
|
28
|
-
leadguru_jobs-0.
|
29
|
-
leadguru_jobs-0.
|
30
|
-
leadguru_jobs-0.
|
31
|
-
leadguru_jobs-0.
|
28
|
+
leadguru_jobs-0.258.0.dist-info/METADATA,sha256=ZOxN-O9RAIiXBBh5DHrQeke6drRaJ-TEBfmr0Ot_ebY,1181
|
29
|
+
leadguru_jobs-0.258.0.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
|
30
|
+
leadguru_jobs-0.258.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
|
31
|
+
leadguru_jobs-0.258.0.dist-info/RECORD,,
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from abc import ABC
|
2
2
|
from typing import Optional
|
3
3
|
from lgt.common.python.slack_client.web_client import SlackWebClient
|
4
|
+
from lgt_data.model import DedicatedBotModel
|
4
5
|
from lgt_data.mongo_repository import BotMongoRepository, DedicatedBotRepository
|
5
6
|
from pydantic import BaseModel
|
6
7
|
from lgt_data.analytics import get_bots_aggregated_analytics
|
@@ -31,21 +32,23 @@ class BotStatsUpdateJob(BaseBackgroundJob, ABC):
|
|
31
32
|
bots_rep = BotMongoRepository()
|
32
33
|
bot = bots_rep.get_by_id(data.bot_name)
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
client = SlackWebClient(bot.token, bot.cookies)
|
36
|
+
if bot.invalid_creds:
|
37
|
+
test_auth_response = client.test_auth()
|
38
|
+
if ((test_auth_response.status_code == 200) and
|
39
|
+
(test_auth_response.json().get("error") != SlackErrors.INVALID_AUTH)):
|
40
|
+
BotStatsUpdateJob.__updated_invalid_creds_flag(bot, False)
|
36
41
|
|
37
42
|
received_messages, filtered_messages = get_bots_aggregated_analytics(bot_ids=[bot.id])
|
38
|
-
client = SlackWebClient(bot.token, bot.cookies)
|
39
43
|
if not bot.token or not bot.cookies:
|
40
44
|
log.warning(f"[BotStatsUpdateJob]: Bot {bot.id} has no credentials.")
|
41
|
-
bot.invalid_creds
|
42
|
-
|
45
|
+
if not bot.invalid_creds:
|
46
|
+
BotStatsUpdateJob.__updated_invalid_creds_flag(bot, True)
|
43
47
|
return
|
44
48
|
channels_response = client.channels_list()
|
45
49
|
if not channels_response['ok']:
|
46
50
|
if channels_response.get("error") == SlackErrors.INVALID_AUTH:
|
47
|
-
bot
|
48
|
-
bots_rep.add_or_update(bot)
|
51
|
+
BotStatsUpdateJob.__updated_invalid_creds_flag(bot, True)
|
49
52
|
else:
|
50
53
|
log.warning(f"[BotStatsUpdateJob]: Error during update bot {bot.id} stats. Error: {channels_response}")
|
51
54
|
return
|
@@ -75,3 +78,8 @@ class BotStatsUpdateJob(BaseBackgroundJob, ABC):
|
|
75
78
|
# save only last 50 messages
|
76
79
|
bot.recent_messages = bot.recent_messages[-50:]
|
77
80
|
bots_rep.add_or_update(bot)
|
81
|
+
|
82
|
+
@staticmethod
|
83
|
+
def __updated_invalid_creds_flag(bot: DedicatedBotModel, invalid_creds: bool):
|
84
|
+
bot.invalid_creds = invalid_creds
|
85
|
+
DedicatedBotRepository().add_or_update(bot)
|
File without changes
|
File without changes
|