arona icon indicating copy to clipboard operation
arona copied to clipboard

Instructions for setup and Line API

Open daktak opened this issue 4 years ago • 17 comments

Are you able to post a README on how to set up a personal LINE API key and this bridge?

daktak avatar Apr 11 '21 02:04 daktak

virtualenv . -p /usr/bin/python3 source ./bin/activate pip -r requirements.txt python main.py

After setting up a provider and a channel, I used below to create a short-lived access token (can you do a long lived one?) https://developers.line.biz/en/reference/messaging-api/#issue-shortlived-channel-access-token

But i'm unsure what value ROOM = should be, and I get the below error

linebot.exceptions.LineBotApiError: LineBotApiError: status_code=403, request_id=7e6fef71-bc31-4ba7-8fbc-a5a59dbec1d7, error_response={"details": [], "message": "Forbidden"}, headers={'Server': 'openresty', 'Content-Type': 'application/json', 'x-line-request-id': '7e6fef71-bc31-4ba7-8fbc-a5a59dbec1d7', 'x-content-type-options': 'nosniff', 'x-xss-protection': '1; mode=block', 'x-frame-options': 'DENY', 'Expires': 'Sun, 11 Apr 2021 03:32:06 GMT', 'Cache-Control': 'max-age=0, no-cache, no-store', 'Pragma': 'no-cache', 'Date': 'Sun, 11 Apr 2021 03:32:06 GMT', 'Connection': 'close'}

daktak avatar Apr 11 '21 03:04 daktak

Ok, creating a messaging api I get the following errror

linebot.exceptions.LineBotApiError: LineBotApiError: status_code=400, request_id=a6a4517b-8f6d-47b4-ae62-4553e472b39c, error_response={"details": [], "message": "The property, 'to', in the request body is invalid (line: -, column: -)"}, headers={'Server': 'openresty', 'Content-Type': 'application/json', 'x-line-request-id': 'a6a4517b-8f6d-47b4-ae62-4553e472b39c', 'x-content-type-options': 'nosniff', 'x-xss-protection': '1; mode=block', 'x-frame-options': 'DENY', 'Content-Length': '85', 'Expires': 'Sun, 11 Apr 2021 03:59:26 GMT', 'Cache-Control': 'max-age=0, no-cache, no-store', 'Pragma': 'no-cache', 'Date': 'Sun, 11 Apr 2021 03:59:26 GMT', 'Connection': 'close'}

daktak avatar Apr 11 '21 04:04 daktak

OK, I will put the documents as soon as possible.

supersonictw avatar Apr 11 '21 04:04 supersonictw

Ok, ROOM value should be populated with the reply string when adding the bot to group that has not been entered in the config.ini yet.

daktak avatar Apr 11 '21 06:04 daktak

Ok, now if I send a message from Matrix, it spams with a history of all messages from Matrix

daktak avatar Apr 11 '21 06:04 daktak

Also i think matrix room must not be encrypted? is below needed in matrix/poll.py under message_callback if room.room_id != config_instance["Matrix"]["ROOM"]: return

daktak avatar Apr 11 '21 07:04 daktak

Fyi bridge server and port must be exposed to the web for webhook. Also url appears to need /callback appended in line API settings

daktak avatar Apr 11 '21 07:04 daktak

OK, I will put the documents as soon as possible.

README has been updated.

supersonictw avatar Apr 11 '21 17:04 supersonictw

Ok, now if I send a message from Matrix, it spams with a history of all messages from Matrix

This is the bug I was finding, but I need someone who knows Matrix API to resolve the problem.

supersonictw avatar Apr 11 '21 17:04 supersonictw

Under the wiki, please mention the user/pass for Matrix should not be the user you will use to chat. +The ID for you to login the network of Matrix. Set up a new user to act as your bridge puppet, as the bridge will not relay messages sent by this user. Add this user to the groups that are bridged to a line room.

daktak avatar Apr 20 '21 05:04 daktak

Also worth mentioning the Line chat bot must be added to the line room. Matrix group should be unencrypted

daktak avatar Apr 20 '21 05:04 daktak

OK, I will update them asap.

supersonictw avatar Apr 21 '21 13:04 supersonictw

Are you able to update install/running instructions for javascript ? how to convert config.ini to js config .env? How to generate the matrix token?

just found .env.sample

daktak avatar Jul 07 '22 04:07 daktak

How to generate the matrix token?

~~The method exists in dev branch only currently.~~ (Merged) But https://t2bot.io/docs/access_tokens/ can help you to generate one from Element.

supersonictw avatar Jul 09 '22 04:07 supersonictw

curl  -XPOST   -d '{"type":"m.login.password", "user":"yourmatrixuser", "password":"yourpass!"}'   "https://yourmatrixhost/_matrix/client/r0/login"

Above is a nice simple way to get the token, perhaps add to the documentation?

daktak avatar Jul 09 '22 04:07 daktak

Above is a nice simple way to get the token, perhaps add to the documentation?

That's cool! But there is a new feature can help you get the AccessToken more friendly since 8fff486c8cf03e21ad410ce81b9b45c624bf75ca.

npm run get-matrix-access

supersonictw avatar Jul 09 '22 06:07 supersonictw

starting to update the wiki https://github.com/daktak/matrix-line-bridge/wiki/1_Create_Line_Bot

daktak avatar Jul 10 '22 02:07 daktak

The documentation is working in processing. https://github.com/web-tech-tw/arona/pull/20

supersonictw avatar Jul 21 '24 16:07 supersonictw

Completed. https://github.com/web-tech-tw/arona/pull/20

supersonictw avatar Jul 24 '24 07:07 supersonictw