Skip to content

Instantly share code, notes, and snippets.

@tamyiuchau
tamyiuchau / bot.py
Created October 31, 2018 14:50
telegram-> kindle book sharing
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Simple Bot to reply to Telegram messages
# This program is dedicated to the public domain under the CC0 license.
"""
This Bot uses the Updater class to handle the bot.
First, a few handler functions are defined. Then, those functions are passed to
the Dispatcher and registered at their respective places.
@tamyiuchau
tamyiuchau / with_bs4.py
Last active April 9, 2019 06:19
abusing with statement to write html in whitespace indentation
from bs4 import BeautifulSoup
from contextlib import contextmanager
__current_soup=[]
@contextmanager
def append(name):
node = __current_soup[0].new_tag(name)
__current_soup.append(node)
global s
s = __current_soup[-1]
yield node