Skip to main content

Twetch SDK for Python 的基于类的实现

项目描述

Twetch2py

一个基于类的库,用于将Twetch SDK与 Python 结合使用。

安装

  1. 在 CLI 模式下安装 Twetch SDK:
npm install -g @twetch/sdk
  1. 从命令行初始化 Twetch SDK:
twetch init
  1. twetch2py在 pip 上安装:
pip3 install twetch2py
  1. 导入twetch2py您的项目:
from twetch2py import Twetch
  1. 在Twetch 开发者页面上验证您的签名地址。不要忘记为您的钱包注资!

用法

实例化后,Twetch 对象具有以下属性:

  1. content:基于文本的帖子的字符串。接受 @ 和分支 URL。
  2. media:富媒体的文件名(如图像)。相对路径将在发布前转换为绝对路径。
  3. reply_tx:要回复的帖子的事务 ID。
  4. like_tx:要赞的帖子的交易ID。
  5. published_url:成功的帖子和点赞会将您的 Twetch 的 URL 设置为该属性。
  6. tweet: 布尔值。如果True,目标 Twetch 将被交叉发布到 Twitter。
  7. hide_link: 布尔值。如果为 true 并且tweet评估为True,则 Twetch 链接将在 Twitter 上隐藏。

该库还可以获取有关您的 Twetch SDK 安装的以下信息:

  1. get_balance():返回您在 BSV 中的签名地址余额。
  2. get_address():返回您的 Twetch SDK BSV 钱包的签名地址。

例子

# Make a text post
my_twetch = Twetch(content="Hello from Python!")
my_twetch.publish()

# Branch a post
my_branch = Twetch(content="https://twetch.app/t/b9ca41ea6e7302016ab039babe19548f74feccdbd2addbc1c50b3e49907e6ef4")
my_branch.publish()

# Quote a post
my_quote = Twetch(content="This is a quote branch! https://twetch.app/t/b9ca41ea6e7302016ab039babe19548f74feccdbd2addbc1c50b3e49907e6ef4")
my_quote.publish()

# Post an image
my_image_twetch = Twetch(content="Image from Python!", media="images/myimage.jpg")
my_image_twetch.publish()

# Reply to a post
my_reply = Twetch(content="Hello fellow Twetcher!", reply_tx="b9ca41ea6e7302016ab039babe19548f74feccdbd2addbc1c50b3e49907e6ef4")
my_reply.publish()

# Reply to a post w/image and text
my_reply = Twetch(content="Hello with image!", media="images/myimage.jpg", reply_tx="b9ca41ea6e7302016ab039babe19548f74feccdbd2addbc1c50b3e49907e6ef4")
my_reply.publish()

# Tweet from Twetch
my_twetch = Twetch(content="Hello Twitter from Twetch!", tweet=True)
my_twetch.publish()

# Tweet from Twetch, hide Twetch link on Twitter
my_twetch = Twetch(content="Hello Twitter from Twetch!", tweet=True, hide_link=True)
my_twetch.publish()

# Like a post
my_like = Twetch(like_tx="b9ca41ea6e7302016ab039babe19548f74feccdbd2addbc1c50b3e49907e6ef4")
my_like.like_twetch()

# Print your active signing address (returns a string)
twetch_object = Twetch()
print(twetch_object.get_address())

# Print the balance of your signing wallet (returns a float)
twetch_object = Twetch()
print(twetch_object.get_balance())

执照

Twetch2py 由 Cyphergato, LLC 提供。根据MIT 许可证,可以免费使用。

如果您觉得这个开源库有用,请考虑捐赠以支持其开发!

  • 支付宝:cyphergato@moneybutton.com
  • 地址:12Jm4J1GxWfA52JdiYHLovhwaFmy89LD6Q

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

twetch2py-0.0.5.tar.gz (4.1 kB 查看哈希

已上传 source