Skip to content

Commit

Permalink
Whip up a quick thing to list followers and subs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Dec 9, 2024
1 parent 6fefce0 commit 8f86890
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions utils.pike
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,38 @@ __async__ void script() {
foreach (G->G->args[Arg.REST], string arg) await(mustard->run_test(arg, G->G->args->q));
}

__async__ void sublist() {
int uid = (int)await(get_user_id("profoundrice"));
array subs = await(get_helix_paginated("https://api.twitch.tv/helix/subscriptions",
(["broadcaster_id": (string)uid]),
(["Authorization": uid])));
array follows = await(get_helix_paginated("https://api.twitch.tv/helix/channels/followers",
(["broadcaster_id": (string)uid]),
(["Authorization": uid])));
werror("Total: %d subs, %d followers\n", sizeof(subs), sizeof(follows));
multiset following = (multiset)follows->user_id;
array foll = ({ }), nonfoll = ({ });
foreach (subs, mapping user) {
if (following[user->user_id]) foll += ({user->user_name});
else nonfoll += ({user->user_name});
}
werror("Search complete. %d following, %d not following.\n", sizeof(foll), sizeof(nonfoll));
Stdio.write_file("following.txt", string_to_utf8(foll * "\n"));
Stdio.write_file("notfollowing.txt", string_to_utf8(nonfoll * "\n"));
following = (multiset)follows->user_login;
array lines = Stdio.read_file("../Downloads/subscriber-list.csv") / "\n";
int nfoll, nnotfoll;
foreach (lines; int i; string l) {
if (!i) {lines[i] += ",Following"; continue;}
if (l == "") continue;
sscanf(l, "%[^,],", string user);
if (following[user]) {nfoll++; lines[i] += ",true";}
else {nnotfoll++; lines[i] += ",false";}
}
Stdio.write_file("subscriber-list-annotated.csv", lines * "\n");
write("Foll %d, not foll %d\n", nfoll, nnotfoll);
}

@"This help information":
void help() {
write("\nUSAGE: pike stillebot --exec=ACTION\nwhere ACTION is one of the following:\n");
Expand Down

0 comments on commit 8f86890

Please sign in to comment.