1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
##################################################################
# PyngFM is a Python implementation of Ping.fm API.
#
# Version: 1.0
# Author: Andrea Grandi <a _DOT_ grandi _AT_ gmail _DOT_ com>
# License: GPL2
# Website: http://pyngfm.googlecode.com
#
# Note: this code is inspired to PHPingFM project.
##################################################################
from base64 import b64decode
class Message():
def __init__(self, id=None, method=None, rfc_time=None, unix_time=None,
title=None, body=None, services= [], location = None):
self.__id = id
self.__method = method
self.__rfc_time = rfc_time
self.__unix_time = unix_time
self.__title = title
self.__body = body
self.__services = services
self.__location = location
@property
def id(self):
return self.__id
@property
def method(self):
return self.__method
@property
def rfc_time(self):
return self.__rfc_time
@property
def unix_time(self):
return self.__unix_time
@property
def title(self):
if self.__title != None:
return b64decode(self.__title)
@property
def body(self):
if self.__body != None:
return b64decode(self.__body)
@property
def services(self):
return self.__services
@property
def location(self):
if self.__location != None:
return b64decode(self.__location)
def set_id(self, id):
self.__id = id
def set_method(self, method):
self.__method = method
def set_rfc_time(self, rfc_time):
self.__rfc_time = rfc_time
def set_unix_time(self, unix_time):
self.__unix_time = unix_time
def set_title(self, title):
self.__title = title
def set_body(self, body):
self.__body = body
def add_service(self, service_id, service_name):
service = {'id': service_id, 'name': service_name}
self.__services.append(service)
def set_location(self, location):
self.__location = location
|