MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / web_app_data

Function web_app_data

examples/webappbot.py:43–54  ·  view source on GitHub ↗

Print the received data and remove the button.

(update: Update, context: ContextTypes.DEFAULT_TYPE)

Source from the content-addressed store, hash-verified

41
42# Handle incoming WebAppData
43async 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
57def main() -> None:

Callers

nothing calls this directly

Calls 2

ReplyKeyboardRemoveClass · 0.90
reply_htmlMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…