Thành viên:KiDavidbot
Giao diện
| Tài khoản thành viên này là một bot bằng Mathematica, do MuDavid (thảo luận) vận hành để lặp đi lặp lại các sửa đổi tự động hoặc bán tự động cực kỳ tẻ nhạt nếu làm thủ công, tuân theo quy định bot. Bot đã được cấp cờ và hiện đang hoạt động – (các) yêu cầu cấp cờ hoặc tác vụ liên quan có thể xem ở đây. Bảo quản viên: Nếu bot này đang bị trục trặc hoặc gây hại, hãy cấm bot. |
| KiDavidbot | |
|---|---|
| (thảo luận · đóng góp) | |
| Người chủ | MuDavid |
| Cờ? | Có |
| Ngôn ngữ lập trình | Mathematica |
| Ngày bắt đầu | Chưa kiểm tra |
| Tổng số sửa đổi | Chưa kiểm tra |
| Tuân thủ quy trình ngắt khẩn cấp? | Có |
Tôi là con rôbô của thành viên MuDavid. Tiền tố mu- là tiền tố tiếng Burǔndi chỉ con người, còn tiền tố ki- chỉ đồ vật nói chung. Mục đích của rôbô là cleanup mục từ tiếng Hà Lan và tạo trang dạng biến, chia của mục từ tiếng Hà Lan.
Con bot này được lập trình bằng Mathematica:
- defs:
myagent = "foo";
sitelang = "vi";
sitename = "wiktionary";
username = "bar";
password = "baz";
site = "https://" <> sitelang <> "." <> sitename <> ".org/";
apiname = site <> "w/api.php";
- đăng nhập, đòi edit token, đăng xuất:
first[response_] := StringPosition[response, "logintoken"][[1, 2]] + 4
last[response_] :=
FirstCase[StringPosition[response, "\""],
x_ /; x[[1]] > first[response]][[1]] - 2
extractlogintoken[response_] :=
StringTake[response, {first[response], last[response]}]
extractedittoken[response_] :=
Module[{first, last},
first = StringPosition[response, "csrftoken"][[1, 2]] + 4;
last = FirstCase[StringPosition[response, "\""],
x_ /; x[[1]] > first][[1]] - 2;
StringTake[response, {first, last}]]
return = URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "query", "meta" -> "tokens",
"type" -> "login", "format" -> "json"}]
logintoken = extractlogintoken[return];
URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "clientlogin",
"loginreturnurl" -> "http://example.com/",
"logintoken" -> logintoken, "username" -> username,
"password" -> password, "rememberMe" -> "1", "format" -> "json"}]
return = URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "query", "meta" -> "tokens",
"format" -> "json"}]
token = extractedittoken[return];
logout :=
URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "logout", "format" -> "json"}]
- tải mã wiki của một trang:
loadwiki[word_] :=
URLFetch[site <> "w/index.php?action=raw&title=" <> word,
"UserAgent" -> myagent]
- sửa trang:
edit[page_, newtext_, summary_] :=
URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "edit", "title" -> page,
"text" -> newtext, "summary" -> summary, "assert" -> "user",
"token" -> token, "format" -> "json"}]
editnocreate[page_, newtext_, summary_] :=
URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "edit", "title" -> page,
"text" -> newtext, "summary" -> summary, "nocreate" -> "1",
"assert" -> "user", "token" -> token, "format" -> "json"}]
editcreate[page_, newtext_, summary_] :=
URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "edit", "title" -> page,
"text" -> newtext, "summary" -> summary, "createonly" -> "1",
"assert" -> "user", "token" -> token, "format" -> "json"}]
editbot[page_, newtext_, summary_] :=
URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "edit", "title" -> page,
"text" -> newtext, "summary" -> summary, "bot" -> "1",
"assert" -> "bot", "token" -> token, "format" -> "json"}]
editnocreatebot[page_, newtext_, summary_] :=
URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "edit", "title" -> page,
"text" -> newtext, "summary" -> summary, "nocreate" -> "1",
"bot" -> "1", "assert" -> "bot", "token" -> token,
"format" -> "json"}]
editcreatebot[page_, newtext_, summary_] :=
URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "edit", "title" -> page,
"text" -> newtext, "summary" -> summary, "createonly" -> "1",
"bot" -> "1", "assert" -> "bot", "token" -> token,
"format" -> "json"}]
hasmessage := (!
StringFreeQ[
URLFetch[apiname, "UserAgent" -> myagent, "Method" -> "POST",
"Parameters" -> {"action" -> "query", "meta" -> "userinfo",
"uiprop" -> "hasmsg", "format" -> "json"}], "messages"])