Skip to content

Commit

Permalink
add home page and readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jyotman committed Apr 15, 2017
1 parent 070cd64 commit ad49435
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 8 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Fantasy Premier League Bot

A bot made for the Facebook messenger platform to track any fantasy team's status on the [fantasy.premierleague.com](https://fantasy.premierleague.com).

To use the bot click [here](https://m.me/341862696190397).

For information about using the bot visit the [website](https://fantasy-bot.herokuapp.com/).
8 changes: 8 additions & 0 deletions lib/controllers/appController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Created by jyot on 15/4/17.
*/
'use strict';

exports.getHome = function (req, res, next) {
res.render('home');
};
1 change: 0 additions & 1 deletion lib/controllers/fantasyController.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ exports.messageReceived = async function (req, res, next) {
const userMessage = req.body.entry[0].messaging[0].message.text;
const userId = res.locals.userId = req.body.entry[0].messaging[0].sender.id;
const messageToSend = await fantasyHelper.processUserMessage(userMessage.toLowerCase(), userId);
console.log(messageToSend);
await fantasyHelper.sendMessage(userId, messageToSend);
res.end();
} catch (err) {
Expand Down
10 changes: 7 additions & 3 deletions lib/tools/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ const redis = require('redis');

const client = redis.createClient(process.env.REDIS_URL);

client.on("error", function (err) {
console.error('Redis Error', err);
});
client
.on('error', function (err) {
console.error('Redis Error', err);
})
.on('connect', function () {
console.log('Redis connected');
});

// Map containing user facebook ID as key and fantasy team ID as value
const idsMapKey = 'ids_map';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "track fantasy.premierleague.com",
"main": "app.js",
"engines": {
"node": "7.8.0"
"node": "7.9.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
Binary file added public/images/messenger-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/team-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/stylesheets/home.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h1, h3, p {
font-family: Montserrat;
}
5 changes: 2 additions & 3 deletions routes/appRouter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const express = require('express'),
appController = require('../lib/controllers/appController'),
router = express.Router();

/* GET home page. */
router.get('/', function (req, res) {
res.json({title: 'Express live bro!'});
});
router.get('/', appController.getHome);

module.exports = router;
73 changes: 73 additions & 0 deletions views/home.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!DOCTYPE HTML>

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="/stylesheets/home.css" type="text/css">
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>

<script>
window.fbAsyncInit = function () {
FB.init({
appId: "1261757857215437",
xfbml: true,
version: "v2.8"
});
};
(function (d, s, id) {
let js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id))
return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

<title>Fantasy Premier League Bot</title>
</head>
<body>
<div style="margin-left: 5%; margin-right: 5%">
<h1 style="text-align: center">Fantasy Premier League Bot</h1>

<p>A Facebook bot to get current team scores and your team ranking for all the leagues your are participating in
with just a single command.</p>

<p>You only need to submit your team's ID once and the bot will save it for you.</p>

<p>To start using, obtain your fantasy team's ID by visiting
<a href="https://fantasy.premierleague.com" target="_blank">fantasy.premierleague.com</a> and logging in. After
that
go to the <strong>Points</strong> tab and your team's ID will be visible in the URL in your browser's address
bar.
</p>

<div style="text-align: center; margin-top: 5%; margin-bottom: 3%"><img style="max-width: 100%" src="/images/team-screenshot.png"></div>

<p>This is your team's ID. Simply copy it and give it to the bot with the command - <strong>login &lt;TEAM
ID&gt;</strong>. In the above case it would be <strong>login 2959370</strong>.</p>

<p>We do not ask for any personal or sensitive information like email or passwords. Your team's ID is a public ID.
Anyone can view any team by simply putting a team's ID in the form of the URL given in the image. This is
completely
public data.</p>

<h3 style="text-align: center; margin-top: 5%">Launch the bot - </h3>


<div style="text-align: center">
<div class="fb-messengermessageus" messenger_app_id="1261757857215437" page_id="341862696190397" color="blue"
size="xlarge"></div>
</div>

<h3 style="text-align: center; margin-top: 5%">Or scan this Messenger code - </h3>

<div style="text-align: center"><img style="max-width: 100%; max-height: 300px" src="/images/messenger-code.png">
</div>

</div>
</body>
</html>

0 comments on commit ad49435

Please sign in to comment.