Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
notification_center
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
porramet
notification_center
Commits
c511d951
Commit
c511d951
authored
Mar 27, 2025
by
porramet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
udate
parent
98ee8070
Pipeline
#1697
failed with stages
Changes
11
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
32 additions
and
21 deletions
+32
-21
README.md
README.md
+8
-10
setup.py
setup.py
+1
-1
__init__.py
src/__init__.py
+0
-3
__init__.py
src/notification_center/__init__.py
+3
-0
notification_center.py
src/notification_center/notification_center.py
+4
-4
notification_sender.py
src/notification_center/notification_sender.py
+3
-3
__init__.py
src/notification_center/strategies/__init__.py
+0
-0
gmail.py
src/notification_center/strategies/gmail.py
+0
-0
notification_strategy.py
src/notification_center/strategies/notification_strategy.py
+0
-0
telegram.py
src/notification_center/strategies/telegram.py
+0
-0
testna.py
testna.py
+13
-0
No files found.
README.md
View file @
c511d951
...
...
@@ -6,7 +6,7 @@ pip install git+https://git.igridproject.info/porrametict/notification_center.gi
How to Use
1.
Configure the Notification
Service
1.
Configure the Notification
center
You need to create a configuration dictionary for both Gmail and/or Telegram. The configuration should look like this:
```
python
...
...
@@ -24,11 +24,11 @@ config = {
}
```
2.
Initialize the Notification
Service
2.
Initialize the Notification
center
```
python
from
notification_
service
import
NotificationService
notification_
service
=
NotificationService
(
config
)
from
notification_
center
import
NotificationCenter
notification_
center
=
NotificationCenter
(
config
)
```
3.
Send a Notification
...
...
@@ -39,9 +39,8 @@ Example:
Sending a Gmail Notification:
```
python
from
src.strategies.gmail
import
MessageParams
gmail_params
:
MessageParams
=
{
gmail_params
=
{
"to"
:
[
"poramet.tan@nectec.or.th"
],
"subject"
:
"Test Notification"
,
"body"
:
f
"""
...
...
@@ -55,15 +54,14 @@ notification_params = {
"params"
:
gmail_params
}
notification_
service
.
send_notification
(
notification_params
)
notification_
center
.
send_notification
(
notification_params
)
```
Sending a Telegram Notification:
```
python
from
src.strategies.telegram
import
MessageParams
telegram_params
:
MessageParams
=
{
telegram_params
=
{
"text"
:
f
"""Hello World"""
}
...
...
@@ -72,5 +70,5 @@ notification_params = {
"params"
:
telegram_params
}
notification_
service
.
send_notification
(
notification_params
)
notification_
center
.
send_notification
(
notification_params
)
```
setup.py
View file @
c511d951
from
setuptools
import
setup
,
find_packages
setup
(
name
=
'n
c_service
'
,
name
=
'n
otification_center
'
,
version
=
'1.0.0'
,
packages
=
find_packages
(
where
=
'src'
),
package_dir
=
{
''
:
'src'
},
...
...
src/__init__.py
deleted
100644 → 0
View file @
98ee8070
import
strategies.gmail
as
gmail
import
strategies.telegram
as
telegram
from
notification_service
import
*
\ No newline at end of file
src/notification_center/__init__.py
0 → 100644
View file @
c511d951
from
.strategies
import
gmail
from
.strategies
import
telegram
from
.notification_center
import
*
\ No newline at end of file
src/notification_
service
.py
→
src/notification_
center/notification_center
.py
View file @
c511d951
from
typing
import
TypedDict
,
Union
,
Literal
,
Optional
from
src
.strategies.gmail
import
Gmail
,
MessageParams
as
GmailMessageParams
from
src
.strategies.telegram
import
Telegram
,
MessageParams
as
TelegramMessageParams
from
src
.notification_sender
import
NotificationSender
from
.strategies.gmail
import
Gmail
,
MessageParams
as
GmailMessageParams
from
.strategies.telegram
import
Telegram
,
MessageParams
as
TelegramMessageParams
from
.notification_sender
import
NotificationSender
class
GmailConfig
(
TypedDict
):
...
...
@@ -24,7 +24,7 @@ class NotificationMessageParams(TypedDict):
method
:
Literal
[
'gmail'
,
'telegram'
]
params
:
Union
[
GmailMessageParams
,
TelegramMessageParams
]
class
Notification
Service
:
class
Notification
Center
:
_config
:
NotificationConfig
_gmail_strategy
:
Optional
[
Gmail
]
=
None
_telegram_strategy
:
Optional
[
Telegram
]
=
None
...
...
src/notification_sender.py
→
src/notification_
center/notification_
sender.py
View file @
c511d951
from
typing
import
Union
from
strategies.gmail
import
MessageParams
as
GmailMessageParams
from
strategies.telegram
import
MessageParams
as
TelegramMessageParams
from
strategies.notification_strategy
import
NotificationStrategy
from
.
strategies.gmail
import
MessageParams
as
GmailMessageParams
from
.
strategies.telegram
import
MessageParams
as
TelegramMessageParams
from
.
strategies.notification_strategy
import
NotificationStrategy
class
NotificationSender
:
...
...
src/strategies/__init__.py
→
src/
notification_center/
strategies/__init__.py
View file @
c511d951
File moved
src/strategies/gmail.py
→
src/
notification_center/
strategies/gmail.py
View file @
c511d951
File moved
src/strategies/notification_strategy.py
→
src/
notification_center/
strategies/notification_strategy.py
View file @
c511d951
File moved
src/strategies/telegram.py
→
src/
notification_center/
strategies/telegram.py
View file @
c511d951
File moved
testna.py
0 → 100644
View file @
c511d951
from
notification_center
import
NotificationCenter
from
src
import
config
_config
=
{
"telegram"
:
{
"bot_token"
:
config
.
TG_BOT_TOKEN
,
# Telegram bot token
"chat_id"
:
config
.
TG_CHAT_ID
,
# The chat ID to send messages to
}
}
ns
=
NotificationCenter
(
_config
)
params
=
{
"method"
:
"telegram"
,
"params"
:{
"text"
:
"TEST"
}}
ns
.
send_notification
(
params
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment