使用telethon包的时候,上传文件到tg机器人,遇到以下报错

TypeError: An asyncio.Future, a coroutine or an awaitable is required

实际使用:

from telethon import TelegramClientclient = TelegramClient(name, api_id, api_hash)def sendFileMsg():client.send_file("+852xxxxxxx", 'test.txt', voice_note=True)with client:client.loop.run_until_complete(sendFileMsg())

这个报错实际看文档能大概知道是什么原因,文档里示范client的使用:

from telethon import TelegramClientclient = TelegramClient(name, api_id, api_hash)async def main():# Now you can use all client methods listed below, like for example...await client.send_message('me', 'Hello to myself!')with client:client.loop.run_until_complete(main())

client.loop.run_until_complete直接调用的时候,方法需要异步,即修改为:

async def sendFileMsg():client.send_file("+852xxxxxxx", 'test.txt', voice_note=True)

telethon TypeError: An asyncio.Future, a coroutine or an awaitable is required解决相关推荐

  1. asyncio 系列四、期程 — asyncio.Future

    asyncio的期程 官网链接:https://docs.python.org/zh-cn/3/library/asyncio-future.html#asyncio.Future 其实期程指的是,c ...

  2. python asyncio future_Python 期物之 asyncio.Future

    asyncio.Future 第三次更新,2020-02-13 Future 的作用 负责终止 loop 的循环. 1.loop 停止循环的唯一条件为 loop._stopping = True 2. ...

  3. 利用while True: break 解决 asyncio:Future exception was never retrieved !

    在if 循环中,break的作用 def test1():my_redis = Redis(db=7)for i in range(1, 1000):my_redis.lpush("redi ...

  4. Vue报错:Uncaught TypeError: Cannot assign to read only property ‘exports‘ of object 的解决方法

    Vue报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object 的解决方法 参考文章: (1)Vue ...

  5. react 中 Warning A future version of React will block javascript 异常解决

    react 中 Warning A future version of React will block javascript 异常解决 问题描述 <a href="javascrip ...

  6. DataFrame/Series运行round()函数报错“TypeError: a float is required”解决办法

    DataFrame/Series运行round()函数报错"TypeError: a float is required"解决办法 原代码片段: #把数据按年龄分层,然后按照不同层 ...

  7. python asyncio future 多线程_深究Python中的asyncio库-线程池

    在同步线程中使用的run_in_executor就如它方法的名字所示,把协程放到了一个执行器里面,可以在一个线程池,也可以在一个进程池.另外还可以使用run_coroutine_threadsafe在 ...

  8. pip安装库包遇到错误:TypeError: expected str, bytes or os.PathLike object, not int 的解决方法

    1 问题描述 1.在安装python3的库包时候,遇到和os模块相关的错误:TypeError: expected str, bytes or os.PathLike object, not int, ...

  9. Vue3.x 报 Uncaught TypeError:Object(...) is not a function( Vue3对象不是函数解决思路)

    今天在vue3的练习时候发现我写的路由总是浏览器报错,仔细校验文档发现并没有错误啊,可总是报Uncaught TypeError:Object(...) is not a function的错误,看下 ...

最新文章

  1. 平板电脑怎么投屏到电视上_电脑屏幕投屏到平板、IPAD、艾派德
  2. tensorlfow.saved_model的使用
  3. 面向对象2(构造方法、抽象类、接口)
  4. Java - 自己动手之在线书店(2)
  5. POJ-1067取石子游戏,威佐夫博弈范例题/NYOJ-161,主要在于这个黄金公式~~
  6. mysqlmodify_modify与change的区别
  7. date()---求N个月后的1号
  8. 交通部 城轨交通运营管理规定_重庆启动节前轨道交通运营管理安全执法检查...
  9. vue+vuex初入门
  10. OpenVINO DL workbench的docker安装
  11. 算法基本知识,入门必备
  12. MySQL讲义第 45 讲——select 查询之查询练习(三)
  13. vue 会议室日历预约组件
  14. 用 Python 绘制 XMind 思维导图
  15. win7计算机睡眠后无法唤醒,win7系统待机后打不开怎么办|win7待机无法唤醒的解决方法...
  16. 异鲁米诺标记/多环芳烃半抗原载聚苯乙烯微球固载N-羟基邻苯二甲酰亚胺的制备反应
  17. 2023 年破解 PDF 密码的 5 种最佳方法
  18. 2019 CCPC 女生专场重现赛 Circle
  19. 台式计算机如何升级,台式电脑怎样升级系统
  20. python 爬虫:下载小说

热门文章

  1. k-means聚类算法与局部最优解
  2. Vert.x MySQL Client中文版
  3. Consider defining a bean of type ‘XXX‘ in your configuration.
  4. royaleapi中文版_皇室战争:CR锄强扶弱式平衡调整基本成型,精锐成4月扶贫对象...
  5. Android 渠道包 动态生成 apk 名称
  6. 加推个人名片为何受到资本和市场的青睐?
  7. 候选码、主码、全码、外码、主属性、主键、主关键字、非主属性
  8. primitive原始数据类型
  9. 1521端口 mysql_Linux开放1521端口允许网络连接Oracle Listener
  10. 三星 SCX-4521NS 网络打印机 在XP 下 强行 设置 安装