This repository has been archived by the owner on Aug 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
setting.py
executable file
·417 lines (353 loc) · 13.4 KB
/
setting.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# -*- coding: utf-8 -*-
import random
import configparser
import os
import requests
import json
import urllib3
import hashlib
from base64 import b64encode
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# 小偶像名字
def idol_name():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
# idol name
idol_name = cf.get('idol', 'name')
return str(idol_name)
def getPa():
t = int(time.time())*1000
r = random.randint(1000, 9999)
salt = "K4bMWJawAtnyyTNOa70S"
s = "{}{}{}".format(t, r, salt).encode("utf-8")
m = hashlib.md5(s).hexdigest()
pa = b64encode("{},{},{}".format(t, r, m).encode("utf-8"))
return pa
# ----------------------摩点微打赏设置----------------------
# # 摩点名称
# def wds_name():
# BASE_DIR = os.path.dirname(__file__)
# file_path = os.path.join(BASE_DIR, 'setting.conf')
# cf = configparser.ConfigParser()
# # with open(file_path, 'r') as cfgfile:
# with open(file_path, 'r', encoding='utf-8') as cfgfile:
# cf.readfp(cfgfile)
# # modian
# modian_name = cf.get('modian', 'name')
# # modian_url = cf.get('modian', 'url')
# # pro_id = cf.get('modian', 'pro_id')
# return str(modian_name)
#
#
# # 摩点网址 建议使用短网址
# def wds_url():
# BASE_DIR = os.path.dirname(__file__)
# file_path = os.path.join(BASE_DIR, 'setting.conf')
# cf = configparser.ConfigParser()
# # with open(file_path, 'r') as cfgfile:
# with open(file_path, 'r', encoding='utf-8') as cfgfile:
# cf.readfp(cfgfile)
# # modian
# # modian_name = cf.get('modian', 'name')
# modian_url = cf.get('modian', 'url')
# # pro_id = cf.get('modian', 'pro_id')
# return str(modian_url)
# 摩点项目对应pro_id
def pro_id():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
# modian
# modian_name = cf.get('modian', 'name')
# modian_url = cf.get('modian', 'url')
pro_id = cf.get('modian', 'pro_id')
array = list(map(int, pro_id.split(',')))
return (array)
# 摩点查询时间间隔读取
def md_interval():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
# modian
interval = cf.get('modian', 'interval')
return int(interval)
# # 获取配置中存储的集资消息时间
# def read_md_time10():
# BASE_DIR = os.path.dirname(__file__)
# file_path = os.path.join(BASE_DIR, 'setting.conf')
# cf = configparser.ConfigParser()
# with open(file_path, 'r', encoding='utf-8') as cfgfile:
# cf.readfp(cfgfile)
# msgtime = cf.get('modian', 'time')
# return int(msgtime)
#
#
# # 写入配置中存储的集资消息时间
# def write_md_time10(msgtime10):
# BASE_DIR = os.path.dirname(__file__)
# file_path = os.path.join(BASE_DIR, 'setting.conf')
# cf = configparser.ConfigParser()
# with open(file_path, 'r', encoding='utf-8') as cfgfile:
# cf.readfp(cfgfile)
# with open(file_path, 'w+', encoding='utf-8') as cfgfile2:
# cf.set('modian', 'time', str(msgtime10))
# cf.write(cfgfile2)
# --------------------------------------------------------
# ----------------------口袋48设置----------------------
# 口袋48:roomId
def roomId():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
roomId = cf.get('koudai48', 'roomId')
ownerId = cf.get('koudai48', 'ownerId')
return int(roomId), int(ownerId)
# 获取配置中存储的口袋房间消息时间
def read_kdmsg_time13():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
msgtime = cf.get('koudai48', 'msgTime')
return int(msgtime)
# 写入配置中存储的口袋房间消息时间
def write_kdmsg_time13(msgtime13):
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
with open(file_path, 'w+', encoding='utf-8') as cfgfile2:
cf.set('koudai48', 'msgTime', str(msgtime13))
cf.write(cfgfile2)
# 获取配置中存储的token
def token():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
# koudai48
# user = cf.get('koudai48', 'user')
# password = cf.get('koudai48', 'password')
token = cf.get('koudai48', 'token')
return str(token)
# 验证token
def token_verify():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
# koudai48
# user = cf.get('koudai48', 'user')
# password = cf.get('koudai48', 'password')
token = cf.get('koudai48', 'token')
url = 'https://pocketapi.48.cn/user/api/v1/user/info/home'
form = {
"userId": 1
}
header = {
'Host': 'pocketapi.48.cn',
'accept': '*/*',
'Accept-Language': 'zh-Hans-CN;q=1',
'User-Agent': 'PocketFans201807/6.0.13 (iPhone; iOS 10.3.3; Scale/2.00)',
'Accept-Encoding': 'gzip, deflate',
'appInfo': '{"osType":"ios","vendor":"apple","os":"ios","appVersion":"6.0.13","osVersion":"10.3.3","deviceName":"iPhone 5","appBuild":"200513","deviceId":"DDDD-DDDD-DDDD-DDDD-DDDD"}',
'Content-Type': 'application/json;charset=utf-8',
'Connection': 'keep-alive',
'token': token,
'pa': getPa(),
}
response = requests.post(
url,
data=json.dumps(form),
headers=header,
verify=False,
timeout=15).json()
if response['status'] == 200:
return True
else:
return False
# 获取新token
def getNewToken():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
# koudai48
user = cf.get('koudai48', 'user')
password = cf.get('koudai48', 'password')
# token = cf.get('koudai48', 'token')
# request
ajax_url = "https://pocketapi.48.cn/user/api/v1/login/app/mobile"
header = {
'Host': 'pocketapi.48.cn',
'accept': '*/*',
'Accept-Language': 'zh-Hans-CN;q=1',
'User-Agent': 'PocketFans201807/6.0.13 (iPhone; iOS 10.3.3; Scale/2.00)',
'Accept-Encoding': 'gzip, deflate',
'appInfo': '{"osType":"ios","vendor":"apple","os":"ios","appVersion":"6.0.13","osVersion":"10.3.3","deviceName":"iPhone 5","appBuild":"200513","deviceId":"DDDD-DDDD-DDDD-DDDD-DDDD"}',
'Content-Type': 'application/json;charset=utf-8',
'Connection': 'keep-alive',
}
form = {
"mobile": user,
"pwd": password
}
response = requests.post(
ajax_url,
data=json.dumps(form),
headers=header,
verify=False
).json()
if response['status'] == 200:
newToken = response['content']['token']
cf.set('koudai48', 'token', newToken)
with open(file_path, 'w+', encoding='utf-8') as cfgfile2:
cf.write(cfgfile2)
return 'success'
else:
return response['message']
# 口袋48房间查询时间间隔读取
def kd_interval():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
interval = cf.get('koudai48', 'interval')
return int(interval)
# --------------------------------------------------------
# ----------------------qq群设置----------------------
# qq群id
def groupid():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
group_id = cf.get('QQqun', 'id')
array = list(map(int, group_id.split(',')))
return array
# 欢迎信息
def welcome():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
# group_welcome
words = cf.get('QQqun', 'welcome')
msg = words.replace('\\n', '\n')
return msg
# 关键词触发
# 禁言关键词,留空则无禁言
def shutup():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
shutword = cf.get('QQqun', 'shutword')
if shutword:
wordlist = shutword.split(',')
else:
wordlist = []
return wordlist
# --------------------------------------------------------
# ----------------------微博设置----------------------
# 手机网页版微博地址
def weibo_url():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
weibo_url = cf.get('weibo', 'weiboURL')
return str(weibo_url)
# weibo container id
def weibo_id():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
weibo_id = cf.get('weibo', 'weiboID')
return int(weibo_id)
# weibo房间查询时间间隔读取
def wb_interval():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
interval = cf.get('weibo', 'interval')
return int(interval)
# --------------------------------------------------------
# ----------------------代理设置----------------------
def proxy():
BASE_DIR = os.path.dirname(__file__)
file_path = os.path.join(BASE_DIR, 'setting.conf')
cf = configparser.ConfigParser()
# with open(file_path, 'r') as cfgfile:
with open(file_path, 'r', encoding='utf-8') as cfgfile:
cf.readfp(cfgfile)
https = cf.get('proxy', 'https')
if https:
list_https = https.split(',')
proxies = {}
proxies['https'] = random.choice(list_https)
else:
list_https = []
proxies = {}
# list_http = ['113.118.98.220:9797', '183.62.196.10:3128', '61.135.217.7:80', '61.155.164.109:3128', '61.155.164.107:3128']
# list_https = ['114.115.140.25:3128', '59.56.74.205:3128', '116.31.75.97:3128', '121.43.178.58:3128', '113.79.75.82:9797']
# proxies['http'] = random.choice(list_http)
# proxies['https'] = random.choice(list_https)
return proxies
# ---------------------长网址转短网址----------------------------
def get_short_url(long_url_str):
return str(long_url_str)
try:
url = 'http://api.t.sina.com.cn/short_url/shorten.json?source=3271760578&url_long=' + str(long_url_str)
response = requests.get(
url,
verify=False,
timeout=5
).json()
urlShort = response[0]['url_short']
return urlShort
except Exception as e:
# print(response)
# return response[0]['url_short']
"""
考虑换成百度短网址,等待系统收录
{'Code': -3, 'LongUrl': 'https://zhongchou.modian.com/item/67397.html',
'ErrMsg': 'this URL has not been detected and recorded, please retry after
recording (normally within 24 hours). see https://dwz.cn/console/faq'}
"""
return str(long_url_str)
# -------------------------------------------------------