Cross tweet from Mastodon

ekardnam 9869f60213 Code style 4 years ago
.gitignore 2eeadd9f2a OAuth 4 years ago
LICENSE 921ae2e84e Add 'LICENSE' 4 years ago
README.md 92b6a09817 Readme definitely 4 years ago
app.js 2eeadd9f2a OAuth 4 years ago
bot.js 9869f60213 Code style 4 years ago
cert.pem 2eeadd9f2a OAuth 4 years ago
key.pem 2eeadd9f2a OAuth 4 years ago
oauth.js 2eeadd9f2a OAuth 4 years ago
package.json 2eeadd9f2a OAuth 4 years ago
storage.js 2eeadd9f2a OAuth 4 years ago

README.md

XTweet

Converts noisy toots to tiny tweets

Configurazione

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ù Sviluppo > Nuova applicazione e dare il permesso read:statuses.

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'OAuth mentre callback_url e callback_path concatenati danno il callback dell'OAuth (che deve essere settato nell'app Twitter)

Al primo avvio si avvia un webserver. Visitandolo ci si logga su twitter mentre la connessione con mastodon è fatta solo mettendo il token nel config

Per eseguirlo npm install per installare le deps e poi node app.js