Skip to content

Commit 95d4750

Browse files
author
ilyasProgrammer
committed
[IMP] git comments rectification
1 parent 93a9a15 commit 95d4750

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

telegram/telegram.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from openerp.addons.base.ir.ir_qweb import QWebContext
1919

2020
_logger = logging.getLogger('# Telegram')
21-
telebot.logger.setLevel(logging.DEBUG)
21+
# telebot.logger.setLevel(logging.DEBUG)
2222
SAFE_EVAL_BASE = {
2323
'datetime': datetime,
2424
'dateutil': dateutil,
@@ -40,7 +40,7 @@ class TelegramCommand(models.Model):
4040
name = fields.Char()
4141
python_code = fields.Char()
4242
response_code = fields.Char()
43-
groups = fields.Char()
43+
group_ids = fields.One2many('res.groups', 'telegram_command_id')
4444
response_template = fields.Char()
4545
notify_template = fields.Char()
4646

@@ -54,7 +54,7 @@ def telegram_listener(self, messages, bot):
5454
'TelegramUser': TelegramUser,
5555
'get_parameter': get_parameter}
5656
safe_eval(res[0].python_code, SAFE_EVAL_BASE, locals_dict, mode="exec", nocopy=True)
57-
self.notify(bot, res[0].response_template, locals_dict, telegram_message=m)
57+
self.render_and_send(bot, res[0].response_template, locals_dict, telegram_message=m)
5858
elif len(res) > 1:
5959
raise ValidationError('Multiple values for %s' % res)
6060
else:
@@ -74,13 +74,13 @@ def odoo_listener(self, message, bot):
7474
'TelegramUser': TelegramUser,
7575
'get_parameter': get_parameter}
7676
safe_eval(command.response_code, SAFE_EVAL_BASE, locals_dict, mode="exec", nocopy=True)
77-
self.notify(bot, command.notify_template, locals_dict, bus_message=m)
77+
self.render_and_send(bot, command.notify_template, locals_dict, bus_message=m)
7878
else:
7979
pass # No response code for this command. Response code is optional.
8080
elif len(command) > 1:
8181
raise ValidationError('Multiple values for %s' % command)
8282

83-
def notify(self, bot, template, locals_dict, bus_message=False, telegram_message=False):
83+
def render_and_send(self, bot, template, locals_dict, bus_message=False, telegram_message=False):
8484
"""Response or notify user. template - xml to render with locals_dict."""
8585
qweb = self.pool['ir.qweb']
8686
context = QWebContext(self._cr, self._uid, {})
@@ -127,6 +127,11 @@ def check_access(tele_env, chat_id, command):
127127
# TODO
128128

129129

130+
class ResGroups(models.Model):
131+
_inherit = 'res.groups'
132+
133+
telegram_command_id = fields.Many2one('telegram.command')
134+
130135
# query = """SELECT *
131136
# FROM mail_message as a, mail_message_res_partner_rel as b
132137
# WHERE a.id = b.mail_message_id

0 commit comments

Comments
 (0)