Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chee
committed
Jan 3, 2018
0 parents
commit 987c59b
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
grep -v 'goodideas' "$1" | awk -F'\t' $'$3 ~ /^let\'?s/ {print $3}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
grep -v goodideas "$1" | awk -F'\t' $'$3 ~ /^what if/ {print $3}' | sort | uniq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
grep -v goodideas "$1" | awk -F'\t' $'$3 ~ /^(i|do you ever|do you|but i) wonder/ {print $3}' | sort | uniq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env node | ||
const {promisify} = require('util') | ||
const fs = require('fs') | ||
const irc = require('irc') | ||
|
||
const readFile = promisify(fs.readFile) | ||
|
||
const getLib = lib => readFile(`/usr/chee/lib/${lib}`) | ||
|
||
const whatifs = getLib('whatif') | ||
const lets = getLib('lets') | ||
const wonders = getLib('wonder') | ||
|
||
const getLine = async getBuffer => { | ||
const buffer = await getBuffer | ||
const lines = buffer.toString().split(/\n/) | ||
return lines[Math.floor(Math.random() * lines.length)] | ||
} | ||
|
||
const letLine = () => getLine(lets) | ||
const whatifLine = () => getLine(whatifs) | ||
const wonderLine = () => getLine(wonders) | ||
|
||
const channel = '#chee-fanclub' | ||
const client = new irc.Client('chat.freenode.net', 'goodideas', { | ||
channels: [channel], | ||
userName: 'goodideas', | ||
realName: 'goodideas' | ||
}) | ||
|
||
client.addListener('message', (from, to, message) => { | ||
let line | ||
|
||
switch(message.toLowerCase()) { | ||
case 'let\'s': | ||
case 'lets': | ||
line = await letLine() | ||
break | ||
case 'what if': | ||
case 'whatif': | ||
line = await whatifLine() | ||
break | ||
case 'wonder': | ||
case 'i wonder': | ||
line = await wonderLine() | ||
break | ||
default: | ||
line = null | ||
} | ||
|
||
line && client.say(channel, line) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "lets", | ||
"version": "1.0.0", | ||
"main": "lets.js", | ||
"bin": { | ||
"lets": "lets.js" | ||
}, | ||
"license": "MIT" | ||
} |