From 4a49d68139a5cb7d45c658865a7115fca1e40eb6 Mon Sep 17 00:00:00 2001 From: tree Date: Tue, 4 Jan 2022 09:32:08 +0100 Subject: [PATCH] Update --- .gitignore | 1 + Makefile | 3 +++ spec/22/speakers.yaml | 8 ++++++- utils/stats.js | 8 +++---- utils/twitter.js | 50 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 utils/twitter.js diff --git a/.gitignore b/.gitignore index 5212586..fd83fbe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store docs dist +.env diff --git a/Makefile b/Makefile index e31d965..9b519d2 100644 --- a/Makefile +++ b/Makefile @@ -22,3 +22,6 @@ speakers-leads: stats: deno run --unstable --allow-read utils/stats.js + +twitter: + deno run --unstable --allow-read --allow-env --allow-net utils/twitter.js diff --git a/spec/22/speakers.yaml b/spec/22/speakers.yaml index 242dd1d..2917705 100644 --- a/spec/22/speakers.yaml +++ b/spec/22/speakers.yaml @@ -109,7 +109,7 @@ - name: Tomáš orgs: | - Člen [KryptoVláďa komunity](https://www.kryptovlada.win) + Člen [KryptoVláďa](https://www.kryptovlada.win) komunity tracks: [ zaklady, eth, defi ] - id: urza @@ -162,3 +162,9 @@ Člen [Bitcoinovej kanál](https://bitcoinovejkanal.cz/) komunity tracks: [ zaklady, btc ] +- id: mirek-h + name: Mirek H + orgs: | + Člen [KryptoVláďa](https://www.kryptovlada.win) komunity + tracks: [ alty ] + diff --git a/utils/stats.js b/utils/stats.js index 21344b7..c7ff26c 100644 --- a/utils/stats.js +++ b/utils/stats.js @@ -16,12 +16,12 @@ for (const sp of entry.specs.speakers) { tracksCount[tr]++ } } -const tracks = entry.specs.tracks.map(t => [t.id, '+'.repeat(tracksCount[t.id] || '0' ) ]) +const tracks = entry.specs.tracks.map(t => [t.id, '|' + '+'.repeat(tracksCount[t.id] || '0' ) ]) const table = Table.from(tracks) -table.border(true) +//table.border(true) -console.log('\nRozložení jednotlivých tématických sekcí dle přednášejících:') -console.log(table.toString()) +console.log('\nRozložení jednotlivých tématických sekcí dle přednášejících:\n' + '-'.repeat(60)) +console.log(table.toString() + '\n') diff --git a/utils/twitter.js b/utils/twitter.js new file mode 100644 index 0000000..a4a4fab --- /dev/null +++ b/utils/twitter.js @@ -0,0 +1,50 @@ +import { config } from "https://deno.land/x/dotenv/mod.ts" +import SimpleTwitter from "https://deno.land/x/simple_twitter_deno@0.05/simple_twitter_deno.ts" +import { Table } from "https://deno.land/x/cliffy@v0.20.1/table/mod.ts" +import { UTXOEngine } from './engine.js' + +const utxo = new UTXOEngine({ silent: true }) +await utxo.init() + +config({ path: ".env", export: true }) + +const simple_twitter = new SimpleTwitter({ + consumer_key: Deno.env.get("CONSUMER_KEY"), + consumer_secret: Deno.env.get("CONSUMER_SECRET"), + access_token: Deno.env.get("ACCESS_TOKEN"), + access_token_secret: Deno.env.get("ACCESS_TOKEN_SECRET"), + bearer_token: Deno.env.get("BEARER_TOKEN") +}) + +const entryId = '22' +const entry = utxo.entries[entryId] + +const arr = [] +let total = 0 + +for (const sp of entry.specs.speakers) { + if (!sp.twitter) { + continue + } + const tw = await twitterUser(sp.twitter) + if (!tw) { + continue + } + arr.push([ tw.screen_name, tw.followers_count ]) + total += tw.followers_count +} + +arr.push([]) +arr.push([ 'total', total ]) + +const table = Table.from(arr) +console.log('\nTwitter followers count:\n\n' + table.toString() + '\n') + +async function twitterUser(screen_name) { + const resp = await simple_twitter.get("users/lookup", { screen_name }) + if (resp.length === 1) { + return resp[0] + } + return null +} +