Skip to content

Commit

Permalink
Refactored TxtWeb
Browse files Browse the repository at this point in the history
* Multiple DB support
* I actually don't know if it works currently
* TODO #38
  • Loading branch information
aneesh-neelam committed Apr 15, 2015
1 parent 11cf858 commit 24e1d63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
17 changes: 9 additions & 8 deletions api/txtweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,48 @@ var path = require('path');

var log;
if (process.env.LOGENTRIES_TOKEN) {
var logentries = require('node-logentries');
let logentries = require('node-logentries');
log = logentries.logger({
token: process.env.LOGENTRIES_TOKEN
});
}

var api_login = require(path.join(__dirname, 'login', 'auto'));
var api_aggregate = require(path.join(__dirname, 'scraper', 'aggregate'));
var api_grades = require(path.join(__dirname, 'scraper', 'grades'));
var status = require(path.join(__dirname, '..', 'status'));


var parseMessage = function (app, data, callback) {
var reply = [
let reply = [
'Register with the VITacademics SMS Service: @vitacademics register [Campus] [RegNo] [DoB]',
'Get Course Details: @vitacademics course [CourseCode]',
'Get Today\'s Classes: @vitacademics today',
'Get Attendance: @vitacademics attendance',
'Get Marks: @vitacademics marks',
'Help - @vitacademics help'
];
var args = data.message.toUpperCase().split(' ');
if (args[0] === 'REGISTER') {
if (data.args[0] === 'REGISTER') {
// TODO
reply = ['Feature Incomplete', 'Contribute to aneesh-neelam/VITacademics on GitHub'];
}
else if (args[0] === 'COURSE') {
else if (data.args[0] === 'COURSE') {
// TODO
reply = ['Feature Incomplete', 'Contribute to aneesh-neelam/VITacademics on GitHub'];
}
else if (args[0] === 'TODAY') {
else if (data.args[0] === 'TODAY') {
// TODO
reply = ['Feature Incomplete', 'Contribute to aneesh-neelam/VITacademics on GitHub'];
}
else if (args[0] === 'ATTENDANCE') {
else if (data.args[0] === 'ATTENDANCE') {
// TODO
reply = ['Feature Incomplete', 'Contribute to aneesh-neelam/VITacademics on GitHub'];
}
else if (args[0] === 'MARKS') {
else if (data.args[0] === 'MARKS') {
// TODO
reply = ['Feature Incomplete', 'Contribute to aneesh-neelam/VITacademics on GitHub'];
}
log.log('debug', {log: 'Incomplete feature TxtWeb used', args: data.args, mobile: data.mobile});
callback(false, reply);
};

Expand Down
6 changes: 4 additions & 2 deletions routes/txtweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@

var express = require('express');
var path = require('path');
var router = express.Router();

var api_txtweb = require(path.join(__dirname, '..', 'api', 'txtweb'));

var router = express.Router();

router.get('/', function (req, res) {
let googleAnalyticsToken = process.env.GOOGLE_ANALYTICS_TOKEN || 'UA-35429946-2';
let txtWebAppKey = process.env.TXTWEB_APP_KEY || 'randomkey';
if (req.query['txtweb-message'] && req.query['txtweb-mobile']) {
let args = req.query['txtweb-message'].toUpperCase().split(' ');
let app = {
dbs: req.dbs,
queue: req.queue
};
let data = {
message: req.query['txtweb-message'],
args: args,
mobile: req.query['txtweb-mobile']
};
let onGet = function (err, messages) {
Expand Down

0 comments on commit 24e1d63

Please sign in to comment.