Skip to content

Commit

Permalink
🌈 move constants and library out
Browse files Browse the repository at this point in the history
fixes #294
  • Loading branch information
Ilya Ilchenko committed Jul 16, 2021
1 parent db60aa2 commit 535a693
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion sync_telegram/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"summary": """Telegram integration powered by Sync Studio""",
"category": "Discuss",
"images": ["images/sync_telegram.jpg"],
"version": "14.0.3.2.0",
"version": "14.0.3.2.1",
"application": False,
"author": "IT Projects Labs, Ilya Ilchenko",
"support": "[email protected]",
Expand Down
5 changes: 5 additions & 0 deletions sync_telegram/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
`3.2.1`
-------

- **Improvement:** move constants and library import from _eval_context_telegram class

`3.2.0`
-------

Expand Down
23 changes: 7 additions & 16 deletions sync_telegram/models/sync_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
import logging

import requests
from lxml.html.clean import Cleaner
from telegram import Bot, Update

from odoo import api, fields, models
from odoo.tools import html2plaintext

from odoo.addons.sync.models.sync_project import AttrDict

_logger = logging.getLogger(__name__)

MAX_SIZE_IMAGE = 10485760
MAX_SIZE_DOCUMENT = 52428800
MAX_SIZE_TO_DOWNLOAD = 20971520


class SyncProjectTelegram(models.Model):

Expand All @@ -31,26 +38,10 @@ def _eval_context_telegram(self, secrets, eval_context):
* telegram.setWebhook
* telegram.parse_data
"""
from lxml.html.clean import Cleaner

from odoo.tools import html2plaintext

try:
# https://github.com/python-telegram-bot/python-telegram-bot
from telegram import ( # pylint: disable=missing-manifest-dependency
Bot,
Update,
)
except (ImportError, IOError) as err:
_logger.debug(err)

log_transmission = eval_context["log_transmission"]
log = eval_context["log"]

MAX_SIZE_IMAGE = 10485760
MAX_SIZE_DOCUMENT = 52428800
MAX_SIZE_TO_DOWNLOAD = 20971520

if secrets.TELEGRAM_BOT_TOKEN:
bot = Bot(token=secrets.TELEGRAM_BOT_TOKEN)
else:
Expand Down

0 comments on commit 535a693

Please sign in to comment.