Open roshanconnor123 opened 4 years ago
- Is it possible to add dedupe feature in Tg bot as well?
- Is it possible to add snap2html and tree function in bot as well?
It is...However I don't want add too much functions to Tg bot. For me, bot is normally used to copy folders others shared. To do other things, using command line is more comfortable.
But a PR is always welcome, if anyone is insterested...
Also if its alright with you,could you please explain how aria2 works (in brief)
I made a screen record earlier: https://drive.google.com/file/d/1lzN7R9Klw66C5UttUUDN3_EsN3pNs62q/view
Feel free to ask if the record isn't clear.
I added instructions for Windows as well as Android system in readme (English Repo) In case if you want to check it out
Thank you for your contribution👍, I added it to readme: https://github.com/iwestlin/gd-utils/commit/9defd5b59bb57de1f7fca44412f225cc16c666f7
Thank you for your response Just tested aria2,its very good About the bot thing..If i wanted to do add those features for my personal use Which file should i be editing ? Thanks for all the insights
Which file should i be editing?
You could add two buttons, for example snap2html
and tree2html
here:
https://github.com/iwestlin/gd-utils/blob/9defd5b59bb57de1f7fca44412f225cc16c666f7/src/tg.js#L137
then handle the callback data of user clicking those buttons here: https://github.com/iwestlin/gd-utils/blob/9defd5b59bb57de1f7fca44412f225cc16c666f7/src/router.js#L64
then call tree_tpl
or snap2html
function to generate html file, and send the file to tg api by:
https://core.telegram.org/bots/api#sending-files (there are some limitations)
send file to bot can be a little tricky, so I wrote a function, tested good:
const fs = require('fs')
const FormData = require('form-data') // need to run `npm i form-data` first
function send_file ({file_path, chat_id}) {
const url = `https://api.telegram.org/bot${tg_token}/sendDocument`
const form = new FormData()
form.append('chat_id', chat_id)
form.append('document', fs.createReadStream(file_path))
axins.post(url, form, {
headers: form.getHeaders()
}).then(r => console.log(r.data)).catch(console.error)
}
// use like this:
send_file({chat_id, file_path: 'html file location'})
Thank you
I will try to add this my own to the bot
I am sure i will fail haha
Will update here
Thanks
also..i should add the above function in gd.js
yes?
better put it in tg.js
, because it used a global variable tg_token
then export this function in module.exports = {send_file}
and require and use it in router.js
(handle the callback data part)
Hi there, Hope you are doing well I have a feature Request for Tg bot
snap2htm
l andtree
function in bot as well? Like,If i run my command this wayCan it reply to me with a
Index.html
FileThank you
PS: I added instructions for Windows as well as Android system in readme (English Repo) In case if you want to check it out
Thanks once again for this wonderful tool