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
from functools import wraps | |
from telegram import ChatAction | |
def before_response(function): | |
"""Do something before responding""" | |
def do_before(func): | |
@wraps(func) |
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
from functools import wraps | |
from telegram.ext import Updater, CommandHandler | |
# Using a factory function (closures) to contain the started-state of the bot | |
# This is cleaner and better-practice than using globals | |
def state_factory(): | |
"""Factory function for containing the bot state.""" | |
state = False |
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 time | |
from functools import wraps | |
timeout_funcs = {} | |
def get_seconds(): | |
return int(round(time.time())) | |
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 os | |
from functools import wraps | |
from sqlalchemy import create_engine, Column, Integer, String | |
from sqlalcheny.ext.declarative import declarative_base | |
from sqlalchemy.orm import sessionmaker | |
def is_admin(func): | |
"""Checks wether the user who issues the command is the admin. | |
Use this if there's supposed to be one, and only one admin.""" |