diff --git a/telegram/telegram.py b/telegram/telegram.py index e47d613..0dc3f0d 100644 --- a/telegram/telegram.py +++ b/telegram/telegram.py @@ -372,6 +372,7 @@ def _render(self, template, locals_dict, tsession): 'editMessageText': options.get('editMessageText'), 'handle_reply_dump': handle_reply, 'reply_keyboard': False, + 'send_invoice': options.get('sendInvoice'), 'context_dump': simplejson.dumps(locals_dict.get('context', {})), 'html': html} reply_markup = options.get('reply_markup') @@ -463,6 +464,10 @@ def _send(self, bot, rendered, tsession): res = bot.send_photo(tsession.chat_ID, photo['file']) photo['file_id'] = res.photo[0].file_id + if rendered.get('sendInvoice'): + kwargs = rendered.get('sendInvoice') + kwargs['chat_id'] = tsession.chat_ID + bot.send_invoice(**kwargs) handle_reply_dump = rendered.get('handle_reply_dump') handle_reply_command_id = None if self.id and handle_reply_dump: diff --git a/telegram/views/telegram_command_views.xml b/telegram/views/telegram_command_views.xml index 019e0d4..0efd010 100644 --- a/telegram/views/telegram_command_views.xml +++ b/telegram/views/telegram_command_views.xml @@ -101,6 +101,8 @@ Vars that can be updated: * dictonary {'replies': {REPLY: DATA}, 'custom_reply': DATA}. * If user send some value from REPLY, then this command will be called again with telegram['callback_data'] equal to corresponded DATA and and telegram['callback_data'] equal to 'reply'. * If custom_reply is present and user send response not from 'replies', then this command is called with telegram['callback_data'] and telegram['callback_data'] equal to 'custom_reply' + * options['sendInvoice'] - kwargs for bot.send_invoice method. See https://core.telegram.org/bots/api#sendinvoice + * context - dictonary to save json serializable data between user requests. Vars that can be used: diff --git a/telegram_buy_me_a_beer/README.rst b/telegram_buy_me_a_beer/README.rst new file mode 100644 index 0000000..e086306 --- /dev/null +++ b/telegram_buy_me_a_beer/README.rst @@ -0,0 +1,35 @@ +=================== + Buy me a beer bot +=================== + +Allows to people buy a beer for a good man via telegram bot. + +Live example available at `@buy_me_a_beer `_. + +Credits +======= + +Contributors +------------ +* Ivan Yelizariev + +Sponsors +-------- +* `IT-Projects LLC `__ + +Maintainers +----------- +* `IT-Projects LLC `__ + +Further information +=================== + +Demo: http://runbot.it-projects.info/demo/telegram/8.0 + +.. HTML Description: https://apps.odoo.com/apps/modules/8.0/telegram_buy_me_a_beer/ + +Usage instructions: ``_ + +Changelog: ``_ + +Tested on Odoo 8.0 78be4cd1de8c1cfe52e362e1635a028141b03f60 diff --git a/telegram_buy_me_a_beer/__init__.py b/telegram_buy_me_a_beer/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/telegram_buy_me_a_beer/__openerp__.py b/telegram_buy_me_a_beer/__openerp__.py new file mode 100644 index 0000000..be232bf --- /dev/null +++ b/telegram_buy_me_a_beer/__openerp__.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +{ + "name": """Buy me a beer bot""", + "summary": """Please, :-)""", + "category": "Telegram", + "live_test_URL": "t.me/buy_me_a_beer_bot", + "images": [], + "version": "1.0.0", + "application": False, + + "author": "IT-Projects LLC, Ivan Yelizariev", + "support": "apps@it-projects.info", + "website": "https://twitter.com/yelizariev", + "license": "LGPL-3", + # "price": 9.00, + # "currency": "EUR", + + "depends": [ + "telegram_portal", + ], + "external_dependencies": {"python": [], "bin": []}, + "data": [ + "data/telegram_command.xml", + ], + "qweb": [ + ], + "demo": [ + ], + + "post_load": None, + "pre_init_hook": None, + "post_init_hook": None, + + "auto_install": False, + "installable": True, +} diff --git a/telegram_buy_me_a_beer/data/telegram_command.xml b/telegram_buy_me_a_beer/data/telegram_command.xml new file mode 100644 index 0000000..73c1001 --- /dev/null +++ b/telegram_buy_me_a_beer/data/telegram_command.xml @@ -0,0 +1,40 @@ + + + + + + + + + /start%|\U0001f37a + Start here + + +if telegram['tmessage'].text.startswith("/start"): + data['type'] = 'start' + # add reply buttons + buttons = [{'text': u'\U0001f37a', 'callback_data': 1}] + command.keyboard_buttons(options, buttons, row_width=1) +else: + data['type'] = 'invoice' + options['keep_reply_keyboard'] = True + options['sendInvoice'] = { + 'title': 'Beer for a good person', + 'description': 'Support the person, if you like what he does', + 'payload': 'beer', + 'provider_token': env.get_param('telegram_buy_me_a_beer.payment_provider_token'), + 'start_parameter': 'beer', + 'currency': 'USD', + 'prices': [types.LabeledPrice('Beer', 500)], + 'photo_url': env.get_param('web.base.url') + '/telegram_buy_me_a_beer/static/beer.jpg', + } + + +Hi! +Feel free to send me a beer by pressing the \U0001f37a button. + + + + + + diff --git a/telegram_buy_me_a_beer/doc/changelog.rst b/telegram_buy_me_a_beer/doc/changelog.rst new file mode 100644 index 0000000..9ee2b48 --- /dev/null +++ b/telegram_buy_me_a_beer/doc/changelog.rst @@ -0,0 +1,4 @@ +`1.0.0` +------- + +- Init version diff --git a/telegram_buy_me_a_beer/doc/index.rst b/telegram_buy_me_a_beer/doc/index.rst new file mode 100644 index 0000000..1e22965 --- /dev/null +++ b/telegram_buy_me_a_beer/doc/index.rst @@ -0,0 +1,25 @@ +=================== + Buy me a beer bot +=================== + +Configuration +============= + +* Configure `Telegram Bot `__ module +* `Enable technical features `__ +* Open ``Technical / Parameters / System Parameters`` menu. + + * Set ``telegram_buy_me_a_beer.payment_provider_token`` -- a token obtained via `@BotFather `_. For more information see here: https://core.telegram.org/bots/payments#the-payments-api + +Client Usage +============ + +* Send ``/start`` to the bot +* Follow his instruction to send money + +Admin Usage +=========== + +* Withdraw donated money +* Buy a beer +* Drink a beer diff --git a/telegram_buy_me_a_beer/static/beer.jpg b/telegram_buy_me_a_beer/static/beer.jpg new file mode 100644 index 0000000..606ad92 Binary files /dev/null and b/telegram_buy_me_a_beer/static/beer.jpg differ diff --git a/telegram_buy_me_a_beer/static/description/icon.png b/telegram_buy_me_a_beer/static/description/icon.png new file mode 100644 index 0000000..85cffa4 Binary files /dev/null and b/telegram_buy_me_a_beer/static/description/icon.png differ diff --git a/telegram_escpos/doc/index.rst b/telegram_escpos/doc/index.rst index fef7eda..38f66e4 100644 --- a/telegram_escpos/doc/index.rst +++ b/telegram_escpos/doc/index.rst @@ -9,10 +9,10 @@ To use this module you need: * network escpos printer * idea what to print -Installation -============ +Configuration +============= -* Install `Telegram Bot `__ module +* Configure `Telegram Bot `__ module * `Enable technical features `__ * Open ``Technical / Parameters / System Parameters`` menu.