Skip to content
This repository has been archived by the owner on Mar 21, 2021. It is now read-only.

8.0 telegram buy me a beer #77

Open
wants to merge 2 commits into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions telegram/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions telegram/views/telegram_command_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 35 additions & 0 deletions telegram_buy_me_a_beer/README.rst
Original file line number Diff line number Diff line change
@@ -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 <t.me/buy_me_a_beer_bot>`_.

Credits
=======

Contributors
------------
* Ivan Yelizariev <[email protected]>

Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__

Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__

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: `<doc/index.rst>`_

Changelog: `<doc/changelog.rst>`_

Tested on Odoo 8.0 78be4cd1de8c1cfe52e362e1635a028141b03f60
Empty file.
36 changes: 36 additions & 0 deletions telegram_buy_me_a_beer/__openerp__.py
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"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,
}
40 changes: 40 additions & 0 deletions telegram_buy_me_a_beer/data/telegram_command.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="telegram.command" id="telegram.help_command">
<field name="active" eval="False"/>
</record>

<record model="telegram.command" id="telegram.command_start">
<field name="name">/start%|\U0001f37a</field>
<field name="description">Start here</field>
<field name="sequence" eval="900"/>
<field name="response_code">
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',
}
</field>
<field name="response_template" type="xml"><t><t t-if="data['type']=='start'">
Hi!
Feel free to send <a href="https://github.com/it-projects-llc/odoo-telegram">me</a> a beer by pressing the \U0001f37a button.
</t></t></field>
<field name="group_ids" eval="[]"/>
</record>

</data>
</openerp>
4 changes: 4 additions & 0 deletions telegram_buy_me_a_beer/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
`1.0.0`
-------

- Init version
25 changes: 25 additions & 0 deletions telegram_buy_me_a_beer/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
===================
Buy me a beer bot
===================

Configuration
=============

* Configure `Telegram Bot <https://www.odoo.com/apps/modules/10.0/telegram/>`__ module
* `Enable technical features <https://odoo-development.readthedocs.io/en/latest/odoo/usage/technical-features.html>`__
* Open ``Technical / Parameters / System Parameters`` menu.

* Set ``telegram_buy_me_a_beer.payment_provider_token`` -- a token obtained via `@BotFather <https://t.me/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
Binary file added telegram_buy_me_a_beer/static/beer.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions telegram_escpos/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ To use this module you need:
* network escpos printer
* idea what to print

Installation
============
Configuration
=============

* Install `Telegram Bot <https://www.odoo.com/apps/modules/10.0/telegram/>`__ module
* Configure `Telegram Bot <https://www.odoo.com/apps/modules/10.0/telegram/>`__ module
* `Enable technical features <https://odoo-development.readthedocs.io/en/latest/odoo/usage/technical-features.html>`__
* Open ``Technical / Parameters / System Parameters`` menu.

Expand Down