Giter Club home page Giter Club logo

marie-2.0-english's Introduction

Pyrogram
Telegram MTProto API Framework for Python
Documentation Releases Community

Pyrogram

from pyrogram import Client, Filters

app = Client("my_account")


@app.on_message(Filters.private)
def hello(client, message):
    message.reply_text("Hello {}".format(message.from_user.first_name))


app.run()

Pyrogram is an elegant, easy-to-use Telegram client library and framework written from the ground up in Python and C. It enables you to easily create custom apps for both user and bot identities (bot API alternative) via the MTProto API.

Pyrogram in fully-asynchronous mode is also available »

Working PoC of Telegram voice calls using Pyrogram »

Features

  • Easy: You can install Pyrogram with pip and start building your applications right away.
  • Elegant: Low-level details are abstracted and re-presented in a much nicer and easier way.
  • Fast: Crypto parts are boosted up by TgCrypto, a high-performance library written in pure C.
  • Documented: Pyrogram API methods, types and public interfaces are well documented.
  • Type-hinted: Exposed Pyrogram types and method parameters are all type-hinted.
  • Updated, to make use of the latest Telegram API version and features.
  • Bot API-like: Similar to the Bot API in its simplicity, but much more powerful and detailed.
  • Pluggable: The Smart Plugin system allows to write components with minimal boilerplate code.
  • Comprehensive: Execute any advanced action an official client is able to do, and even more.

Requirements

Installing

pip3 install pyrogram

Resources

Contributing

Pyrogram is brand new, and you are welcome to try it and help make it even better by either submitting pull requests or reporting issues/bugs as well as suggesting best practices, ideas, enhancements on both code and documentation. Any help is appreciated!

Copyright & License

marie-2.0-english's People

Contributors

tgexplore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

marie-2.0-english's Issues

problem with bans and kicks and mutes

Hello, there is a problem with the bot that every time a manager does not have permission to remove people from the group, it is enough that he has minimal management so the bot lets him do it as if he has the option to remove the people from the group, can you fix the glitch?

TRANSLATOR

Hello, @TGExplore
As i noticed there is a issue on your repo.
As it holds CMD - /tr for correcting grammer
I think that's wrong as i noticed most of the people were reporting about translator
As i have suggestion... You Must have CMD - /gr for grammer correction &
you must leave /tr for translator when you get time.
Yeah, do not ment about hurting the work of Mr Paul & Marie it's a req of users to have it.

Thanks
MrHonekawa

Translate

import asyncioimport itertoolsimport loggingimport randomfrom collections import defaultdictfrom datetime import datetimefrom urllib.parse import quote, urljoin import aiohttpfrom aiocache import Cachefrom async_lru import alru_cache from i17obot import configfrom i17obot.models import Stringfrom i17obot.utils import seconds_until_tomorrow TRANSIFEX_API = { "python": "https://www.transifex.com/api/2/project/python-newest/", "jupyter": "https://www.transifex.com/api/2/project/jupyter-meta-documentation/",} PROJECT_URL = { "python": ( "https://www.transifex.com/" "python-doc/python-newest/translate/#{language}/{resource}/1" "?q={query_string}" ), "jupyter": ( "https://www.transifex.com/" "project-jupyter/jupyter-meta-documentation/translate/#{language}/{resource}/1" "?q={query_string}" ),} FILTER_RESOURCES_TO_BE_TRANSLATED = { "python": lambda r: r.split("--")[0] in ["bugs", "howto", "library"], "jupyter": None,} WEEK_IN_SECONDS = 604_800 logging.basicConfig(level=logging.INFO)logger = logging.getLogger() logger.info(config.CACHE_URL)cache = Cache.from_url(config.CACHE_URL) STRINGS_CACHE = defaultdict(dict) async def transifex_api(url, project, data=None, retrying=False, ttl=3600): url = urljoin(TRANSIFEX_API[project], url) if not data and (in_cache := await cache.get(url)): return in_cache if retrying: logger.debug("retrying url=%s", url) auth = aiohttp.BasicAuth(login="api", password=config.TRANSIFEX_TOKEN) async with aiohttp.ClientSession(auth=auth) as session: http_method = session.put if data else session.get kwargs = {"json": data} if data else {} try: async with http_method(url, **kwargs) as response: logger.debug("url=%s, status_code=%s", url, response.status) try: response = await response.json() if not data: await cache.set(url, response, ttl=3600) return response except aiohttp.ContentTypeError: response = await response.text() logger.warn("response=%r", response) return response except aiohttp.client_exceptions.ClientConnectorSSLError as e: logger.error("url=%s, error=%s", url, e) if not retrying: await asyncio.sleep(2) return await transifex_api(url, project, retrying=True) raise async def review_string(project, resource, language, translation, string_hash): return await transifex_api( f"resource/{resource}/translation/{language}/string/{string_hash}", project, data={"translation": translation, "reviewed": True}, ) async def random_resource(project): resources = await transifex_api(f"resources/", project, ttl=WEEK_IN_SECONDS) resources = [resource["slug"] for resource in resources] if FILTER_RESOURCES_TO_BE_TRANSLATED[project]: resources = filter(FILTER_RESOURCES_TO_BE_TRANSLATED[project], resources) resource = random.choice(list(resources)) logger.info("random_resource, resource=%s", resource) return resource async def strings_from_resource(resource, language, project): strings = await transifex_api( f"resource/{resource}/translation/{language}/strings/?details", project, ) logger.info( "getting strings from resource, resource=%s, strings_found=%s", resource, len(strings), ) return [ String.from_transifex( resource=resource, language=language, project=project, **string ) for string in strings ] async def random_string( language, project, resource=None, translated=None, reviewed=None, max_size=None): if not resource: resource = await random_resource(project) strings = await strings_from_resource(resource, language, project) if translated is not None: strings = filter(lambda s: bool(s.translation) == translated, strings) if reviewed is not None: strings = filter(lambda s: s.reviewed == reviewed, strings) if max_size is not None: strings = filter(lambda s: len(s.source) <= max_size, strings) strings = list(strings) if not strings: if max_size: max_size += 300 resource = None return await random_string( language, project, resource, translated, reviewed, max_size ) string = random.choice(strings) return string def transifex_string_url(resource, key, language, project): return PROJECT_URL[project].format( resource=resource, language=language, query_string=quote(f"text:'{key[:20]}'"), ) async def translate_string(user, string): await transifex_api( f"resource/{string.resource}/translation/{string.language}/string/{string.hash}/", string.project, data={"translation": string.translation, "user": user.transifex_username}, ) async def stats_from_resource(resource, language, project="python"): return await transifex_api(f"resource/{resource}/stats/{language}/", project,) async def download_all_strings(language): """ Download all strings in Transifex to JSON file """ today = datetime.today().strftime("%Y-%m-%d") resources = await transifex_api(f"resources/", "python") resources = [resource["slug"] for resource in resources] print("Resources", len(resources)) sema = asyncio.Semaphore(10) async with sema: strings = await asyncio.gather( *[strings_from_resource(resource, language) for resource in resources] ) strings = list(itertools.chain.from_iterable(strings)) print("Strings", len(resources)) return strings async def translation_stats(language): today = datetime.today() key = f"stats-{today.strftime('%Y-%m-%d')}" if (stats := await cache.get(key)) : return stats print(f"Statistics not cached for {language}") resources = await transifex_api(f"resources/", "python") resources = [resource["slug"] for resource in resources] print("Resources", len(resources)) sema = asyncio.Semaphore(1) async with sema: stats = await asyncio.gather( *[stats_from_resource(resource, language) for resource in resources] ) ttl = seconds_until_tomorrow(today) cache.set(key, stat, ttl=ttl) return stats

python update

hello! i have a issue like this python version is unavabile a new python version is avabile, sooo can you fix it please?
resim_2021-01-21_230706

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.