Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Save New Duplicate & Edit Just Text Twitter | |
""" | |
This example is under the same license as aiogram itself. | |
https://github.com/aiogram/aiogram/blob/dev-3.x/LICENSE | |
""" | |
from os import getenv | |
from typing import Any, Dict, Tuple |
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 asgiref.sync import async_to_sync | |
bot = Bot('ABC') | |
async_to_sync(bot.send_message)( | |
chat_id='123', text='abc | |
) |
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
# берет хтмл из grades на my.university.innopolis.ru, | |
# и считает гпа по формуле (grades * credits)/credits. | |
# положить файлик рядом с main.py под именем gpa.html | |
# КАЧАЙ html из https://my.university.innopolis.ru/profile/personal-form/index?tab=validations | |
from bs4 import BeautifulSoup | |
with open("gpa.html", "r") as f: | |
html_doc = f.read() |
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 aiogram import Bot, Dispatcher, executor | |
import logging | |
from aiogram.contrib.fsm_storage.memory import MemoryStorage | |
logging.basicConfig(level=logging.INFO) | |
token = 'BOT_TOKEN_HERE' | |
bot = Bot(token) | |
dp = Dispatcher(bot, storage=MemoryStorage()) |
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 warnings | |
def my_depr_func(user=None, **kwargs): | |
if 'user_id' in kwargs: | |
user = kwargs.pop('user_id') | |
warnings.simplefilter('always', DeprecationWarning) | |
warnings.warn("message", category=DeprecationWarning) | |
warnings.simplefilter('default', DeprecationWarning) | |
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 is a echo bot. | |
It echoes any incoming text messages. | |
""" | |
import logging | |
from aiogram import Bot, Dispatcher, executor, types | |
API_TOKEN = 'BOT_API_TOKEN' |
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 functools | |
import logging | |
from typing import Coroutine | |
from aiogram import Bot, Dispatcher, executor, types | |
from aiogram.contrib.fsm_storage.memory import MemoryStorage | |
API_TOKEN = 'BOT_TOKEN_HERE' | |
# Configure logging | |
logging.basicConfig(level=logging.INFO) |
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 aiogram import Bot, Dispatcher, executor, types | |
from aiogram.dispatcher.filters.builtin import Text | |
API_TOKEN = 'BOT_TOKEN' | |
# Initialize bot and dispatcher | |
bot = Bot(token=API_TOKEN) | |
dp = Dispatcher(bot) | |
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 logging | |
import asyncio | |
from pathlib import Path | |
from typing import Optional | |
from aiogram import Bot, Dispatcher, executor, types | |
from aiogram.utils.exceptions import TelegramAPIError | |
from aiogram.types import InlineKeyboardMarkup | |
from aiogram.contrib.fsm_storage.files import JSONStorage | |
from aiogram.dispatcher import FSMContext | |
from aiogram.dispatcher.filters.state import State, StatesGroup |
NewerOlder