This repository has been archived by the owner on Jan 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
weibo_message.py
executable file
·74 lines (67 loc) · 1.89 KB
/
weibo_message.py
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
# -*- coding: utf-8 -*-
import os
class WeiboMessage(object):
"""weibo message struct"""
def __init__(self, text, images=None):
super(WeiboMessage, self).__init__()
self.text = text if text is not None else ""
self.text = self.text.replace('@', 'rp @'+u'\ufeff')
self.images = images
self.pids = ""
self.rt = False
self.rt_mid = ""
self.pids = ""
@property
def has_image(self):
return self.images is not None \
and len(self.images) > 0
@property
def is_empty(self):
return len(self.text) == 0 \
and not self.has_image
@property
def is_retweet(self):
return self.rt
def get_send_data(self):
# if not pids:
# pids = self.pids
data = {
"location": "v6_content_home",
"appkey": "",
"style_type": "1",
"pic_id": self.pids,
"text": self.text,
"pdetail": "",
"rank": "0",
"rankid": "",
"module": "stissue",
"pub_type": "dialog",
"_t": "0",
}
return data
def get_rt_data(self):
# if not pids:
# pids = self.pids
# if not mid:
# mid = '4380981861287509',
data = {
"pic_src": "",
"pic_id": self.pids,
"appkey": "",
"mid": self.rt_mid,
"style_type": "1",
"mark": "",
"reason": self.text,
"location": "page_100505_home",
"module": '',
"page_module_id": "",
"refer_sort": "",
"rank": "0",
"rankid": "0",
"isReEdit": "false",
"_t": "0"
}
return data
def __str__(self):
return "text: " + self.text + os.linesep \
+ "images: " + str(self.images)