Skip to content

Instantly share code, notes, and snippets.

kyp kypkyp

View GitHub Profile
View bot6.js
controller.hears(['sudo tweet '], 'direct_mention,mention,ambient', function(bot, message) {
if(message.channel === "C2Z3UJWAW"){
var output = message.text.slice(10,message.text.length);
var name;
if(output.indexOf('@') === -1 && output.indexOf('') === -1 && output.indexOf('[by') === -1 && output.indexOf('twitter.com') === -1 && output.indexOf('t.co') === -1){
// DEBUG
if(Math.random() < 0.25){
View bot5.js
controller.hears(['sudo tweet '], 'direct_mention,mention,ambient', function(bot, message) {
if(message.channel === "C2Z3UJWAW"){
var output = message.text.slice(10,message.text.length);
var name;
if(output.indexOf('@') === -1 && output.indexOf('[by') === -1 && output.indexOf('twitter.com') === -1 && output.indexOf('t.co') === -1){
/* 生のIDから名前を特定する */
// DEBUG
View bot4.js
controller.hears(['tweet '], 'direct_mention,mention,ambient', function(bot, message) {
var output = message.text.slice(10,message.text.length);
if(message.channel === "C2Z3UJWAW"){
twitterClient.post('statuses/update', {status: "[from #kyp_memo]" + output}, function(error, tweet, response)
if(!error){
bot.say({
channel:"C2Z3UJWAW",
text:"https://twitter.com/_kypu/status/" + tweet.id_str, // tweet.id ではない!(utgwさんに感謝)
});
@kypkyp
kypkyp / twitter.js
Last active Dec 24, 2016
ついったー
View twitter.js
var Twitter = require('twitter');
var twitterClient = new Twitter({
consumer_key: ***,
consumer_secret: ***,
access_token_key: ***,
access_token_secret: ***
});
twitterClient.post('statuses/update', {status: "node.jsからのつぶやきテスト"}, function(error, tweet, response){
@kypkyp
kypkyp / bot3.js
Created Dec 24, 2016
へんすう
View bot3.js
controller.hears(['@[0-9a-z_]+'], 'direct_message,direct_mention,mention,ambient', function(bot, message) {
if(message.channel === "C2Z3UJWAW"){
var mentionedID = message.text.match(/@[0-9a-z_]+/);
var ansstr = mentionedID + " そうだよ";
bot.say({
channel:"C2Z3UJWAW",
text:ansstr,
username:"BOT",
icon_url:"https://i.gyazo.com/f3e1776ca8cbde6644df9fe04bcbf05a.jpg"
});
@kypkyp
kypkyp / bot2.js
Created Dec 24, 2016
そびえとしき とうちほう
View bot2.js
/* ソビエト式倒置法 */
controller.hears(['(.*)を(.*)(う|く|ぐ|す|ず|つ|づ|ぬ|ふ|ぶ|む|る|ゆ)'], 'direct_message,direct_mention,mention,ambient', function(bot, message) {
if(message.channel === "C2Z3UJWAW"){
var splittext = message.text.match(/(\S+)を(\S+)/);
var outstr;
if(splittext[1].indexOf("") != -1){
var subtext = splittext[1].split("");
outstr = "ソビエトロシアでは、" + subtext[1] + "" + subtext[0] + "" + splittext[2] + "!";
}else if(splittext[1].indexOf("") != -1){
@kypkyp
kypkyp / bot1.js
Last active Dec 24, 2016
とても しんぷるな やつ
View bot1.js
/* じっさいには トークンとか いろいろな初期設定がひつよう (ただし デフォルトのサンプルコードに のっとればOK)*/
controller.hears(['hi'], 'direct_message,direct_mention,mention,ambient', function(bot, message) {
if(message.channel === "********"){
bot.say({
channel:"C2Z3UJWAW",
text:"hello!",
username:"kyp_bot"
});
}
You can’t perform that action at this time.