首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我如何从python发邮件到Gwibber?

我如何从python发邮件到Gwibber?
EN

Ask Ubuntu用户
提问于 2012-06-19 04:47:36
回答 1查看 169关注 0票数 6

我如何从python发邮件到Gwibber?

我试过了

代码语言:javascript
复制
import gwibber.utils
foo = gwibber.utils.GwibberPublic()
foo.post("This is a test message")

来自https://wiki.ubuntu.com/Quickly/Snippets

但不起作用。

EN

回答 1

Ask Ubuntu用户

发布于 2012-06-19 14:33:50

您应该真正使用基于GIR的API,下面是一个更最新的示例:

代码语言:javascript
复制
from gi.repository import Gwibber

s = Gwibber.Service ()
s.send_message ("This is the content to post", None, None, None)

这将发送到当前启用的所有帐户发送。下面是send_message的参数:

代码语言:javascript
复制
"""
  send_message: Posts a message
  @message: The message to post to Gwibber as a string or None
  @id: The gwibber message id or None
  @action: The action or None (reply, private)
  @account_id: The ID of the account to post from or None
"""

因此,如果您只想从某个特定帐户发帖,您可以这样做:

代码语言:javascript
复制
from gi.repository import Gwibber
accounts_service = Gwibber.Accounts.new ()
s = Gwibber.Service ()

accts = accounts_service.list () # A list of Gwibber.Account objects
for acct in accts:
    print "Gwibber ID: %s, Service: %s, Username: %s, Send: %s" % (acct.props.id, acct.props.service, acct.props.username, "True" if acct.props.send_enabled == "1" else "False")
    #add code to check if this is the account you want to post from, like if you want to post from all twitter accounts you would do this
    if acct.props.service == "twitter":
        s.send_message ("Whatever you want to post", None, None, acct.props.id)
票数 6
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/152882

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档