Package gwibber ::
Package lib
|
|
1 import dbus
2 from gwibber import util
3
5 """
6 GwibberPublic is the public python class which provides convience methods
7 for using Gwibber.
8 """
9
11 bus = dbus.SessionBus()
12 self.service = util.getbus("Service")
13 self.accounts_monitor = util.getbus("Accounts")
14 self.shortener = util.getbus("URLShorten")
15 self.settings = util.SettingsMonitor()
16
17 - def post(self, message):
18 args = [message]
19 self.microblog.operation({
20 "args": args,
21 "opname": "send",
22 })
23
25 """
26 Returns a list of services available as json string
27 example:
28 import json, gwibber.lib
29 gw = gwibber.lib.GwibberPublic()
30 services = json.loads(gw.GetServices())
31 """
32 return self.service.GetServices()
33
35 """
36 Returns a list of services available as json string
37 example:
38 import json, gwibber.lib
39 gw = gwibber.lib.GwibberPublic()
40 accounts = json.loads(gw.GetAccounts())
41 """
42 return self.service.GetAccounts()
43
45 """
46 Posts a message/status update to all accounts with send_enabled = True. It
47 takes one argument, which is a message formated as a string.
48 example:
49 import gwibber.lib
50 gw = gwibber.lib.GwibberPublic()
51 gw.SendMessage("This is a message")
52 """
53 return self.service.SendMessage(message)
54
56 """
57 Calls the Gwibber Service to trigger a refresh operation
58 example:
59 import gwibber.lib
60 gw = gwibber.lib.GwibberPublic()
61 gw.Refresh()
62 """
63 return self.service.Refresh()
64
66 """
67 Takes a long url in and returns a shortened url as a string, based on your
68 configured shortening service
69 example:
70 import gwibber.lib
71 gw = gwibber.lib.GwibberPublic()
72 gw.Shorten(url)
73 """
74 service = self.settings["urlshorter"] or "is.gd"
75 return self.shortener.Shorten(url, service)
76
78 self.accounts_monitor.connect_to_signal("AccountChanged", cb)
79
81 self.accounts_monitor.connect_to_signal("AccountDeleted", cb)
82