Skip to content

Instantly share code, notes, and snippets.

@burtonsamograd
Created July 4, 2018 18:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save burtonsamograd/4fc1bbfeb418ada3776f03cb694fb2f8 to your computer and use it in GitHub Desktop.
Save burtonsamograd/4fc1bbfeb418ada3776f03cb694fb2f8 to your computer and use it in GitHub Desktop.
Chat User Logger Thing (CULT) - a Chaturbate Chat user logger and note taker runnable in node.js
////////////////////////////////////////////////////////////////////////////////
// Chatubate API Emultaion - Make work on node stuff.
////////////////////////////////////////////////////////////////////////////////
var stdin = process.openStdin();
function randomBoolean () {
if(Math.random() < .5) {
return true;
} else {
return false;
}
}
function onMessage (callback) {
stdin.addListener("data", function (d) {
let msg = {
gender: 'it', // invalid gender on CB
user: 'CULTRobot',
m: d.toString().trim(),
is_mod: randomBoolean(),
has_tokens: randomBoolean(),
in_fanclub: randomBoolean(),
tipped_recently: randomBoolean(),
tipped_alot_recently: randomBoolean(),
tipped_tons_recently: randomBoolean()
};
callback(msg);
});
}
let cb = {
log: console.log,
chatNotice: console.log,
onMessage: onMessage,
room_slug: 'CULTRobot'
};
////////////////////////////////////////////////////////////////////////////////
// Chat User Logger Thing (CULT) Code - start by skarlet31
////////////////////////////////////////////////////////////////////////////////
/*
/debug
help
CULTRobot is not female.
CULTRobot said 'help'.
CULTRobot has tokens.
CULTRobot has tipped a lot recently.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'help'
This is the help system for CULT.
Topics:
help: Show this help.
note: Add a note.
notes: Show your notes.
topics: Show topics.
denote: Add a note about a topic.
denotes: Show notes about a topic.
file: File (hide) a specific note.
dump: Dump state for later loading.
load: Load state from previous dumping.
meta: Meta word substitution.
aleph: WIP: Aleph word expansion.
Adding note for 'CULTRobot': 'help'.
note sweetsexangel would be nice to meet IRL someday
CULTRobot is not female.
CULTRobot said 'note sweetsexangel would be nice to meet IRL someday'.
CULTRobot has tokens.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'note sweetsexangel would be nice to meet IRL someday'
Adding note for 'CULTRobot': 'sweetsexangel,would,be,nice,to,meet,in real life,someday'.
Adding note for 'CULTRobot': 'note,sweetsexangel,would,be,nice,to,meet,IRL,someday'.
notes
CULTRobot is not female.
CULTRobot said 'notes'.
CULTRobot is a moderator.
CULTRobot has tokens.
CULTRobot has tipped recently.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'notes'
0: Type 'denotes skarlet31' to see the notes on that top and to continue.
1: help
2: sweetsexangel would be nice to meet in real life someday
3: note sweetsexangel would be nice to meet IRL someday
Adding note for 'CULTRobot': 'notes'.
file 3
CULTRobot is not female.
CULTRobot said 'file 3'.
CULTRobot is a moderator.
CULTRobot is in my fan club.
CULTRobot has tipped recently.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'file 3'
Adding note for 'CULTRobot': 'file,3'.
file 2
CULTRobot is not female.
CULTRobot said 'file 2'.
CULTRobot has tokens.
CULTRobot is in my fan club.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'file 2'
Adding note for 'CULTRobot': 'file,2'.
notes
CULTRobot is not female.
CULTRobot said 'notes'.
CULTRobot is a moderator.
CULTRobot is in my fan club.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'notes'
0: Type 'denotes skarlet31' to see the notes on that top and to continue.
1: help
4: notes
5: file 3
6: file 2
Adding note for 'CULTRobot': 'notes'.
denotes sweetsexangel
CULTRobot is not female.
CULTRobot said 'denotes sweetsexangel'.
CULTRobot has tokens.
CULTRobot has tipped recently.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'denotes sweetsexangel'
No notes about topic: sweetsexangel
Adding note for 'CULTRobot': 'denotes,sweetsexangel'.
denote sweetsexangel testing denotes
CULTRobot is not female.
CULTRobot said 'denote sweetsexangel testing denotes'.
CULTRobot is a moderator.
CULTRobot has tokens.
CULTRobot is in my fan club.
CULTRobot has tipped recently.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'denote sweetsexangel testing denotes'
Adding note for 'sweetsexangel': 'testing,denotes'.
Adding note for 'CULTRobot': 'denote,sweetsexangel,testing,denotes'.
denotes sweetsexangel
CULTRobot is not female.
CULTRobot said 'denotes sweetsexangel'.
CULTRobot is in my fan club.
CULTRobot has tipped a lot recently.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'denotes sweetsexangel'
0: testing denotes
Adding note for 'CULTRobot': 'denotes,sweetsexangel'.
file sweetsexangel 0
CULTRobot is not female.
CULTRobot said 'file sweetsexangel 0'.
CULTRobot has tipped recently.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'file sweetsexangel 0'
Adding note for 'CULTRobot': 'file,sweetsexangel,0'.
denotes sweetsexangel
CULTRobot is not female.
CULTRobot said 'denotes sweetsexangel'.
CULTRobot has tokens.
CULTRobot is in my fan club.
CULTRobot has tipped a lot recently.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'denotes sweetsexangel'
Adding note for 'CULTRobot': 'denotes,sweetsexangel'.
dump
CULTRobot is not female.
CULTRobot said 'dump'.
CULTRobot is a moderator.
CULTRobot has tokens.
CULTRobot has tipped a lot recently.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'dump'
-- Begin Core ++
load {"notes":{"skarlet31":[["skarlet31","is","the","original","author","of","this","script."],["http://chaturbate.com/skarlet31"]],"CULTRobot":[["Type","'denotes","skarlet31'","to","see","the","notes","on","that","top","and","to","continue."],["help"],null,null,["notes"],["file","3"],["file","2"],["notes"],["denotes","sweetsexangel"],["denote","sweetsexangel","testing","denotes"],["denotes","sweetsexangel"],["file","sweetsexangel","0"],["denotes","sweetsexangel"]],"sweetsexangel":[null]},"filed_notes":[["CULTRobot",["note","sweetsexangel","would","be","nice","to","meet","IRL","someday"]],["CULTRobot",["sweetsexangel","would","be","nice","to","meet","in real life","someday"]],["sweetsexangel",["testing","denotes"]]],"metas":{"IRL":["in real life"],"CULT":["Chat User Logger Thing (CULT)"]}}
-- End Core ++
Adding note for 'CULTRobot': 'dump'.
notes
CULTRobot is not female.
CULTRobot said 'notes'.
CULTRobot is in my fan club.
CULTRobot has tipped recently.
CULTRobot has tipped a lot recently.
User is the room owner (CULTRobot).
THE USERS CAN SEE YOUR COMMANDS.
Command (root) mode enabled.
Your command is: 'notes'
0: Type 'denotes skarlet31' to see the notes on that top and to continue.
1: help
4: notes
5: file 3
6: file 2
7: notes
8: denotes sweetsexangel
9: denote sweetsexangel testing denotes
10: denotes sweetsexangel
11: file sweetsexangel 0
12: denotes sweetsexangel
13: dump
Adding note for 'CULTRobot': 'notes'.
*/
let me = cb.room_slug;
let version = 0;
let log = cb.log
let message = cb.chatNotice
message("Chat User Logger Thing (CULT) Enabled.");
message("Type /debug to see it's output.");
message("Type notes to see your notes.");
message("Type help for online help.");
message("");
////////////////////////////////////////////////////////////////////////////////
// command interpreter
////////////////////////////////////////////////////////////////////////////////
function print_help_help () {
log("help - the help system.");
log("");
log("The help system is meant to guide the design of the root system.");
}
let notes = { 'skarlet31': [
'skarlet31 is the original author of this script.'.split(' '),
'http://chaturbate.com/skarlet31'.split(' ')
] };
notes[me] = [ "Type 'denotes skarlet31' to see the notes on that top and to continue.".split(' ') ];
let metas = { 'IRL': [ "in real life" ],
'CULT': [ "Chat User Logger Thing (CULT)" ]};
let filed_notes = []; // notes that have been filed
function add_denote(topic, note) {
log("Adding note for '" + topic + "': '" + note + "'.");
if(notes[topic]) {
notes[topic].push(note);
} else {
notes[topic] = [ note ];
}
}
function cmd_dump () {
log("-- Begin Core ++");
log("load " + JSON.stringify({ notes: notes,
filed_notes: filed_notes,
metas: metas }));
log("-- End Core ++");
}
function cmd_load (args) {
let data = JSON.parse(args[0]);
notes = data.notes;
filed_notes = data.filed_notes;
}
function cmd_load () {
log("// WRITEME");
}
function file_denote(topic, note_index) {
let note = notes[topic][note_index];
filed_notes.push([ topic, note ]);
notes[topic][note_index] = undefined;
}
function print_denotes(topic) {
let theNotes = notes[topic];
if(theNotes) {
for(let i = 0; i < theNotes.length; i++) {
if(theNotes[i]) {
log(i + ": " + theNotes[i].join(' '));
}
}
} else {
log("No notes about topic: " + topic);
}
log("");
}
function print_topics() {
log("The topics are:");
log("");
for(topic in notes) {
log(topic);
}
log("");
}
function cmd_note (args) {
add_denote(me, args);
}
function cmd_notes (args) {
print_denotes(me);
}
function cmd_file (args) {
let topic = me;
let note_index = parseInt(args[0]);
if (isNaN(note_index)) {
topic = args[0];
note_index = parseInt(args[1]);
}
file_denote(topic, note_index);
}
function cmd_denote (args) {
let topic = args[0];
let note = args.slice(1);
add_denote(topic, note);
}
function cmd_denotes (args) {
let topic = args[0];
print_denotes(topic);
}
function cmd_topics (args) {
print_topics();
}
function cmd_help (args) {
log("This is the help system for CULT.");
log("");
if(args.length === 0) {
log("Topics: ");
log("");
for(command in commands) {
log(" " + command + ": " + commands[command].h[0]);
}
log("");
} else {
log("");
let topic = args[0];
if(commands[topic]) {
log(" " + topic + ":");
log("");
let helpText = commands[topic].h;
for(let i = 0; i < helpText.length; i++) {
log(" " + helpText[i]);
}
} else {
log("Unknown help topic: " + args[1]);
}
log("");
}
}
function cmd_meta (args) {
let word = args[0];
let expansion = args.slice(1);
metas[word] = expansion;
}
function meta_substitute (word) {
if(metas[word]) {
return metas[word].join(' ');
} else {
return word;
}
}
function cmd_aleph (args) {
}
let commands = {
'help': { f: cmd_help, h: [ "Show this help." ]},
'note': { f: cmd_note, h: ["Add a note.", "Syntax: note <note ...>" ] },
'notes': { f: cmd_notes, h: [ "Show your notes." ] },
'topics': { f: cmd_topics, h: [ "Show topics." ] },
'denote': { f: cmd_denote, h: [ "Add a note about a topic.",
"Syntax: denote <topic> <note ...>",
"Example: denote skarlet31 wrote this script" ] },
'denotes': { f: cmd_denotes, h: [ "Show notes about a topic.",
"Syntax: denotes <topic>",
"Example: denotes skarlet31" ] },
'file': { f: cmd_file, h: [ "File (hide) a specific note.",
"Syntax: file_note <note index>",
"Syntax: file_note <topic> <note index>"] },
'dump': { f: cmd_dump, h: [ "Dump state for later loading." ] },
'load': { f: cmd_load, h: [ "Load state from previous dumping." ] },
'meta': { f: cmd_meta, h: [ "Meta word substitution.",
"Substitutes words with their 'meta' expansion",
"Syntax: meta <word> <expansion...>",
"Example: meta this THAT # changes this into THAT" ] },
'aleph': { f: cmd_aleph, h: [ "WIP: Aleph word expansion.",
"Expands specified words with their 'aleph' (argumentative) expansion",
"Syntax: aleph <word> <args..> as <expansion containing args...>",
"Example: Coming Soon..." ] }
}
function execute_command(words) {
let words2 = [];
for(let i = 0; i < words.length; i++) {
words2.push(meta_substitute(words[i]));
}
if(commands[words2[0]]) {
commands[words2[0]].f(words2.slice(1));
}
}
////////////////////////////////////////////////////////////////////////////////
// message handling system
////////////////////////////////////////////////////////////////////////////////
let messages = {}; // saved messages table
function denote_what_they_said (user, msg) {
var x = user + " " + msg;
cmd_denote(x.split(' '));
}
cb.onMessage(function (msg) {
// This tells you more about who is talking in your room.
// Enable by typing /debug in your chat window.
let m = msg['m'];
let user = msg['user'];
let gender = msg['gender'];
let is_mod = msg['is_mod'];
let in_fanclub = msg['in_fanclub'];
let has_tokens = msg['has_tokens'];
let tipped_recently = msg['tipped_recently'];
let tipped_alot_recently = msg['tipped_alot_recently'];
let tipped_tons_recently = msg['tippped_tons_recently'];
if(gender == 'f') {
log(user + " is female.");
} else {
log(user + " is not female.");
}
if(m) { log(user + " said '" + m + "'."); }
if(is_mod) { log(user + " is a moderator."); }
if(has_tokens) { log(user + " has tokens."); }
if(in_fanclub) { log(user + " is in my fan club."); }
if(tipped_recently) { log(user + " has tipped recently."); }
if(tipped_alot_recently) { log(user + " has tipped a lot recently."); }
if(tipped_tons_recently) { log(user + " has tipped tons recently."); }
if(user === me) { // root mode enabled
log("User is the room owner (" + me + ").");
log("");
log("THE USERS CAN SEE YOUR COMMANDS.");
log("");
log("Command (root) mode enabled.");
log("");
let words = msg['m'].split(" ");
log("Your command is: '" + words.join(' ') + "'");
log("");
execute_command(words);
}
denote_what_they_said(user, m);
return msg;
});
--
Burton Samograd - 2018
License: AGPL
@burtonsamograd
Copy link
Author

An experimental app using the Chaturbate V1 api. For logging, organizing and exploring chat messages sent in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment