Skip to content

Instantly share code, notes, and snippets.

View MasterGroosha's full-sized avatar

Aleksandr MasterGroosha

View GitHub Profile
@MasterGroosha
MasterGroosha / bot.py
Last active January 8, 2023 07:06
Set only needed updates (aiogram 2.20+)
import asyncio
import logging
from aiogram import Bot, Dispatcher
from aiogram.types import BotCommand
from bot.config_reader import load_config
from bot.middlewares.config import ConfigMiddleware
from bot.handlers.main_group_events import register_group_events
from bot.handlers.callbacks_reports import register_callbacks_reports
@MasterGroosha
MasterGroosha / index.html
Created April 16, 2021 13:42
Vue rendering: preventing unnecesary re-rendering by passing objects
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</script>
</head>
<body>
<div id="app">
</div>
</body>
@MasterGroosha
MasterGroosha / bot.py
Created November 25, 2020 11:09
aiogram custom filter example
import logging
from aiogram import Bot, Dispatcher, executor, types
from aiogram.dispatcher.filters import Filter
logging.basicConfig(level=logging.INFO)
bot = Bot(token="")
dp = Dispatcher(bot)
admins = set()
@MasterGroosha
MasterGroosha / aiogram_cli.py
Created November 14, 2020 23:00
The simpliest CLI for aiogram
import asyncio
import shlex
from aiogram import Bot
from json import loads, dumps
# Suppress DeprecationWarning from close() method
import logging
logging.captureWarnings(True)
###
# Telegram-казино
# Этот код позволяет понять, какие именно значения выпали в дайсе "казино" по тому, что вернул Bot API
# Авторы: @Groosha, @svinerus | 2020 год
###
from typing import List
# 0 1 2 3
casino = ["BAR", "виноград", "лимон", "семь"]
@MasterGroosha
MasterGroosha / whitelist.py
Created April 12, 2020 09:16 — forked from JrooTJunior/whitelist.py
Whitelist Middleware
from typing import Any, Dict, List, Set
from aiogram import types
from aiogram.dispatcher.handler import CancelHandler
from aiogram.dispatcher.middlewares import BaseMiddleware
from loguru import logger
class WhitelistMiddleware(BaseMiddleware):
def __init__(self, users: Set[int]):
Здесь будут куски кода к 14-му уроку моего учебника
// This is a piece of code how Commit and Revert (reset) are called
// m_Git is a TGitClient instance
void main() {
const auto commitMessage = "Some commit message";
std::string commitError;
if(!m_Git.MakeCommitToRepo(commitError, commitMessage)) {
std::cout << "MakeCommit returned error: " << commitError << std::endl;
}
std::cout << "Commited\n";
// This is a list of your own shortcuts for Telegram Desktop
// You can see full list of commands in the 'shortcuts-default.json' file
// Place a null value instead of a command string to switch the shortcut off
[
// The two commands below are "inactive"
// {
// "command": "close_telegram",
// "keys": "ctrl+f4"
// },