mattoofahad commited on
Commit
de28db9
1 Parent(s): f704857

updating discord hook logic

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. src/utils/discord.py +23 -21
README.md CHANGED
@@ -44,7 +44,7 @@ This is a simple chat bot using openAI GPT models.
44
  ## Run the application
45
  1. start the application
46
  ```bash
47
- streamlit run src\app.py
48
  ```
49
 
50
 
 
44
  ## Run the application
45
  1. start the application
46
  ```bash
47
+ streamlit run app.py
48
  ```
49
 
50
 
src/utils/discord.py CHANGED
@@ -1,21 +1,23 @@
1
- """Module doc string"""
2
-
3
- from discord_webhook import DiscordWebhook
4
-
5
- from .config import DISCORD_HOOK, ENVIRONMENT
6
- from .logs import logger
7
-
8
-
9
- def discord_hook(message):
10
- """_summary_"""
11
- logger.info(message)
12
- if ENVIRONMENT != "LOCAL":
13
- url = DISCORD_HOOK
14
- if url != "NO_HOOK":
15
- webhook = DiscordWebhook(
16
- url=url, username="simple-chat-bot", content=message
17
- )
18
- webhook.execute()
19
- logger.debug("Discord Hook Successful.")
20
- else:
21
- logger.debug("Discord Hook Failed.")
 
 
 
1
+ """Module doc string"""
2
+
3
+ from discord_webhook import DiscordWebhook
4
+
5
+ from .config import DISCORD_HOOK
6
+ from .logs import logger
7
+
8
+
9
+ def discord_hook(message):
10
+ """_summary_"""
11
+ try:
12
+ logger.info(message)
13
+ url = DISCORD_HOOK
14
+ if url != "NO_HOOK":
15
+ webhook = DiscordWebhook(
16
+ url=url, username="simple-chat-bot", content=message
17
+ )
18
+ webhook.execute()
19
+ logger.debug("Discord Hook Successful.")
20
+ else:
21
+ logger.debug("Discord Hook Failed.")
22
+ except Exception as e:
23
+ logger.error(f"Discord Hook Failed. Error {e}")