Git Product home page Git Product logo

mx-puppet-twitter's Introduction

Support room on Matrix donate

mx-puppet-twitter

This is a twitter puppeting bridge for matrix. It is based on mx-puppet-bridge.

Setup

Twitter API access

You will need to create a Twitter developer account and a Twitter app, which can be done here: https://developer.twitter.com/en/apps

NOTE: This service uses Twitter's webhooks API. For it to work, you will need the ability to configure a publically accessible URL serving SSL on port 443. Twitter webhooks will not work with any other port. You will likely want to set up a reverse proxy such as Nginx to handle SSL. If you're hosting this on your home network, your ISP may be blocking port 443, in which case you will need to either host it somewhere else, or set up a reverse proxy with port 443 on a VPS back to an open port. This setup and others are beyond the scope of this README.

Configuration

Copy the sample.config.yaml to config.yaml and edit it appropriately. The sample config includes some sensible defaults and comments describing each option.

Run node ./src/index.js. This will generate a twitter-registration.yaml file. Edit that file as needed. In particular, the url option needs to be set to a URL where the bridge can communicate with your homeserver. Copy this file to your Synapse homeserver.

Run node ./src/index.js again to start the bridge. (If you encounter errors here, it is likely because Twitter is unable to reach the webhooks server, or because the bridge is unable to reach your homeserver.)

On your Synapse homeserver, edit your homeserver.yaml's app_service_config_files to include the path to the twitter-registration.yaml, then restart your Synapse server.

Using Docker

To run the bridge as a Docker container, create a directory for your configuration, cd into it, then create your config.yaml as described above.

Run docker run -v `pwd`:/data:z sorunome/mx-puppet-twitter. This will generate the twitter-registration.yaml. Edit it and copy it as above, including updating your homeserver.yaml file and restarting Synapse.

From the same directory, run the following command, being sure to update the port mappings per your config.yaml:

docker run -d --name=mx-puppet-twitter \
  --restart unless-stopped \
  -p 6000:6000 \
  -p 6001:6001 \
  -v `pwd`:/data:z \
  sorunome/mx-puppet-twitter

Usage

Start a chat with @_twitterpuppet_bot:matrix.myhomeserver.com and send help for a list of commands.

mx-puppet-twitter's People

Contributors

cvincent avatar ericmigi avatar sorunome avatar tulir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mx-puppet-twitter's Issues

Not recieving any room invite when people message me, and most functions not implemented !

Hello,

I managed to install this puppet and connect to it correctly via the bot (says connected!)

I double checked the keys and secrets, all seems to be alright but I can't recieve any message looks like, when my friends send messages I don't recieve them in matrix, same if I send them from twitter itself.
The service seems to be struggling to do some stuff, here's a part of the log that's outputed when I try to speak from twitter directly, it seems to react but fail to transmit the message (I can't copy the whole thing in ssh, I don't know how to get the log, not very linux savy)
log.txt

Also most features seem to be non functionnal
image

UnhandledPromiseRejection

(node:11704) UnhandledPromiseRejectionWarning: Error: Forbidden.
    at Request._callback (.................../mx-puppet-twitter/node_modules/twitter-webhooks/lib/helpers.js:27:33)
    at Request.self.callback (................/mx-puppet-twitter/node_modules/request/request.js:185:22)
    at Request.emit (events.js:196:13)
    at Request.<anonymous> (................/mx-puppet-twitter/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:196:13)
    at IncomingMessage.<anonymous> (................/mx-puppet-twitter/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:284:20)
    at IncomingMessage.emit (events.js:201:15)
    at endReadableNT (_stream_readable.js:1130:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:9)
(node:11704) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11704) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Can anyone please help with this? I really am unsure what is wrong here.
I think It is becasue of this issue, that the bot will not even register to my server.

Failing to connect to Twitter:

Steps to Reproduce

  1. Install Twitter bridge through the Ansible method
  2. Start a room with @_twitterpuppet_bot
  3. Type in link
  4. Click link provided by the bot
  5. Authorize, and paste PIN into chat with @_twitterpuppet_bot
  6. Receive the following error in chat:
Status] 7: Twitter as <USERNAME> (<username>): disconnected!: failed to connect. TypeError: Cannot read property 'unsubscribe' of null

I'm not sure what I did incorrectly here. Any advice?

Logs from journalctl matrix-mx-puppet-twitter:

[TwitterPuppet:Twitter] warn: Failed to subscribe to user, retrying... TypeError: Cannot read property 'subscribe' of null
     at Twitter.<anonymous> (/opt/mx-puppet-twitter/build/twitter.js:92:55)
     at Generator.next (<anonymous>)
     at fulfilled (/opt/mx-puppet-twitter/build/twitter.js:5:58)
     at runMicrotasks (<anonymous>)
     at processTicksAndRejections (internal/process/task_queues.js:97:5)
[TwitterPuppet:Twitter] error: Failed to start up puppet 8 TypeError: Cannot read property 'unsubscribe' of null
     at Twitter.<anonymous> (/opt/mx-puppet-twitter/build/twitter.js:97:40)
     at Generator.next (<anonymous>)
     at fulfilled (/opt/mx-puppet-twitter/build/twitter.js:5:58)
     at runMicrotasks (<anonymous>)
     at processTicksAndRejections (internal/process/task_queues.js:97:5)

Installation instructions?

Attempting to get this bridge running on my Arch Linux server. I've managed to run npm install (after installing the sqlite3 package) but I'm stuck from there. Wouldn't mind running this as a Docker container, looks like it's possible, but there's no information about what ports need mapped or how to generate the config.yaml. Would love to take this for a spin and potentially contribute to the project if I can get it running!

Fix install instructions(?)

node ./src - I am not too familiar with how node operates but executing a directory seems strange? and aslo does not work.

Then the closed issue where you referenced the discord puppet turned this up:
npm run start -- -r [-c config.yaml] [-f discord-registration.yaml]
This actually works, and generates the registration config.
(square brackets being optional and default values so just delete them in case you don't want to specify anything new.)

Maybe update the readme?.
Not sure tho. As I said, I do not really know node so the first option might eventually work.

failed to register new webhook

Any suggestions on how I can debug this one?

Apr-6 05:41:01.653 [PuppetBridge] info: Application service started!                                                                                          
Apr-6 05:41:01.653 [PuppetBridge] info: Setting bridge user data...                                                                                           
Apr-6 05:41:04.435 [TwitterPuppet:Twitter] error: Failed to register new webhook Error: Non-200 response code during CRC GET request (i.e. 404, 500, etc).    
    at Request._callback (/opt/mx-puppet-twitter/node_modules/twitter-webhooks/lib/helpers.js:27:33)                                                          
    at Request.self.callback (/opt/mx-puppet-twitter/node_modules/request/request.js:185:22)                                                                  
    at Request.emit (events.js:316:20)                                                                                                                        
    at Request.<anonymous> (/opt/mx-puppet-twitter/node_modules/request/request.js:1161:10)                                                                   
    at Request.emit (events.js:316:20)
    at IncomingMessage.<anonymous> (/opt/mx-puppet-twitter/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:422:28)
    at IncomingMessage.emit (events.js:328:22)
    at endReadableNT (_stream_readable.js:1201:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 214,
  statusCode: 400,
  body: { errors: [ [Object] ] }
}
Apr-6 05:41:04.436 [PuppetBridge] info: Activating users...

config.yaml

bridge:
  port: 29322
  domain: nova.chat
  bindAddress: 0.0.0.0
  homeserverUrl: https://asmux.nova.chat
  loginSharedSecretMap:
    nova.chat: 

homeserverUrlMap:
  nova.chat: https://asmux.nova.chat

namePatterns:
  user: :name [:team? - :team,]  Twitter
  room: :name [:team? - :team,]  Twitter
  group: :name - Twitter

logging:
  console: info
  files:
  - file: /data/debug.log
    level: silly
    disable:
    - 'PresenceHandler'
    - 'bot-sdk-Metrics'
presence:
  enabled: false
database:
  filename: /data/twitter.db
provisioning:
  whitelist:
    - "@testtwo:nova\\.chat"
  sharedSecret: 
  apiPrefix: /_matrix/provision
twitter:
  consumerKey: ""
  consumerSecret: ""
  accessToken: "-"
  accessTokenSecret: ""
  environment: "novadev"
  server:
    url: https://testtwo.novabridge.dev/twitter
    host: 0.0.0.0
    port: 4567

Many commands aren’t implemented

Hello,

22:09:38 <alarig> help
22:09:38 <_twitterpuppet_bot> Available commands: link, unlink, relink, help, list, setmatrixtoken, adminme, listusers, listrooms, listgroups, settype, setispublic, setautoinvite, invite, groupinvite, unbridge, fixghosts, fixmute, resendbridgeinfo
Type help <command> to get more help on them.
22:09:45 <alarig> help link
22:09:45 <_twitterpuppet_bot> Command link not found!
22:09:55 <alarig> help list
22:09:55 <_twitterpuppet_bot> List all set links along with their information.
Usage: list
22:10:02 <alarig> list
22:10:02 <_twitterpuppet_bot> Links:
● 1: Twitter as alarig_ (alarig)
22:10:16 <alarig> listusers
22:10:16 <_twitterpuppet_bot> Feature not implemented!
22:10:21 <alarig> listrooms
22:10:21 <_twitterpuppet_bot> Feature not implemented!
22:10:25 <alarig> listgroups
22:10:25 <_twitterpuppet_bot> Feature not implemented!
22:10:31 <alarig> invite
22:10:31 <_twitterpuppet_bot> Couldn't send invite to the room. Perhaps you don't have permission to see it?
22:10:51 <alarig> fixghosts
22:10:51 <_twitterpuppet_bot> Room not resolvable
22:10:58 <alarig> fixmute
22:10:58 <_twitterpuppet_bot> Room not resolvable

I was trying to re-invite me to a PM that I leaved, and I don’t see how.

twitter bridge seems to fail silently every ~12 hours. restarting fixes it

Messages fail to be bridged in either direction. not much in logs unfortunately.

Jan-15 17:25:34.159 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-15 17:25:34.162 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-15 17:25:34.183 [UserSync] �[32minfo�[39m: Fetching client for 1144425621340078081
Jan-15 17:25:34.188 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) POST http://synapse:8008/_matrix/client/r0/register
Jan-15 17:25:34.199 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-3) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-15 17:25:34.222 [ChannelSync] �[32minfo�[39m: Fetching mxid for roomId 1144425621340078081 and puppetId 1
Jan-15 17:25:34.229 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-15 17:25:34.236 [bot-sdk-MatrixLiteClient] �[31merror�[39m: (REQ-1) { errcode: 'M_USER_IN_USE', error: 'User ID already taken.' }
Jan-15 17:25:34.237 [bot-sdk-Appservice] �[31merror�[39m: Error registering user: User ID is in use
Jan-15 17:25:34.252 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-15 17:25:34.266 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-2) PUT http://synapse:8008/_matrix/client/r0/rooms/!bZztJeWksThqaiKTkM%3Aeric.nova.chat/send/m.room.message/1579109134266__REQ1
Jan-15 17:25:34.911 [bot-sdk-Appservice] �[32minfo�[39m: Processing transaction 82
Jan-15 17:25:34.913 [bot-sdk-Appservice] �[32minfo�[39m: Processing event of type m.room.message
Jan-15 17:25:34.919 [PuppetBridge] �[32minfo�[39m: New message by @eric:eric.nova.chat of type m.room.message to process!
172.20.0.2 - - [15/Jan/2020:17:25:34 +0000] "PUT /transactions/82?access_token=a59ca7d9-c389-4c3e-b387-b3b4a5b66dca HTTP/1.1" 200 2 "-" "Synapse/1.7.2"
Jan-16 17:39:44.014 [Store] �[32minfo�[39m: Starting DB Init
Jan-16 17:39:44.035 [Store] �[32minfo�[39m: Filename present in config, using sqlite
Jan-16 17:39:44.038 [SQLite3] �[32minfo�[39m: Opening /data/twitter.db
Jan-16 17:39:44.068 [Store] �[32minfo�[39m: Database schema version is 6, latest version is 6
{ response_token: 'p5y5HVvEEP9pP9pTu23qYYGkpgn0=' }
Jan-16 17:39:45.251 [PuppetBridge] �[32minfo�[39m: Starting application service....
Jan-16 17:39:45.285 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) POST http://synapse:8008/_matrix/client/r0/register
Jan-16 17:39:45.342 [bot-sdk-MatrixLiteClient] �[31merror�[39m: (REQ-1) { errcode: 'M_USER_IN_USE', error: 'User ID already taken.' }
Jan-16 17:39:45.348 [PuppetBridge] �[32minfo�[39m: Application service started!
Jan-16 17:39:45.349 [PuppetBridge] �[32minfo�[39m: Setting bridge user data...
Jan-16 17:39:45.350 [PuppetBridge] �[32minfo�[39m: Activating users...
Jan-16 17:39:45.360 [TwitterPuppet:Twitter] �[32minfo�[39m: Adding new Puppet: puppetId=1
Jan-16 17:39:45.607 [BotProvisioner] �[32minfo�[39m: Sending status message for puppetId 1...
Jan-16 17:39:45.659 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-2) PUT http://synapse:8008/_matrix/client/r0/rooms/!KZcUyaWYUGzlVAnIls%3Aeric.nova.chat/send/m.room.message/1579196385658__REQ1
Jan-16 17:39:47.460 [bot-sdk-Appservice] �[32minfo�[39m: Processing transaction 83
Jan-16 17:39:47.463 [bot-sdk-Appservice] �[32minfo�[39m: Processing event of type m.room.message
172.20.0.2 - - [16/Jan/2020:17:39:47 +0000] "PUT /transactions/83?access_token=a59ca7d9-c389-4c3e-b387-b3b4a5b66dca HTTP/1.1" 200 2 "-" "Synapse/1.7.2"
Jan-16 17:40:05.496 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-16 17:40:05.499 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-16 17:40:05.518 [UserSync] �[32minfo�[39m: Fetching client for 1144425621340078081
Jan-16 17:40:05.522 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) POST http://synapse:8008/_matrix/client/r0/register
Jan-16 17:40:05.538 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-3) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-16 17:40:05.594 [ChannelSync] �[32minfo�[39m: Fetching mxid for roomId 1144425621340078081 and puppetId 1
Jan-16 17:40:05.611 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-16 17:40:05.650 [bot-sdk-MatrixLiteClient] �[31merror�[39m: (REQ-1) { errcode: 'M_USER_IN_USE', error: 'User ID already taken.' }
Jan-16 17:40:05.652 [bot-sdk-Appservice] �[31merror�[39m: Error registering user: User ID is in use
Jan-16 17:40:05.681 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-16 17:40:05.707 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-2) PUT http://synapse:8008/_matrix/client/r0/rooms/!bZztJeWksThqaiKTkM%3Aeric.nova.chat/send/m.room.message/1579196405706__REQ1
Jan-16 17:40:06.420 [bot-sdk-Appservice] �[32minfo�[39m: Processing transaction 84
Jan-16 17:40:06.423 [bot-sdk-Appservice] �[32minfo�[39m: Processing event of type m.room.message
Jan-16 17:40:06.430 [PuppetBridge] �[32minfo�[39m: New message by @eric:eric.nova.chat of type m.room.message to process!
172.20.0.2 - - [16/Jan/2020:17:40:06 +0000] "PUT /transactions/84?access_token=a59ca7d9-c389-4c3e-b387-b3b4a5b66dca HTTP/1.1" 200 2 "-" "Synapse/1.7.2"
Jan-16 17:40:49.548 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) GET http://synapse:8008/_matrix/client/r0/account/whoami
Jan-16 17:40:49.584 [UserSync] �[32minfo�[39m: Fetching client for 844726645
Jan-16 17:40:49.587 [UserSync] �[32minfo�[39m: User doesn't exist yet, creating entry...
Jan-16 17:40:49.712 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-1) POST http://synapse:8008/_matrix/client/r0/register
Jan-16 17:40:53.347 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-2) PUT http://synapse:8008/_matrix/client/r0/profile/%40twitter1_844726645%3Aeric.nova.chat/displayname
Jan-16 17:40:53.485 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-3) POST http://synapse:8008/_matrix/media/r0/upload
Jan-16 17:40:54.629 [bot-sdk-MatrixLiteClient] �[32minfo�[39m: (REQ-4) PUT http://synapse:8008/_matrix/client/r0/profile/%40twitter1_844726645%3Aeric.nova.chat/avatar_url

UnhandledPromiseRejectionWarning: Error: Forbidden.

I've set up everything as far as I can see, but I'm getting this error. (I set up a reverse proxy and pointed it to the internal host where the bridge is running, but I'm still getting this error.

Any tip about how can I debug it?

Thanks!

Jan-28 18:09:30.561 [Store] info: Starting DB Init
Jan-28 18:09:30.565 [Store] info: Filename present in config, using sqlite
Jan-28 18:09:30.566 [SQLite3] info: Opening database.db
Jan-28 18:09:30.570 [Store] info: Database schema version is 9, latest version is 9
(node:7454) UnhandledPromiseRejectionWarning: Error: Forbidden.
    at Request.request [as _callback] (/opt/mx-puppet-twitter/node_modules/twitter-webhooks/lib/helpers.js:27:33)
    at Request.self.callback (/opt/mx-puppet-twitter/node_modules/request/request.js:185:22)
    at Request.emit (events.js:198:13)
    at Request.<anonymous> (/opt/mx-puppet-twitter/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:198:13)
    at IncomingMessage.<anonymous> (/opt/mx-puppet-twitter/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:286:20)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:7454) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7454) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.