Ejemplo n.º 1
0
from pydub import AudioSegment
from telethon.sync import TelegramClient, errors, functions, types

import config
import models
import utils

if __name__ == '__main__':
    print("For start: uvicorn main:app --reload")
    exit(0)

templates = Jinja2Templates(directory="templates")

app = FastAPI(title="Tapkofon API", version="1.0")
user = TelegramClient("session", config.api_id, config.api_hash)
user.parse_mode = "html"


##### / Работа с подключением / #####
@app.get("/logout",
         description="Деавторизоваться",
         response_class=HTMLResponse)
async def logout():
    await user.log_out()
    return templates.get_template("auth/logout.html").render()


@app.get("/auth_old",
         description="Авторизация через терминал",
         response_class=HTMLResponse)
async def auth_old():
Ejemplo n.º 2
0
""" SamFirm Telegram Bot"""
import asyncio
import pickle
from os import path, remove

from telethon.sync import TelegramClient

from samfirm_bot import API_KEY, API_HASH, BOT_TOKEN, TG_LOGGER, LOCAL_STORAGE, WEB_STORAGE, PARENT_DIR, WORK_DIR
from samfirm_bot.classes.local_client import LocalClient
from samfirm_bot.classes.samfirm import SamFirm
from samfirm_bot.modules import ALL_MODULES
from samfirm_bot.utils.loader import load_modules

BOT = TelegramClient('samfirm_bot', API_KEY,
                     API_HASH).start(bot_token=BOT_TOKEN)
BOT.parse_mode = 'markdown'
BOT_INFO = {}
SAM_FIRM = SamFirm(BOT.loop)
STORAGE = LocalClient(LOCAL_STORAGE, WEB_STORAGE)


def main():
    """Main"""
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run())


async def run():
    """Run the bot."""
    bot_info = await BOT.get_me()
    BOT_INFO.update({
Ejemplo n.º 3
0
import time
from pyrogram import Client
import yaml

with open('config.yaml') as config:
    config = yaml.safe_load(config)

logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")

# Telethon
client = TelegramClient(
        'helperbot-telethon',
        config['telegram']['api_id'],
        config['telegram']['api_hash']
        )
client.parse_mode = 'html'

# Pyrogram
app = Client(
            'helperbot-pyrogram',
            api_id=config['telegram']['api_id'],
            api_hash=config['telegram']['api_hash'],
            bot_token=config['telegram']['bot_token']
        )

ratelimits = dict()
help_dict = {}
whitelisted_chats = config['config']['whitelisted_chats']

def _check_ratelimit(e):
    global ratelimits