@@ -4,11 +4,31 @@ const KEY_signcookie = 'chavy_cookie_rrtv'
44
55const signinfo = { }
66let VAL_signcookie = chavy . getdata ( KEY_signcookie )
7+ const week = "日一二三四五六" . charAt ( new Date ( ) . getDay ( ) )
78
89; ( exec = async ( ) => {
910 chavy . log ( `🔔 ${ cookieName } 开始签到` )
11+ await getuid ( )
12+ await watch ( )
1013 await signdaily ( )
1114 await signwelfare ( )
15+ if ( week == "日" ) {
16+ signinfo . canOpenBag = false
17+ signinfo . diceCount = 1
18+ while ( ! signinfo . canOpenBag && signinfo . diceCount ) {
19+ await baginfo ( )
20+ if ( signinfo . baginfo ) {
21+ if ( signinfo . canOpenBag ) {
22+ await openbag ( )
23+ } else {
24+ await refresh ( )
25+ }
26+ } else {
27+ break
28+ }
29+
30+ }
31+ }
1232 await getquestion ( )
1333 if ( ! signinfo . hasAnswered ) {
1434 await answerquestion ( )
@@ -34,6 +54,48 @@ let VAL_signcookie = chavy.getdata(KEY_signcookie)
3454 chavy . done ( )
3555} ) ( ) . catch ( ( e ) => chavy . log ( `❌ ${ cookieName } 签到失败: ${ e } ` ) , chavy . done ( ) )
3656
57+ function getuid ( ) {
58+ return new Promise ( ( resolve , reject ) => {
59+ let url = { url : `https://api.rr.tv/user/profile` , headers : { token : VAL_signcookie } }
60+ url . headers [ 'clientType' ] = `web`
61+ url . headers [ 'clientVersion' ] = ``
62+ chavy . post ( url , ( error , response , data ) => {
63+ try {
64+ let obj = JSON . parse ( data )
65+ signinfo . uid = obj . data . user . id
66+ resolve ( )
67+ } catch ( e ) {
68+ chavy . msg ( cookieName , `获取会员信息: 失败` , `说明: ${ e } ` )
69+ chavy . log ( `❌ ${ cookieName } getinfo - 获取会员信息失败: ${ e } ` )
70+ chavy . log ( `❌ ${ cookieName } getinfo - response: ${ JSON . stringify ( response ) } ` )
71+ resolve ( )
72+ }
73+ } )
74+ } )
75+ }
76+
77+ function watch ( ) {
78+ return new Promise ( ( resolve , reject ) => {
79+ let playDuration = Math . floor ( Math . random ( ) * - 30 + 10800 )
80+ let objId = Math . floor ( Math . random ( ) * 99 + 153300 )
81+ let playTime = Math . round ( new Date ( ) . getTime ( ) / 1000 )
82+ let url = { url : `https://api.rr.tv/constant/growthCallback` , headers : { token : VAL_signcookie } }
83+ url . body = "growthStr=" + encodeURIComponent ( '{"growthRecordDtos":[{"userId":' + signinfo . uid + ',"clientVersion":"","playDuration":"' + playDuration + '","clientType":"web","objId":"' + objId + '","type":"season","playTime":"' + playTime + '"}]}' ) + "&token=" + VAL_signcookie
84+ url . headers [ 'clientType' ] = `web`
85+ url . headers [ 'clientVersion' ] = ``
86+ chavy . post ( url , ( error , response , data ) => {
87+ try {
88+ resolve ( ) ;
89+ } catch ( e ) {
90+ chavy . msg ( cookieName , `随机观影: 失败` , `说明: ${ e } ` )
91+ chavy . log ( `❌ ${ cookieName } watch - 随机观影失败: ${ e } ` )
92+ chavy . log ( `❌ ${ cookieName } watch - response: ${ JSON . stringify ( response ) } ` )
93+ resolve ( )
94+ }
95+ } ) ;
96+ } ) ;
97+ }
98+
3799function signdaily ( ) {
38100 return new Promise ( ( resolve , reject ) => {
39101 let url = { url : `https://api.rr.tv/rrtv-activity/sign/sign` , headers : { token : VAL_signcookie } }
@@ -162,6 +224,72 @@ function openbox(boxcode, boxname, body) {
162224 } )
163225}
164226
227+ function baginfo ( ) {
228+ return new Promise ( ( resolve , reject ) => {
229+ let url = { url : `https://api.rr.tv/rrtv-activity/sign/getInfo` , headers : { token : VAL_signcookie } }
230+ url . headers [ 'clientType' ] = `web`
231+ url . headers [ 'clientVersion' ] = ``
232+ chavy . post ( url , ( error , response , data ) => {
233+ try {
234+ signinfo . baginfo = JSON . parse ( data )
235+ signinfo . canOpenBag = signinfo . baginfo . data . canOpenBag
236+ signinfo . diceCount = signinfo . baginfo . data . diceCount
237+ resolve ( )
238+ } catch ( e ) {
239+ chavy . msg ( cookieName , `获取礼包信息: 失败` , `说明: ${ e } ` )
240+ chavy . log ( `❌ ${ cookieName } baginfo - 获取礼包信息失败: ${ e } ` )
241+ chavy . log ( `❌ ${ cookieName } baginfo - response: ${ JSON . stringify ( response ) } ` )
242+ resolve ( )
243+ }
244+ } )
245+ } )
246+ }
247+
248+ function openbag ( ) {
249+ return new Promise ( ( resolve , reject ) => {
250+ let url = { url : `https://api.rr.tv/rrtv-activity/sign/openBag` , headers : { token : VAL_signcookie } }
251+ url . headers [ 'clientType' ] = `web`
252+ url . headers [ 'clientVersion' ] = ``
253+ chavy . post ( url , ( error , response , data ) => {
254+ try {
255+ signinfo . openbag = JSON . parse ( data )
256+ resolve ( )
257+ } catch ( e ) {
258+ chavy . msg ( cookieName , `打开礼包: 失败` , `说明: ${ e } ` )
259+ chavy . log ( `❌ ${ cookieName } openbag - 获取会员信息失败: ${ e } ` )
260+ chavy . log ( `❌ ${ cookieName } openbag - response: ${ JSON . stringify ( response ) } ` )
261+ resolve ( )
262+ }
263+ } )
264+ } )
265+ }
266+
267+ function refresh ( ) {
268+ return new Promise ( ( resolve , reject ) => {
269+ let cardDetailList = signinfo . baginfo . data . cardDetailList
270+ for ( l of cardDetailList ) {
271+ if ( l . showDice ) {
272+ var cardId = l . id
273+ break
274+ }
275+ }
276+ let url = { url : `https://api.rr.tv/rrtv-activity/sign/reflashUserCard` , headers : { token : VAL_signcookie } }
277+ url . body = "cardDetailId=" + cardId
278+ url . headers [ 'clientType' ] = `web`
279+ url . headers [ 'clientVersion' ] = ``
280+ chavy . post ( url , ( error , response , data ) => {
281+ try {
282+ resolve ( )
283+ } catch ( e ) {
284+ chavy . msg ( cookieName , `刷新卡片: 失败` , `说明: ${ e } ` )
285+ chavy . log ( `❌ ${ cookieName } refresh - 获取会员信息失败: ${ e } ` )
286+ chavy . log ( `❌ ${ cookieName } refresh - response: ${ JSON . stringify ( response ) } ` )
287+ resolve ( )
288+ }
289+ } )
290+ } )
291+ }
292+
165293function showmsg ( ) {
166294 let subTitle = ''
167295 let detail = ''
@@ -193,42 +321,53 @@ function showmsg() {
193321 } else {
194322 detail = `编码: ${ signinfo . userinfo . code } , 说明: ${ signinfo . userinfo . msg } `
195323 }
196-
197- if ( signinfo . question . data . question ) {
198- detail += `\n查看答题详情`
199- detail += `\n\n问题: ${ signinfo . question . data . question . questionStr } `
200- for ( key in signinfo . questionopts )
201- detail += `\n选项: ${ signinfo . questionopts [ key ] . optionStr } , 回答人数: ${ signinfo . questionopts [ key ] . answererCount } (${ signinfo . questionopts [ key ] . percent } )`
202- if ( signinfo . selectId ) {
203- detail += `\n最佳回答: ${ signinfo . answeropt . optionStr } `
204- detail += `\n我的回答: ${ signinfo . questionopts [ signinfo . selectId ] . optionStr } `
205- detail += `${ signinfo . isRight ? '✅' : '❌' } \n`
206- } else {
207- detail += `\n最佳回答: ${ signinfo . answeropt . optionStr } \n`
208- }
209- }
210-
324+
325+ detail += '\n'
211326 if ( signinfo . copperbox ) {
212327 if ( signinfo . copperbox . code == '0000' ) {
213- for ( box of signinfo . copperbox . data . boxs ) detail += `\n铜宝箱: ${ box . rewardName } (+${ box . rewardNum } )`
328+ detail += '铜宝箱: '
329+ for ( box of signinfo . copperbox . data . boxs ) detail += `${ box . rewardName } (+${ box . rewardNum } ) `
214330 } else {
215- detail += `\n铜宝箱 : ${ signinfo . copperbox . msg } `
331+ detail += `铜宝箱 : ${ signinfo . copperbox . msg } `
216332 }
217333 }
218334
219335 if ( signinfo . silverbox ) {
220336 if ( signinfo . silverbox . code == '0000' ) {
221- for ( box of signinfo . silverbox . data . boxs ) detail += `\n银宝箱: ${ box . rewardName } (+${ box . rewardNum } )`
337+ detail += '银宝箱: '
338+ for ( box of signinfo . silverbox . data . boxs ) detail += `${ box . rewardName } (+${ box . rewardNum } ) `
222339 } else {
223- detail += `\n银宝箱 : ${ signinfo . silverbox . msg } `
340+ detail += `银宝箱 : ${ signinfo . silverbox . msg } `
224341 }
225342 }
226343
227344 if ( signinfo . goldenbox ) {
228345 if ( signinfo . goldenbox . code == '0000' ) {
229- for ( box of signinfo . goldenbox . data . boxs ) detail += `\n金宝箱: ${ box . rewardName } (+${ box . rewardNum } )`
346+ detail += '金宝箱: '
347+ for ( box of signinfo . goldenbox . data . boxs ) detail += `${ box . rewardName } (+${ box . rewardNum } ) `
348+ } else {
349+ detail += `金宝箱: ${ signinfo . goldenbox . msg } `
350+ }
351+ }
352+
353+ if ( signinfo . openbag ) {
354+ if ( signinfo . openbag . code == '0000' ) {
355+ detail += `\n每周礼盒: ${ signinfo . openbag . data . name } `
230356 } else {
231- detail += `\n金宝箱: ${ signinfo . goldenbox . msg } `
357+ detail += `\n每周礼盒: ${ signinfo . openbag . msg } `
358+ }
359+ }
360+
361+ if ( signinfo . question . data . question ) {
362+ detail += `\n\n问题: ${ signinfo . question . data . question . questionStr } `
363+ for ( key in signinfo . questionopts )
364+ detail += `\n选项: ${ signinfo . questionopts [ key ] . optionStr } , 回答人数: ${ signinfo . questionopts [ key ] . answererCount } (${ signinfo . questionopts [ key ] . percent } )`
365+ if ( signinfo . selectId ) {
366+ detail += `\n最佳回答: ${ signinfo . answeropt . optionStr } `
367+ detail += `\n我的回答: ${ signinfo . questionopts [ signinfo . selectId ] . optionStr } `
368+ detail += `${ signinfo . isRight ? '✅' : '❌' } \n`
369+ } else {
370+ detail += `\n最佳回答: ${ signinfo . answeropt . optionStr } \n`
232371 }
233372 }
234373 chavy . msg ( cookieName , subTitle , detail )
0 commit comments