Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Tp = require('thingpedia');
const GetWeather = require('./weather_names');
const URL = 'https://api.met.no/weatherapi/locationforecast/1.9/?lat=%f;lon=%f';
const POLL_INTERVAL = 10 * 60 * 1000; // 10min
// for compatibility with older ThingTalk
const DEFAULT_FORMATTER = {
locationToString(o) {
return '[Latitude: ' + Number(o.y).toFixed(3) + ' deg, Longitude: ' + Number(o.x).toFixed(3) + ' deg]';
}
};
module.exports = new Tp.ChannelClass({
Name: 'WeatherAPICurrentWeather',
Extends: Tp.HttpPollingTrigger,
_init: function(engine, device, params) {
this.parent();
this._params = params;
this._location = params[0];
this.filterString = this._params.join('-');
if (!this._location)
throw new TypeError('Missing required parameter');
this.interval = POLL_INTERVAL;
this.url = URL.format(this._location.y, this._location.x);
},
formatEvent(event, hint, formatter) {
var location = event[0];
var temperature = event[1];
// Copyright 2015 Giovanni Campagna
// 2016 Riad S. Wahby - modified to select based on tournament rather than team
//
// See LICENSE for details
const Tp = require('thingpedia');
const deepEqual = require('deep-equal');
const API_KEY = '9kx5ta95brfyftwzx83vmfsz';
const SCHEDULE_URL = 'https://api.sportradar.us/soccer-t2/eu/matches/schedule.xml?api_key=' + API_KEY;
const BOXSCORE_URL = 'https://api.sportradar.us/soccer-t2/eu/matches/%s/boxscore.xml?api_key=' + API_KEY;
const POLL_INTERVAL = 24 * 3600 * 1000; // 1day
module.exports = new Tp.ChannelClass({
Name: 'SportRadarEUTourneySoccerChannel',
Extends: Tp.HttpPollingTrigger,
RequiredCapabilities: ['channel-state'],
interval: POLL_INTERVAL,
_init: function(engine, state, device, params) {
this.parent(engine, state, device);
this.state = state;
this._params = params.slice(0, 1);
this._observedTourney = params[0];
if (!this._observedTourney)
throw new TypeError("Missing required parameter");
this._observedTourneyLC = this._params[0].toLowerCase();
this.filterString = this._params.join('-');
this.url = SCHEDULE_URL;
this._gameId = null;
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 Giovanni Campagna
// Daniel Melendez
//
// See COPYING for details
"use strict";
const ICalendar = require('ical.js');
const Tp = require('thingpedia');
const POLL_INTERVAL = 3 * 3600 * 1000; // 3 hours
module.exports = new Tp.ChannelClass({
Name: 'iCalendarEventBeginChannel',
Extends: Tp.HttpPollingTrigger,
interval: POLL_INTERVAL,
_init: function(engine, device, params) {
this.parent(engine, device);
this.url = device.url;
this.interval = POLL_INTERVAL;
},
formatEvent(event, filters) {
var startDate = event[0];
var endDate = event[1];
var summary = event[2];
var description = event[3];
var sequence = event[4];
var organizer = event[5];
var location = event[6];
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of ThingPedia
//
// Copyright 2016 Huafei Wang
// Ye Yuan
//
// See LICENSE for details
const Tp = require('thingpedia');
module.exports = new Tp.ChannelClass({
Name: 'GmailPollingTrigger',
Extends: Tp.HttpPollingTrigger,
RequiredCapabilities: ['channel-state'],
interval: 60000,
_init: function(engine, state, device) {
this.parent();
this.state = state;
this.device = device;
this.url = 'https://www.googleapis.com/gmail/v1/users/' + this.device.userId + '/messages?maxResults=1';
},
get auth() {
return 'Bearer ' + this.device.accessToken;
},
_onResponse: function(data) {
var parsed_package = JSON.parse(data);
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2016 Jacob Baldwin
// Giovanni Campagna
//
// See LICENSE for details
"use strict";
const Tp = require('thingpedia');
const TUMBLR_POSTS_URL = 'https://api.tumblr.com/v2/blog/%s/posts/text?api_key=%s&filter=text';
const POLL_INTERVAL = 30*60000; // 30 minutes
module.exports = new Tp.ChannelClass({
Name: 'TumblrNewPosts',
Extends: Tp.HttpPollingTrigger,
RequiredCapabilities: ['channel-state'],
interval: POLL_INTERVAL,
_init: function(engine, state, device, params) {
this.parent(engine, state, device);
this.state = state;
this._params = params;
this.filterString = this._params[0];
this._observedBlog = this._params[0];
if (!this._observedBlog)
throw new TypeError('Missing parameter');
if (this._observedBlog.indexOf('.') < 0)
this._observedBlog = this._observedBlog + '.tumblr.com';
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of ThingEngine
//
// Copyright 2015 Jiaqi Xue
//
const Tp = require('thingpedia');
const URL_TEMPLATE = 'https://us.data.bodytrace.com/1/device/%s/datavalues?names=batteryVoltage,signalStrength,values/weight,values/unit';
const POLL_INTERVAL = 3600 * 1000; // 1h
module.exports = new Tp.ChannelClass({
Name: 'ScaleChannel',
Extends: Tp.HttpPollingTrigger,
RequiredCapabilities: ['channel-state'],
interval: POLL_INTERVAL,
_init: function(engine, state, device) {
this.parent();
this.url = URL_TEMPLATE.format(device.serial);
this.auth = "Basic " + (new Buffer(device.username + ':' + device.password)).toString('base64');
this._state = state;
},
_onResponse: function(response) {
var state = this._state;
function makeEvent(time, data) {
// weight is in grams, convert to kg, which the base unit
// -*- 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');
const Interval = 5 * 60 * 1000; // 5 min
module.exports = new Tp.ChannelClass({
Name: 'OneDriveFileCreatedTrigger',
Extends: Tp.HttpPollingTrigger,
RequiredCapabilities: ['channel-state'],
interval: Interval,
_init: function(engine, state, device) {
this.parent(engine, device);
this._state = state;
this._baseurl = 'https://api.onedrive.com/v1.0/drive/root/view.delta';
this.url = this._baseurl + "?token=latest";
this.useOAuth2 = this.device;
},
formatEvent(event) {
var fileName = event[0];
return ["New file created: %s".format(fileName)];
//
// This file is part of ThingPedia
//
// Copyright 2016 Linyu He
// Lingbin Li
//
// See LICENSE for details
const Tp = require('thingpedia');
const INTERVAL = 60000;
const PAGE_SIZE = 10;
module.exports = new Tp.ChannelClass({
Name: 'GoogleDocsPollingTrigger',
Extends: Tp.HttpPollingTrigger,
RequiredCapabilities: ['channel-state'],
interval: INTERVAL,
_init: function(engine, state, device) {
this.parent();
this.device = device;
this.url = 'https://www.googleapis.com/drive/v3/files?orderBy=createdTime desc&pageSize=' + PAGE_SIZE;
this.state = state;
},
get auth() {
return 'Bearer ' + this.device.accessToken;
},
_onResponse: function(response) {
var parsedResponse = JSON.parse(response);
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// Copyright 2015 Rick Yan
//
// See LICENSE for details
const Tp = require('thingpedia');
//http://finance.yahoo.com/d/quotes.csv?s=&f=nab
const YAHOO_URL = 'http://finance.yahoo.com/d/quotes.csv';
const POLL_INTERVAL = 30 * 1000; // 30s
module.exports = new Tp.ChannelClass({
Name: 'StockQuoteChannel',
Extends: Tp.HttpPollingTrigger,
_init: function(engine, device, params) {
this.parent();
this._params = params;
this._myCompanyID = this._params[0];
if (!this._myCompanyID)
throw new TypeError("Missing required parameters");
this.filterString = String(this._myCompanyID)
this.interval = POLL_INTERVAL;
this.url = YAHOO_URL + "?s=" + encodeURIComponent(this._myCompanyID) + "&f=nab";
},
formatEvent(event, hint, formatter) {
var id = event[0];
module.exports = function(name, url, format) {
return new Tp.ChannelClass({
Name: name,
Extends: Tp.HttpPollingTrigger,
RequiredCapabilities: ['channel-state'],
interval: POLL_INTERVAL,
_init(engine, state, device, params) {
this.parent(engine, state, device);
this.url = url;
this.precise = true;
},
formatEvent: format,
_onResponse(data) {
if (!data)
return;
var jcalData = ICAL.parse(data);