Skip to content

Instantly share code, notes, and snippets.

@dmytrostriletskyi
Last active February 14, 2018 22:46
Show Gist options
  • Save dmytrostriletskyi/67261c8864e981a9416d0158298a8199 to your computer and use it in GitHub Desktop.
Save dmytrostriletskyi/67261c8864e981a9416d0158298a8199 to your computer and use it in GitHub Desktop.
How redirect generator create widget
def create_redirect_login_widget(
redirect_url, bot_name, size=SMALL, user_photo=True, access_write=True
):
"""
Create a redirect widget, that allows to handle an user data as get request params.
"""
script_initital = \
'<script async src="https://telegram.org/js/telegram-widget.js?2" '
bot = 'data-telegram-login="{}" '.format(bot_name)
size = 'data-size="{}" '.format(size)
userpic = \
'data-userpic="{}" '.format(str(user_photo).lower()) if not user_photo else ''
redirect = 'data-auth-url="{}" '.format(redirect_url)
access = 'data-request-access="write"' if access_write else ''
script_end = '></script>'
widget_script = \
script_initital + bot + size + userpic + redirect + access + script_end
return widget_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment