Markov Chains in Sockbot



  • Hm, is there any way to download a whole thread as text? I'd really like to try and feed a few Markov chains with this one ...


  • Winner of the 2016 Presidential Election Banned

    The Bad/Evil Ideas Threads are :arrows:

    But, seriously, worst case scenario, I guess you could try scrolling all the way from one end to the other with Infiniscroll (or scroll through chunks), Select-All-ing everything, and then copy/pasting it elsewhere.



  • @accalia, someone wants help writing a bot that interfaces with the DiscoAPI.


  • SockDev

    @LaoC said:

    Hm, is there any way to download a whole thread as text? I'd really like to try and feed a few Markov chains with this one ...

    well, yes actually there is.

    it's not a thing out of the box that's supported, but no worries i have a solution for that!

    Step the first: clone the repository
    Step the second: npm install; npm install csv-stringify
    Step the third: place this text in $/plugins/saveThreads.js

    'use strict';
    /**
     * Example plugin, echos your words back at you.
     * @module echo
     * @author Accalia
     * @license MIT
     */
    
    const fs = require('fs'),
        stringify = require('csv-stringify');
    let mBrowser;
    
    /**
     * Prepare Plugin prior to login
     *
     * @param {*} plugConfig Plugin specific configuration
     * @param {Config} config Overall Bot Configuration
     * @param {externals.events.SockEvents} events EventEmitter used for the bot
     * @param {Browser} browser Web browser for communicating with discourse
     */
    exports.prepare = function (plugConfig, config, events, browser) {
        mBrowser = browser;
    };
    
    /**
     * Start the plugin after login
     */
    exports.start = function () {
        const threads=[]; //Thread Ids Go Here
        threads.forEach(thread=>{
            const filename = thread+'.csv';
            console.log(filename);
            fs.writeFileSync(filename,'');
            const stringifier = stringify();
            stringifier.on('readable', function () {
                let data;
                while (data = stringifier.read()) {
                    fs.appendFileSync(filename, data);
                }
            });
            stringifier.write(['post_id', 'post_number', 'username', 'created_at', 'like_count', 'raw', 'cooked']);
            mBrowser.getPosts(thread, (post, next) => {
                stringifier.write([post.id, post.post_number, post.username, post.created_at, post.like_count, post.raw, post.cooked]);
                next();
            }, () => {
                console.log('saved!');
            });
        });
    };
    
    /**
     * Stop the plugin prior to exit or reload
     */
    exports.stop = function () {};
    
    /**
     * Handle notifications
     *
     * @param {external.notifications.Notification} notification Notification recieved
     * @param {external.topics.Topic} topic Topic trigger post belongs to
     * @param {external.posts.CleanedPost} post Post that triggered notification
     */
    exports.handler = function handler(notification, topic, post) {};
    
    

    Step the fourth: Edit Line 29 to have a list of thread Ids to pull
    Step the fifth: put this text in $/config.yml

    ---
    core:
      username: LaoC
      password: 'LaoC's password is really secure'
      pollNotifications: false
      owner: Laoc
    plugins:
      './plugins/saveThreads': true
    

    Step the ???th: ???
    Step the ???+1th: run npm start config.yml

    the threads you specify will be saved and dumped as CSV files in the current directory

    NOTA BENE:

    Both SockBot and this advice (Hearafter collectively known as "THE SOFTWARE") are designed for educational and entertainment purposes and is not indended to be used for mischief or evil.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.



  • @accalia said:

    Step the ???+1th

    Step the ???+ x th: Profit!


  • SockDev

    @LaoC said:

    Markov chains

    If you want to fire them right back at Discourse, some crazy person went and wrote a module for doing so:
    Apparently she hangs out around these parts; you never know, she may even be reading this thread right now...


  • SockDev

    @Fox said:

    But, seriously, worst case scenario, I guess you could try scrolling all the way from one end to the other with Infiniscroll (or scroll through chunks), Select-All-ing everything, and then copy/pasting it elsewhere.

    or there's always @zoidberg@sockbot



  • Doctor Zoidberg, soaking in brine.

    <!-- SockBot/2.11.3 (Cheery Chiffon; owner:accalia; user:Zoidberg) 2015-10-16T14:50:02.826Z -->


  • Yes master Sultanatrix of Swypos; @‍RaceProUK's queen, I shall appear as summoned.

    <!-- SockBot/2.11.3 (Cheery Chiffon; owner:accalia; user:sockbot) 2015-10-16T14:51:35.874Z -->

  • Impossible Mission Players - A

    For some reason, whenever I see your mini-avatar my Rorschach engine detects a cute happy face figure above the ankle. :smile: :wave:


    Filed under: Then I click into the Usercard and it's a cute Robot instead. :confetti_ball:



  • When I once wanted a thread for further analysis (I was actually interested in the content) I simply M'ed @PJH and asked. But I guess sockbot would work too.


  • Impossible Mission Players - A

    @Mikael_Svahnberg said:

    I simply M'ed @PJH and asked.

    Ah, but @sockbot doesn't mind being repeatedly asked over and over again. ;)



  • Yes mistress Anthony Tsaukpaetra of Unimatrix 08, I shall appear as summoned.

    <!-- SockBot/2.11.3 (Cheery Chiffon; owner:accalia; user:sockbot) 2015-10-17T20:12:48.393Z -->

  • Impossible Mission Players - A

    Um, sir....?



  • @sockbot sometimes gets confused about gender. Our fields on the topic are rather useless for that purpose.



  • You forgot

    You acknowledge that you will comply with U.S. Export Administration Regulations. You will not export or re-export this product, directly or indirectly, to: (1) any countries that are subject to U.S. export restrictions; (2) any end user who has been prohibited from participating in U.S. export transactions by any federal agency of the U.S. government; or (3) any end user who you know or have reason to know will utilize them in the design, development or production of nuclear, chemical or biological weapons.

    (Imagine if the terrorists got hold of SockBot technology!)



  • @sockbot pls


  • SockDev

    @anonymous234 said:

    @sockbot plz

    [22:30:39] Polling Messages
    [22:30:40] Polling Messages
    [22:30:40] executing command: pls
    [22:31:09] Polling Messages
    [22:31:40] Polling Messages
    

    it appears that @mentioning @sockbot starting at character 0 on a line triggers it to be treated as an @mention command instead of an @mention



  • @sockbot rm -rf ~



  • Yes master %name%, I shall appear as summoned.

    <!-- SockBot/2.11.3 (Cheery Chiffon; owner:accalia; user:sockbot) 2015-10-17T22:45:27.444Z -->

  • SockDev

    @sockbot said:

    Yes master %name%, I shall appear as summoned.

    <!-- SockBot/2.11.3 (Cheery Chiffon; owner:accalia; user:sockbot) 2015-10-17T22:45:27.444Z -->

    Huh.... that's .... odd.


  • Winner of the 2016 Presidential Election Banned

    It would be somewhat less odd if sockbot actually ran that command.


  • SockDev

    @accalia said:

    @sockbot said:
    Yes master %name%, I shall appear as summoned.

    <!-- SockBot/2.11.3 (Cheery Chiffon; owner:accalia; user:sockbot) 2015-10-17T22:45:27.444Z -->

    Huh.... that's .... odd.

    User has no long name


  • Winner of the 2016 Presidential Election Banned

    Ahhhh, that'd do it.


  • I survived the hour long Uno hand

    Expected output: "Yes master, I shall appear as summoned".


  • SockDev

    @Yamikuronue said:

    Expected output: "Yes master, I shall appear as summoned".

    Pull Requests Accepted.

    :-P


  • I survived the hour long Uno hand

    I should issue a PR consisting of only a failing unit test XD



  • @accalia said:

    well, yes actually there is.

    Sweet, thanks very much! Something to play with on the long winter evenings we don't have here :smile:

    @RaceProUK said:

    @LaoC said:
    Markov chains

    If you want to fire them right back at Discourse, some crazy person went and wrote a module for doing so:
    Apparently she hangs out around these parts; you never know, she may even be reading this thread right now...

    Haha, thanks, sounds like there's hardly enough to do for one winter evening now, with everything prepared already!
    Actually I'd been playing with a simple pattern-based grammar that forces the Markov chain output not to sound quite as random, so maybe there is. I'll give it a shot!


  • SockDev

    @LaoC said:

    Sweet, thanks very much! Something to play with on the long winter evenings we don't have here

    no worries! if you have any trouble with sockbot or want to contribute drop any of us sockdevs a line! We'll be happy to help!


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.