ekardnam fb146f7cc1 Read me | 4 years ago | |
---|---|---|
.dockerignore | 4 years ago | |
.gitignore | 4 years ago | |
Dockerfile | 4 years ago | |
LICENSE | 4 years ago | |
README.md | 4 years ago | |
app.js | 4 years ago | |
bot.js | 4 years ago | |
cert.pem | 4 years ago | |
key.pem | 4 years ago | |
oauth.js | 4 years ago | |
package.json | 4 years ago | |
storage.js | 4 years ago |
Converts noisy toots to tiny tweets
Crea un file config.js
con questa struttura
module.exports = {
twitter_consumer_key: '...',
twitter_consumer_secret: '...',
mastodon_token: '...',
mastodon_user: 'ekardnam',
instance: 'mastodon.bida.im',
key: 'key.pem',
cert: 'cert.pem',
passphrase: 'pass',
bind_ip: '0.0.0.0',
port: 8000,
callback_url: 'https://localhost:8000',
callback_path: '/oauth/callback'
}
In twitter_consumer_key
e in twitter_consumer_secret
ci vanno i token relativi all'app Twitter.
Per Mastodon basta andare nel menù Impostazioni > Sviluppo > Nuova applicazione e dare il permesso read:statuses
.
Twitter è po' più complicato. Bisgona eseguire l'app in locale alla prima esecuzione siccome non trovarà un file storage.json
con i token di Twitter l'app avvierà un webserver per l'autorizzazione di Twitter.
I certificati che sono nella repo sono di test e sono configurati già nel config d'esempio. Siccome vengono negoziati i token di Twitter è bene cambiarli. Si generano con
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
bind_ip
e port
sono dove si binda il server HTTPS per l'autorizzazione, mentre callback_url
e callback_path
concatenati danno il callback dell'OAuth (che deve essere settato nell'app Twitter)
Avviato il webserver lo si visita (a https://localhost:8000 con la configurazione di default) e verrà chiesto di autenticarsi su Twitter e di autorizzare l'app.
Dopo aver seguito i passi precedenti si può finalmente eseguire il bot. Se lo si vuole ospitare su un server a questo punto sono necessarie alcune accortezze.
Dopo aver clonato la repo sul server è necessario copiare nella directory sul server i file config.js
e storage.json
che contengono i token relativi a Mastodon e Twitter.
Fatto questo si può buildare l'immagine Docker con docker build . -t xtweet
e successivamente eseguirla con docker run -d xtweet