Greasy Fork is available in English.

[bot-manager]botマネージャー ( RPGEN )

ささやきのゆびわ機能を利用したRPGENのbot

// ==UserScript==
// @name         [bot-manager]botマネージャー ( RPGEN )
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  ささやきのゆびわ機能を利用したRPGENのbot
// @author       You
// @match        http://rpgen.us/dq/?map=*
// @require      https://greasyfork.org/scripts/387509-yaju1919-library/code/yaju1919_library.js?version=755144
// @require      https://greasyfork.org/scripts/387372-chatbot/code/Chatbot.js?version=745904
// @grant        GM.setValue
// @grant        GM.getValue
// ==/UserScript==
(function () {
    'use strict';
    const yaju1919 = yaju1919_library;
    //---------------------------------------------------------------------------------
    var copy = yaju1919.win.console.log;
    yaju1919.win.console.log = function(){
        copy.apply(console, arguments);
        var ar = []
        for(let i = 0; i < arguments.length; i++) ar.push(arguments[i]);
        if(isNaN(ar[2]) || isNaN(ar[3])) return;
        ar.push(new Date().getTime());
        g_ar = ar;
    };
    //---------------------------------------------------------------------------------
    const post = str => {
        yaju1919.win.dqSock.sendNChat(str);
    };
    //---------------------------------------------------------------------------------
    var g_ar, g_timeLog = 0;
    const update = ()=>{ // 新しい発言内容の文字列を返す
        if(!g_ar) return;
        if(g_ar[5] === g_timeLog) return;
        g_timeLog = g_ar[5];
        if(g_ar[1] === g_ar[4]) return;
        return { text: g_ar[0] };
    };
    //---------------------------------------------------------------------------------
    const rand = yaju1919.rand;
    const auto = () =>{ // 定期投稿
        return rand([
            '過疎',
            '放置',
            '憂鬱だなぁ…',
            '暇だなー',
            '暇定期',
            '腹減った',
            '眠い',
            '腹痛い',
            'もうこんな時間か',
            '・・・',
            'しーん',
            'とりあえず何か発言してみる',
            '潮が引いたように静寂が訪れた',
            'そして誰もいなくなった・・・',
            'この時間帯は人いないのかな?',
            "近所の犬うるさい",
            "(・ω・)",
            "(-_-).zZ乙",
            "_(:3」∠)_",
            rand([ // 定期発狂
                "\( 'ω')/ウオオオオオアアアーーーッ!",
                "(っ'ヮ'c)ウゥッヒョオアアァアアアァ",
                "( ^o^)<ンンンンンンンンンンンンンンンwww",
            ]),
        ]);
    };
    //---------------------------------------------------------------------------------
    const main = () => {
        appendChatbotManager({
            update: update,
            post: post,
            auto: auto,
            rentou: false
        });
    };
    const observe = () => { // jQueryが読み込まれるまで待つ
        if(yaju1919.win.$) main();
        else setTimeout(observe,2000);;
    };
    observe();
})();