diff --git a/cfg.js b/cfg.js new file mode 100644 index 0000000..156fc29 --- /dev/null +++ b/cfg.js @@ -0,0 +1,8 @@ +module.exports = { + consumer_key: '0jLhI21FclBdw7ArkzBIPj4W6', + consumer_secret: 'Q805J8iKRuhGKWnYDiB8gL6u9LnRFUrJFGztLMpFALrLMEX0eg', + token: '527372302-oQneyUhrb7aWRAJldyFN535bql3kw9fS7nai7LNy', + access_token_key: '527372302-oQneyUhrb7aWRAJldyFN535bql3kw9fS7nai7LNy', + token_secret: '7FQ3w5jzlePCEkrJ4qt3hPvcHXB8vstaBKCubzGdWLV0Z', + access_token_secret: '7FQ3w5jzlePCEkrJ4qt3hPvcHXB8vstaBKCubzGdWLV0Z' +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..33e9d1c --- /dev/null +++ b/index.html @@ -0,0 +1,54 @@ + + + + Mur de tweets ! + + + + + + + + + + +
+
+

Ouvre ton Twitter ou crée-toi un compte si tu n'en as pas, et fait un maximum de tweets avec le hashtag #LeClubInfoCestCool, celui qui en fait le plus gagne une binouze !

+

Ça commence DTC

+

Ça finit DTC

+
+
+ +

c'est cool

+

Mur de tweets

+
+
+

Venez déguster le bon gratin de pâtes (avec ou sans jambon) fait avec amour par Poly'games et Le Club Info pour 2,5€ seulement ! Hmmm, c'est bon !

+
+
+
+
+
+
+
    +
+
+
+ + diff --git a/index.js b/index.js new file mode 100644 index 0000000..453b5fa --- /dev/null +++ b/index.js @@ -0,0 +1,59 @@ +var express = require('express'); +var app = express(); +var http = require('http').Server(app); +var io = require('socket.io')(http) + +var cfg = require('./cfg.js') +var tw = require('node-tweet-stream')(cfg) +var tp = require('twitter')(cfg) + +var tweets = []; +var tag = '#LeClubInfoCestCool'; + +io.on('connection', function(socket) { + socket.on('track', function(tag) { + tw.track(tag); + }); + socket.on('untrack', function(tag) { + tw.untrack(tag); + }); + console.log('Someone connected'); + socket.emit('tag', tag); + for (tweet in tweets) { + socket.emit('tweet', tweets[tweet]); + } +}); + +function twe(tweet) { + console.log('Tweet', tweet.text) + tweets.push(tweet) + io.emit('tweet', tweet) +} + +tp.get('search/tweets', {q: tag, count: 10}, function(err, tweets, rep) { + if (err) { + console.log(err); + } else { + for (tweet in tweets.statuses) { + twe(tweets.statuses[tweet]) + } + } +}); + +tw.track(tag); +tw.on('tweet', twe) + +setInterval(function msg() { + var whole = require('fs').readFileSync('sub.txt', 'utf8'); + console.log(whole) + ex = whole.split('\n'); + id = Math.floor((Math.random() * (ex.length - 1))); + io.emit('msg', ex[id]) + console.log('MSG', id, ex[id]); +}, 30000); + +app.use(express.static(__dirname)) + +http.listen(3000, function(){ + console.log('listening on *:3000'); +}); diff --git a/logo.svg b/logo.svg new file mode 100644 index 0000000..026146b --- /dev/null +++ b/logo.svg @@ -0,0 +1,144 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..e16b3d1 --- /dev/null +++ b/script.js @@ -0,0 +1,127 @@ +moment.locale('fr', { + months : "janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"), + monthsShort : "janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"), + weekdays : "dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"), + weekdaysShort : "dim._lun._mar._mer._jeu._ven._sam.".split("_"), + weekdaysMin : "Di_Lu_Ma_Me_Je_Ve_Sa".split("_"), + longDateFormat : { + LT : "HH:mm", + LTS : "HH:mm:ss", + L : "DD/MM/YYYY", + LL : "D MMMM YYYY", + LLL : "D MMMM YYYY LT", + LLLL : "dddd D MMMM YYYY LT" + }, + calendar : { + sameDay: "[Aujourd'hui à] LT", + nextDay: '[Demain à] LT', + nextWeek: 'dddd [à] LT', + lastDay: '[Hier à] LT', + lastWeek: 'dddd [dernier à] LT', + sameElse: 'L' + }, + relativeTime : { + future : "dans %s", + past : "il y a %s", + s : "quelques secondes", + m : "une minute", + mm : "%d minutes", + h : "une heure", + hh : "%d heures", + d : "un jour", + dd : "%d jours", + M : "un mois", + MM : "%d mois", + y : "une année", + yy : "%d années" + }, + ordinalParse : /\d{1,2}(er|ème)/, + ordinal : function (number) { + return number + (number === 1 ? 'er' : 'ème'); + }, + meridiemParse: /PD|MD/, + isPM: function (input) { + return input.charAt(0) === 'M'; + }, + // in case the meridiem units are not separated around 12, then implement + // this function (look at locale/id.js for an example) + // meridiemHour : function (hour, meridiem) { + // return /* 0-23 hour, given meridiem token and hour 1-12 */ + // }, + meridiem : function (hours, minutes, isLower) { + return hours < 12 ? 'PD' : 'MD'; + }, + week : { + dow : 1, // Monday is the first day of the week. + doy : 4 // The week that contains Jan 4th is the first week of the year. + } +}); + +var startTime = moment().hour(18).minute(30); +var endTime = moment().hour(19).minute(45); +var tag = '#leclubinfocestcool' + +var s = null; + +var scores = {}; + +function updateLeaderBoard() { + var sortable = []; + for (var name in scores) + sortable.push([name, scores[name]]) + sortable.sort(function(b, a) {return a[1] - b[1]}) + var list = $('#lead ol'); + list.empty(); + for (tuple in sortable) { + list.append($('
  • ').text(sortable[tuple][0])); + } +} + +function clearTw() { + var els = $('#tweets>div'); + for (el in els) { + if (el > 10) { + $(els[el]).remove(); + } + } +} + + + +$(function() { + twttr.ready(function() { + console.log('Ready') + s = io(); + setInterval(function() { + $('#start').text(startTime.fromNow()); + $('#stop').text(endTime.fromNow()); + }, 1000); + s.on('tag', function(datag) { + // tag = datag + }); + s.on('tweet', function(tweet) { + var el = $('
    ').hide(); + console.log(tweet) + var d = new Date(tweet.created_at); + if (tweet.text.toLowerCase().indexOf(tag) != -1 && startTime.isBefore(d) && endTime.isAfter(d)) { // Si il y a bien le tag + el.addClass('tag'); + if (scores[tweet.user.name] == undefined) { + scores[tweet.user.name] = 0; + } + scores[tweet.user.name]++; + updateLeaderBoard(); + } + $('#tweets').prepend(el); + twttr.widgets.createTweet(tweet.id_str, el[0], {theme: 'dark', width: 500}) + .then(function(iframe) { + $(el).show('slow'); + clearTw(); + }); + }) + s.on('msg', function(msg) { + $('#sub').text(msg); + + }); + + }) +}) diff --git a/style.css b/style.css new file mode 100644 index 0000000..989167f --- /dev/null +++ b/style.css @@ -0,0 +1,33 @@ +body { + background: black; + color: white; + font-family: "GeosansLight"; + padding: 30px; + overflow: hidden; +} + +p { + font-size: 150%; +} + +#logo { + width: 300px; +} + +#tweets { + padding: 10px; +} + +#lead { + font-size: 150%; + padding: 10px; +} + +#sub { + min-height: 100px; +} + +.tag { + margin-left: 50px; +} + diff --git a/sub.txt b/sub.txt new file mode 100644 index 0000000..1c12ab6 --- /dev/null +++ b/sub.txt @@ -0,0 +1,19 @@ +On est supra cool ! +On fait pas de vidéos, désolé. +Faites un tweet original, je pourrais peut-être donner des points en plus. +On aurait pu faire la même chose sur Facebook, mais vos amis auraient peut-être pas apprécié. +Partenaire officieux de ta maman depuis dix ans. +Toujours pas espionné par Windows 10. +On est juste derrière toi. +On sait déjà tout sur ta toi. +Barbus et fier de l'être. +Ferme tes volets ! +Ouvre ton PC ! +Tous les langages informatique on les connait. Ou presque. +Contrairement aux idées reçues, nous ne sommes pas une majorité d'IMA. +Nous on nous voit ! + +cout << "Hello world!" << endl; +Arrête de lire ça et tweete. +Twitter et le logo Twitter est une marque déposée de Twitter Inc., et patati, et patata, et texte légal, et bla bla bla... +À Polytech Lille depuis 74 ans. -- libgit2 0.21.2