How to use the thingpedia.SimpleAction function in thingpedia

To help you get started, we’ve selected a few thingpedia examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stanford-oval / thingengine-core / engine / device-classes / thingengine / logger.js View on Github external
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of ThingEngine
//
// Copyright 2015 Giovanni Campagna 
//
// See COPYING for details

const Tp = require('thingpedia');

module.exports = new Tp.ChannelClass({
    Name: 'LoggingChannel',
    Extends: Tp.SimpleAction,

    _doInvoke: function(message) {
        console.log("LoggingChannel: ", message);
    }
});
github stanford-oval / thingpedia-common-devices / com.facebook / post.js View on Github external
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of ThingPedia
//
// Copyright 2016 Elena Kane Frey 
//                Meredith Grace Marks ,
//
// See LICENSE for details

const Tp = require('thingpedia');

module.exports = new Tp.ChannelClass({
    Name: "FacebookPostsSinkAction",
    Extends: Tp.SimpleAction,

    _doInvoke: function(text) {

    }
});
github stanford-oval / thingengine-core / lib / device-classes / sabrina / say.js View on Github external
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of ThingEngine
//
// Copyright 2015 Giovanni Campagna 
//
// See COPYING for details

const Tp = require('thingpedia');

module.exports = new Tp.ChannelClass({
    Name: 'SabrinaSayChannel',
    Extends: Tp.SimpleAction,

    _init: function(engine, device) {
        this.parent();
        this.engine = engine;
    },

    _doInvoke: function(message) {
        this.engine.assistant.sendReply(message);
    },
});
github stanford-oval / thingpedia-common-devices / com.live.onedrive / create_file.js View on Github external
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 {jasonf2, kkiningh}@stanford.edu
//
// See LICENSE for details
"use strict";

const Tp = require('thingpedia');

module.exports = new Tp.ChannelClass({
    Name: 'OneDriveCreateFileAction',
    Extends: Tp.SimpleAction,

    _init: function(engine, device) {
        this.parent(engine, device);
        this._baseurl = 'https://api.onedrive.com/v1.0/drive/root/children/';
    },

    _doInvoke: function(fileName, body) {
        var url = this._baseurl + fileName + "/content";
        return Tp.Helpers.Http.request(url, 'PUT', body, {
            dataContentType: "text/plain",
            useOAuth2: this.device
        });
    }
});
github stanford-oval / thingpedia-common-devices / com.live.onedrive / upload_picture.js View on Github external
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 {jasonf2, kkiningh}@stanford.edu
//                Giovanni Campagna 
//
// See LICENSE for details
"use strict";

const Tp = require('thingpedia');
const path = require('path');

module.exports = new Tp.ChannelClass({
    Name: 'OneDriveCreateFileAction',
    Extends: Tp.SimpleAction,

    _init: function(engine, device) {
        this.parent(engine, device);
        this._baseurl = 'https://api.onedrive.com/v1.0/drive/items/';
    },

    _doInvoke: function(fileName, url) {
        var dirname = path.dirname(fileName);
        if (!dirname || dirname === '.')
            dirname = 'root';
        var basename = path.basename(fileName);
        url = this._baseurl + dirname + "/children";
        return Tp.Helpers.Http.request(url, 'POST', JSON.stringify({
            '@content.sourceUrl': url,
            name: basename,
            file: {}
github stanford-oval / thingpedia-common-devices / com.live.onedrive / delete_file.js View on Github external
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 {jasonf2, kkiningh}@stanford.edu
//
// See LICENSE for details
"use strict";

const Tp = require('thingpedia');

module.exports = new Tp.ChannelClass({
    Name: 'OneDriveCreateFileAction',
    Extends: Tp.SimpleAction,

    _init: function(engine, device) {
        this.parent(engine, device);
        this._baseurl = 'https://api.onedrive.com/v1.0/drive/root/children/';
    },

    _doInvoke: function(fileName) {
        var url = this._baseurl + fileName;
        return Tp.Helpers.Http.request(url, 'DELETE', '', {
            dataContentType: "text/plain",
            useOAuth2: this.device
        });
    }
});
github stanford-oval / thingpedia-common-devices / com.live.onedrive / rename_file.js View on Github external
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 {jasonf2, kkiningh}@stanford.edu
//
// See LICENSE for details
"use strict";

const Tp = require('thingpedia');

module.exports = new Tp.ChannelClass({
    Name: 'OneDriveCreateFileAction',
    Extends: Tp.SimpleAction,

    _init: function(engine, device) {
        this.parent(engine, device);
        this._baseurl = 'https://api.onedrive.com/v1.0/drive/root/children/';
    },

    _doInvoke: function(fileName, newFilename) {
        var body = JSON.stringify({ name: newFilename });
        var url = this._baseurl + fileName;
        return Tp.Helpers.Http.request(url, 'PATCH', body, {
            dataContentType: "text/plain",
            useOAuth2: this.device
        });
    }
});