Skip to content

Commit

Permalink
Merge branch 'drop-telegram' into 'main'
Browse files Browse the repository at this point in the history
Drop telegram notifications (ix.ai/notifiers!8)

See merge request ix.ai/cioban!93
  • Loading branch information
tlex committed May 19, 2024
2 parents cace94d + 8926ef8 commit 7428736
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 24 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Gitlab Project](https://img.shields.io/badge/GitLab-Project-554488.svg)](https://gitlab.com/ix.ai/cioban/)


A docker swarm service for automatically updating your services to the latest image tag push. You can enable telegram or gotify notifications, so you get a message after every successful update.
A docker swarm service for automatically updating your services to the latest image tag push. You can enable gotify notifications, so you get a message after every successful update.

## Contributing

Expand All @@ -28,8 +28,6 @@ Cioban will try to update your services every 5 minutes by default. The followin
| `SCHEDULE_TIME` | - | Cron-Style string for scheduled runs. This will **disable** `SLEEP_TIME` |
| `BLACKLIST_SERVICES` | - | Space-separated list of service names to exclude from updates |
| `FILTER_SERVICES` | - | Anything accepted by the filtering flag in `docker service ls`. Example: `label=ai.ix.auto-update=true` |
| `TELEGRAM_TOKEN` | - | See the [Telegram documentation](https://core.telegram.org/bots#creating-a-new-bot) how to get a new token |
| `TELEGRAM_CHAT_ID` | - | See this question on [stackoverflow](https://stackoverflow.com/questions/32423837/telegram-bot-how-to-get-a-group-chat-id) |
| `GOTIFY_URL` | - | The URL of the [Gotify](https://gotify.net/) server |
| `GOTIFY_TOKEN` | - | The APP token for Gotify |
| `GOTIFY_DEFAULT_PRIORITY` | - | If set, this is the priority of the Gotify message. See this comment in [gotify/android#18](https://github.com/gotify/android/issues/18#issuecomment-437403888). Must be integer. |
Expand Down Expand Up @@ -85,8 +83,6 @@ docker service create \
--env BLACKLIST_SERVICES="cioban karma_karma karma_oauth" \
--env FILTER_SERVICES="label=ai.ix.auto-update=true" \
--env LOGLEVEL="WARNING" \
--env TELEGRAM_TOKEN="000000000:zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" \
--env TELEGRAM_CHAT_ID="-0000000000000" \
--env NOTIFY_INCLUDE_NEW_IMAGE="yes" \
--env NOTIFY_INCLUDE_OLD_IMAGE="y" \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
Expand Down Expand Up @@ -137,8 +133,6 @@ services:
NOTIFY_INCLUDE_IMAGE: 'yes'
GOTIFY_URL: "${GOTIFY_URL?err}"
GOTIFY_TOKEN: "${GOTIFY_TOKEN?err}"
TELEGRAM_TOKEN: "${TELEGRAM_TOKEN?err}"
TELEGRAM_CHAT_ID: "${TELEGRAM_CHAT_ID?err}"
LOGLEVEL: INFO
networks:
websites: {}
Expand Down
2 changes: 0 additions & 2 deletions cioban/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
options = helpers.gather_environ()
options['notifiers'] = []

if options.get('telegram_token') and options.get('telegram_chat_id'):
options['notifiers'].append('telegram')
if options.get('gotify_url') and options.get('gotify_token'):
options['notifiers'].append('gotify')

Expand Down
2 changes: 0 additions & 2 deletions cioban/lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ def gather_environ(keys=None) -> dict:
keys = {
'filter_services': 'filter',
'blacklist_services': 'list',
'telegram_token': 'string',
'telegram_chat_id': 'string',
'gotify_url': 'string',
'gotify_token': 'string',
'gotify_default_priority': 'int',
Expand Down
13 changes: 0 additions & 13 deletions cioban/lib/notifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@ def gotify_notify(self, notifier, **kwargs):
}
notifier.send(**params)

def telegram_notify(self, notifier, **kwargs):
""" parses the arguments, formats the message and dispatches it """
log.debug('Sending notification to telegram')
message = f"*{kwargs.get('title')}*\n"
if kwargs.get('message'):
message += kwargs['message']
else:
for k, v in kwargs.items():
if k == 'title':
break
message += f"*{notifier.key_to_title(k)}*: `{v}` \n"
notifier.send(message=message)

def null_notify(self, notifier, **kwargs):
""" dispatches directly """
notifier.send(f'{kwargs}')

0 comments on commit 7428736

Please sign in to comment.