Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions for setup and Line API #2

Open
daktak opened this issue Apr 11, 2021 · 17 comments
Open

Instructions for setup and Line API #2

daktak opened this issue Apr 11, 2021 · 17 comments

Comments

@daktak
Copy link
Contributor

daktak commented Apr 11, 2021

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

@daktak
Copy link
Contributor Author

daktak commented Apr 11, 2021

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
Copy link
Contributor Author

daktak commented Apr 11, 2021

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'}

@supersonictw
Copy link
Member

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

@daktak
Copy link
Contributor Author

daktak commented Apr 11, 2021

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
Copy link
Contributor Author

daktak commented Apr 11, 2021

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

@daktak
Copy link
Contributor Author

daktak commented Apr 11, 2021

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
Copy link
Contributor Author

daktak commented Apr 11, 2021

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

@supersonictw
Copy link
Member

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

README has been updated.

@supersonictw
Copy link
Member

supersonictw commented Apr 11, 2021

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.

@daktak
Copy link
Contributor Author

daktak commented Apr 20, 2021

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
Copy link
Contributor Author

daktak commented Apr 20, 2021

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

@supersonictw
Copy link
Member

supersonictw commented Apr 21, 2021

OK, I will update them asap.

@daktak
Copy link
Contributor Author

daktak commented Jul 7, 2022

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

@supersonictw
Copy link
Member

supersonictw commented Jul 9, 2022

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.

@daktak
Copy link
Contributor Author

daktak commented Jul 9, 2022

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?

@supersonictw
Copy link
Member

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 8fff486.

npm run get-matrix-access

@daktak
Copy link
Contributor Author

daktak commented Jul 10, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants