This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This gist shows how to run asyncio loop in a separate thread. | |
It could be useful if you want to mix sync and async code together. | |
Python 3.7+ | |
""" | |
import asyncio | |
from datetime import datetime | |
from threading import Thread | |
from typing import Tuple, List, Iterable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This module contains subclasses of :class:`collections.abc.MutableMapping` that keeps track of the | |
keys that where accessed. | |
Warning: | |
Tested only manually. | |
""" | |
from typing import ( | |
TypeVar, | |
DefaultDict, | |
Callable, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import sys | |
from functools import partial | |
if sys.version_info >= (3, 8): | |
_MANUAL_UNWRAP = False | |
else: | |
_MANUAL_UNWRAP = True | |
def is_coroutine_function(obj: object) -> bool: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Tested with pyhon-telegram-bot>=13.5 (>=13.0 should also do the trick …) | |
A small study on the more exotic parameters of inline results for Telegram Bots. | |
Punchline: The effect heavily depends on the client and is not always straight forward. | |
E.g. when passing a `url` to the `input_message_content` of a `InlineQueryResultArticle`, but set | |
`hide_url=True`, the `url` just has no effect at all (on official Android and Windows clients) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
from collections import namedtuple | |
from typing import List | |
Arg = namedtuple('Arg', ['name', 'type_var', 'default']) | |
args = [ | |
Arg('context', 'CCT', 'CallbackContext'), | |
# Order matters! | |
Arg('user_data', 'UD', 'Dict'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
This script prepares the file(s) saved by PicklePersistence for v13.1. How you do it: | |
1. Edit the PicklePersistence according to your settings below. | |
2. Run this script *before* upgrading from 12.x to v13.1 | |
3. Upgrade to v13.1 and run your bot to make sure everything is working |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
############################################################ | |
# MIGRATED TO REPOSITORY | |
# https://github.com/tavinus/cloudsend.sh | |
# | |
# This gist will NOT be updated anymore | |
############################################################ | |
############################################################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
This script prepares the file(s) saved by PicklePersistence for v13.0. How you do it: | |
1. Edit the PicklePersistence according to your settings below. | |
2. Run this script *before* upgrading to v13 | |
3. Upgrade to v13 and run your bot to make sure everything is working |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import itertools | |
import json | |
import os | |
import re | |
import urllib.parse | |
import itertools | |
from telethon import TelegramClient | |
from telethon.utils import get_input_peer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write the numbers of all merged PRs in a file named 'prs', each one in a new line | |
# RST-links will be written to 'links' | |
links = [] | |
with open('prs', 'r') as file: | |
for pr in file.readlines(): | |
pr = pr.strip('\n') | |
pr = '.. _`#{}`: https://github.com/python-telegram-bot/python-telegram-bot/pull/{}'.format(pr, pr) | |
links.append(pr) |
NewerOlder