Skip to content

Commit

Permalink
🌈 move constants and library imports from the eval method
Browse files Browse the repository at this point in the history
it was copy-pasted from sync module, where telegram is a demo and we don't require to installing telegram package
close #294
  • Loading branch information
Ilya Ilchenko committed Jul 19, 2021
1 parent 7fb862a commit eaed8c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 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.1",
"version": "14.0.3.2.2",
"application": False,
"author": "IT Projects Labs, Ilya Ilchenko",
"support": "[email protected]",
Expand Down
8 changes: 7 additions & 1 deletion sync_telegram/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
`3.2.2`
-------

- **Improvement:** code clean up

`3.2.1`
-------

**Improvement:** In cases when there are many subscribed partners channel name was too long
- **Improvement:** In cases when there are many subscribed partners channel name was too long


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

import requests
from lxml.html.clean import Cleaner
from telegram import ( # pylint: disable=missing-manifest-dependency; disabled because pre-commit cannot find external dependency in manifest. https://github.com/itpp-labs/DINAR/issues/91
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 @@ -32,26 +42,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 eaed8c0

Please sign in to comment.