Print the received data and remove the button.
(update: Update, context: ContextTypes.DEFAULT_TYPE)
| 41 | |
| 42 | # Handle incoming WebAppData |
| 43 | async def web_app_data(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
| 44 | """Print the received data and remove the button.""" |
| 45 | # Here we use `json.loads`, since the WebApp sends the data JSON serialized string |
| 46 | # (see webappbot.html) |
| 47 | data = json.loads(update.effective_message.web_app_data.data) |
| 48 | await update.message.reply_html( |
| 49 | text=( |
| 50 | f"You selected the color with the HEX value <code>{data['hex']}</code>. The " |
| 51 | f"corresponding RGB value is <code>{tuple(data['rgb'].values())}</code>." |
| 52 | ), |
| 53 | reply_markup=ReplyKeyboardRemove(), |
| 54 | ) |
| 55 | |
| 56 | |
| 57 | def main() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…