MCPcopy Create free account
hub / github.com/NobyDa/Script / signBars

Function signBars

BDTieBa-DailyBonus/TieBa.js:154–205  ·  view source on GitHub ↗
(bars, tbs, index)

Source from the content-addressed store, hash-verified

152}
153
154function signBars(bars, tbs, index) {
155 //$nobyda.notify("贴吧签到", `进度${index}/${bars.length}`, "");
156 if (index >= bars.length) {
157 //$nobyda.notify("贴吧签到", "签到已满", `${process.result.length}`);
158 checkIsAllProcessed();
159 } else {
160 var bar = bars[index];
161 if (bar.is_sign == 1) { //已签到的,直接不请求接口了
162 process.result.push({
163 bar: `${bar.forum_name}`,
164 level: bar.user_level,
165 exp: bar.user_exp,
166 errorCode: 9999,
167 errorMsg: "已签到"
168 });
169 signBars(bars, tbs, ++index);
170 } else {
171 url_fetch_add.body = `tbs=${tbs}&kw=${bar.forum_name}&ie=utf-8`;
172 $nobyda.post(url_fetch_add, function(error, response, data) {
173 if (error) {
174 process.result.push({
175 bar: bar.forum_name,
176 errorCode: 999,
177 errorMsg: '接口错误'
178 });
179 signBars(bars, tbs, ++index);
180 } else {
181 try {
182 var addResult = JSON.parse(data);
183 if (addResult.no == 0) {
184 process.result.push({
185 bar: bar.forum_name,
186 errorCode: 0,
187 errorMsg: `获得${addResult.data.uinfo.cont_sign_num}积分,第${addResult.data.uinfo.user_sign_rank}个签到`
188 });
189 } else {
190 process.result.push({
191 bar: bar.forum_name,
192 errorCode: addResult.no,
193 errorMsg: addResult.error
194 });
195 }
196 } catch (e) {
197 $nobyda.notify("贴吧签到", "贴吧签到数据处理异常", JSON.stringify(e));
198 $nobyda.done()
199 }
200 signBars(bars, tbs, ++index)
201 }
202 })
203 }
204 }
205}
206
207function checkIsAllProcessed() {
208 //$nobyda.notify("贴吧签到", `最终进度${process.result.length}/${process.total}`, "");

Callers 1

signTieBaFunction · 0.85

Calls 5

checkIsAllProcessedFunction · 0.85
postMethod · 0.45
notifyMethod · 0.45
stringifyMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected