229 lines
12 KiB
HTML
229 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html class="writer-html5" lang="zh-CN" >
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>欢迎来到 Xtaothon — Xtaothon Documentation</title>
|
|
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/copybutton.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/tabs.css" type="text/css" />
|
|
<link rel="shortcut icon" href="_static/favicon.ico"/>
|
|
<link rel="canonical" href="https://docs.xtaolabs.com/index.html"/>
|
|
<!--[if lt IE 9]>
|
|
<script src="_static/js/html5shiv.min.js"></script>
|
|
<![endif]-->
|
|
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
|
<script src="_static/jquery.js"></script>
|
|
<script src="_static/underscore.js"></script>
|
|
<script src="_static/doctools.js"></script>
|
|
<script src="_static/clipboard.min.js"></script>
|
|
<script src="_static/copybutton.js"></script>
|
|
<script src="_static/translations.js"></script>
|
|
<script src="_static/js/theme.js"></script>
|
|
<link rel="index" title="索引" href="genindex.html" />
|
|
<link rel="search" title="搜索" href="search.html" />
|
|
<link rel="next" title="快速开始" href="intro/quickstart.html" />
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav">
|
|
<div class="wy-grid-for-nav">
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
<div class="wy-side-scroll">
|
|
<div class="wy-side-nav-search" >
|
|
<a href="#">
|
|
<img src="_static/xtaothon.png" class="logo" alt="Logo"/>
|
|
</a>
|
|
<div role="search">
|
|
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
|
|
<input type="text" name="q" placeholder="Search docs" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Main">
|
|
<p class="caption"><span class="caption-text">简介</span></p>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="intro/quickstart.html">快速开始</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="intro/install.html">安装指南</a></li>
|
|
</ul>
|
|
<p class="caption"><span class="caption-text">开始</span></p>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="start/auth.html">授权</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="start/invoking.html">调用方法</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="start/updates.html">处理消息</a></li>
|
|
</ul>
|
|
<p class="caption"><span class="caption-text">API</span></p>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="api/client.html">客户端</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="api/methods/index.html">可用方法</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="api/types/index.html">可用类型</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="api/bound-methods/index.html">绑定方法</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="api/handlers.html">消息更新处理器</a></li>
|
|
</ul>
|
|
<p class="caption"><span class="caption-text">主题指南</span></p>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="topics/proxy.html">SOCKS5 Proxy</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="topics/text-formatting.html">文本格式</a></li>
|
|
</ul>
|
|
<p class="caption"><span class="caption-text">更多</span></p>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="glossary.html">常见短语</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="support.html">支持 Xtaothon</a></li>
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
<nav class="wy-nav-top" aria-label="Top" >
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
<a href="#">xtaothon</a>
|
|
</nav>
|
|
|
|
<div class="wy-nav-content">
|
|
<div class="rst-content style-external-links">
|
|
|
|
|
|
<div role="navigation" aria-label="Breadcrumbs">
|
|
<ul class="wy-breadcrumbs">
|
|
<li><a href="#" class="icon icon-home"></a> »</li>
|
|
<li>欢迎来到 Xtaothon</li>
|
|
<li class="wy-breadcrumbs-aside">
|
|
<!-- User defined GitHub URL -->
|
|
<a href="https://github.com/Xtao-Labs/docs-all" class="fa fa-github"> Edit on GitHub</a>
|
|
</li>
|
|
</ul>
|
|
<hr/>
|
|
</div>
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
<div itemprop="articleBody">
|
|
|
|
<div class="section" id="xtaothon">
|
|
<h1>欢迎来到 Xtaothon<a class="headerlink" href="#xtaothon" title="永久链接至标题">¶</a></h1>
|
|
<div align="center">
|
|
<a href="/">
|
|
<div><img src="_static/xtaothon.png" alt="Xtaothon Logo" width="420"></div>
|
|
</a>
|
|
</div>
|
|
|
|
<p align="center">
|
|
<b>Telegram MTProto API Framework for Python</b>
|
|
|
|
<br>
|
|
<a href="https://github.com/LonamiWebs/Telethon">
|
|
Source Code
|
|
</a>
|
|
•
|
|
<a href="https://github.com/LonamiWebs/Telethon/releases">
|
|
Releases
|
|
</a>
|
|
•
|
|
<a href="https://t.me/Telethon_CN_Chat">
|
|
Community
|
|
</a>
|
|
</p><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">telethon.sync</span> <span class="kn">import</span> <span class="n">TelegramClient</span><span class="p">,</span> <span class="n">events</span>
|
|
|
|
<span class="k">with</span> <span class="n">TelegramClient</span><span class="p">(</span><span class="s1">'name'</span><span class="p">,</span> <span class="n">api_id</span><span class="p">,</span> <span class="n">api_hash</span><span class="p">)</span> <span class="k">as</span> <span class="n">client</span><span class="p">:</span>
|
|
<span class="n">client</span><span class="o">.</span><span class="n">send_message</span><span class="p">(</span><span class="s1">'me'</span><span class="p">,</span> <span class="s1">'Hello, myself!'</span><span class="p">)</span>
|
|
<span class="nb">print</span><span class="p">(</span><span class="n">client</span><span class="o">.</span><span class="n">download_profile_photo</span><span class="p">(</span><span class="s1">'me'</span><span class="p">))</span>
|
|
|
|
<span class="nd">@client</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">events</span><span class="o">.</span><span class="n">NewMessage</span><span class="p">(</span><span class="n">pattern</span><span class="o">=</span><span class="s1">'(?i).*Hello'</span><span class="p">))</span>
|
|
<span class="k">async</span> <span class="k">def</span> <span class="nf">handler</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
|
|
<span class="k">await</span> <span class="n">event</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s1">'Hey!'</span><span class="p">)</span>
|
|
|
|
<span class="n">client</span><span class="o">.</span><span class="n">run_until_disconnected</span><span class="p">()</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Telegram 是一款十分受欢迎的简洁的即时通讯软件。<strong>Telethon</strong> 旨在使您能够轻松使用 <cite>Python</cite> 编写可以与 <a class="reference external" href="https://telegram.org">Telegram</a> 进行交互的 Python 程序。</p>
|
|
<div class="section" id="id1">
|
|
<h2>快速使用这篇文档<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h2>
|
|
<p>内容总共被分成几大独立主题,这些主题可以从侧边栏或通过页面下方的 <span class="guilabel">下一项</span> 按钮来访问。
|
|
下方我们提供了几个常用的主题以供快速访问。</p>
|
|
<div class="tip admonition">
|
|
<p class="admonition-title">云服务器优惠</p>
|
|
<p>如果您需要服务器来托管您的程序我们推荐使用 <strong>NSD Cloud</strong>. 通过
|
|
<a class="reference external" href="https://nsdcloud.net/aff.php?aff=2">链接</a> 注册就可以帮助 Xtaothon 。</p>
|
|
</div>
|
|
<div class="section" id="id3">
|
|
<h3>出发<a class="headerlink" href="#id3" title="永久链接至标题">¶</a></h3>
|
|
<table class="hlist"><tr><td><ul class="simple">
|
|
<li><p><a class="reference internal" href="intro/quickstart.html"><span class="doc">快速开始</span></a>: 快速使用 Telethon 创建一个应用程序。</p></li>
|
|
<li><p><a class="reference internal" href="start/invoking.html"><span class="doc">调用方法</span></a>: 快速调用 Telethon 的内置方法来与 Telegram 交互。</p></li>
|
|
</ul>
|
|
</td><td><ul class="simple">
|
|
<li><p><a class="reference internal" href="start/updates.html"><span class="doc">处理消息</span></a>: 快速处理来自 Telegram 的新消息。</p></li>
|
|
</ul>
|
|
</td></tr></table>
|
|
</div>
|
|
<div class="section" id="api">
|
|
<h3>API<a class="headerlink" href="#api" title="永久链接至标题">¶</a></h3>
|
|
<table class="hlist"><tr><td><ul class="simple">
|
|
<li><p><a class="reference internal" href="api/client.html"><span class="doc">Telethon Client</span></a>: Client 类的详细可配置参数。</p></li>
|
|
<li><p><a class="reference internal" href="api/methods/index.html"><span class="doc">内置方法</span></a>: 可用的高级方法列表。</p></li>
|
|
</ul>
|
|
</td><td><ul class="simple">
|
|
<li><p><a class="reference internal" href="api/types/index.html"><span class="doc">内置类型</span></a>: 可用的高级类型列表。</p></li>
|
|
<li><p><a class="reference internal" href="api/bound-methods/index.html"><span class="doc">绑定方法</span></a>: 方便的绑定方法列表。</p></li>
|
|
</ul>
|
|
</td></tr></table>
|
|
</div>
|
|
<div class="section" id="id4">
|
|
<h3>更多<a class="headerlink" href="#id4" title="永久链接至标题">¶</a></h3>
|
|
<table class="hlist"><tr><td><ul class="simple">
|
|
<li><p><a class="reference internal" href="faq.html"><span class="doc">Telethon FAQ</span></a>: Telethon 常见问题。</p></li>
|
|
<li><p><a class="reference internal" href="glossary.html"><span class="doc">常见短语</span></a>: 一些常见短语的释意。</p></li>
|
|
</ul>
|
|
</td><td><ul class="simple">
|
|
<li><p><a class="reference internal" href="support.html"><span class="doc">支持 Xtaothon</span></a>: 支持 Xtaothon 的方式。</p></li>
|
|
</ul>
|
|
</td></tr></table>
|
|
<p>最后更新于 2021 年 06 月 11 日</p>
|
|
<div class="toctree-wrapper compound">
|
|
</div>
|
|
<div class="toctree-wrapper compound">
|
|
</div>
|
|
<div class="toctree-wrapper compound">
|
|
</div>
|
|
<div class="toctree-wrapper compound">
|
|
</div>
|
|
<div class="toctree-wrapper compound">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<footer>
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
|
<a href="intro/quickstart.html" class="btn btn-neutral float-right" title="快速开始" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
|
|
</div>
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<p></p>
|
|
</div>
|
|
|
|
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
|
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
|
|
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
<script>
|
|
jQuery(function () {
|
|
SphinxRtdTheme.Navigation.enable(false);
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html> |