How to use the thingpedia.RSSPollingTrigger 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 / lib / devices / thingpedia / rss_factory.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
"use strict";

const Q = require('q');
const WebSocket = require('ws');
const Tp = require('thingpedia');

class GenericRSSTrigger extends Tp.RSSPollingTrigger {
    static get requiredCapabilities() {
        return ['channel-state'];
    }

    constructor(engine, state, device, params) {
        super(engine, state, device);
        var ast = this.device.constructor.metadata;
        this.auth = this._makeAuth(ast);
        this.useOAuth2 = this.device;
    }

    _lateInit() {
        var id = this.name;
        console.log('Initializing generic RSS channel ' + id);

        var ast = this.device.constructor.metadata;
github stanford-oval / thingpedia-common-devices / com.reddit.frontpage / newpost.js View on Github external
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 Jia-Han Chiam 
//                Giovanni Campagna 
//
// See LICENSE for details

const Tp = require('thingpedia');

module.exports = new Tp.ChannelClass({
    Name: 'NewPostTrigger',
    RequiredCapabilities: ['channel-state'],
    Extends: Tp.RSSPollingTrigger,
    interval: 300000, // 5 min

    _init(engine, state, device, params) {
        this.parent(engine, state, device);

        if (params[2] !== null && params[2] !== undefined) {
            // filter by user
            this.url = 'https://www.reddit.com' + params[2] + '/.rss';
            this.filterString = 'user-' + params[2];
        } else if (params[3] !== null && params[3] !== undefined) {
            // filter by category
            this.url = 'https://www.reddit.com' + params[3] + '/.rss';
            this.filterString = 'category-' + params[3];
        } else {
            // #nofilter
            this.url = 'https://www.reddit.com/.rss';
github stanford-oval / thingpedia-common-devices / org.thingpedia.rss / new_post.js View on Github external
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 Shloka Desai 
//                Giovanni Campagna 
//
// See LICENSE for details

const Tp = require('thingpedia');

module.exports = new Tp.ChannelClass({
    Name: 'GenericRSSPollingTrigger',
    Extends: Tp.RSSPollingTrigger,
    RequiredCapabilities: ['channel-state'],
    interval: 3 * 3600 * 1000, // 3 hours

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

    formatEvent(event) {
        var title = event[0];
        var link = event[1];

        return [{
            type: 'rdl',
            what: 'post',
            displayTitle: title,
github stanford-oval / thingpedia-common-devices / com.phdcomics / new_post.js View on Github external
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 Shloka Desai 
//                Giovanni Campagna 
//
// See LICENSE for details

const Tp = require('thingpedia');

module.exports = new Tp.ChannelClass({
    Name: 'GenericRSSPollingTrigger',
    Extends: Tp.RSSPollingTrigger,
    RequiredCapabilities: ['channel-state'],
    interval: 3 * 3600 * 1000, // 3 hours

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

    formatEvent(event) {
        var title = event[0];
        var link = event[1];
        var img = event[2];

        return [title, {
            type: 'picture',
            url: img