Telegram-Bot-Node / Nikoro

A plugin-based, all-in-one, Telegram Bot written in Node.js
MIT License
56 stars 28 forks source link

Errors in Google Search, Google Images and YouTube #129

Closed koodoxz closed 6 years ago

koodoxz commented 6 years ago

Hi

How can i enable plugin google search? I've searched the wiki but did not find it. if i enable the plugin and show error like this :

warn: [PluginManager] Failed to initialize plugin GoogleSearch.

Thanks

crisbal commented 6 years ago

Hello, as you can see from here (as of right now I am not sure it is documented) https://github.com/crisbal/Telegram-Bot-Node/blob/es6/src/plugins/GoogleSearch.js#L23 you need to provide the Google API Key and the Google CX Key that you can get using Google API Console (https://console.cloud.google.com/?pli=1) in the config.json file

crisbal commented 6 years ago

Ok I just checked and it seems the issues is on our side. I will keep you updated when we fix the problem

CapacitorSet commented 6 years ago

By the way, @koodoxz do you have a complete log? Are there other lines explaining the error?

koodoxz commented 6 years ago

Hi

@CapacitorSet Here is the log when in Firstrun

and here are the full log

npm run bot

telegram-bot-node@1.0.0 bot /home/Telegram-Bot-Node node src/Bot.js

info: [Bot] Instance created. node-telegram-bot-api deprecated Events new_chat_participant,left_chat_participant are deprecated. See the updated list of events: https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events src/PluginManager.js:35:17 warn: [PluginManager] Error: Cannot find module 'this.google-search' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (/home/Telegram-Bot-Node/src/plugins/GoogleSearch.js:2:22) warn: [PluginManager] Failed to initialize plugin GoogleSearch. warn: [PluginManager] Error: Cannot find module 'youtube-api' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (/home/Telegram-Bot-Node/src/plugins/YouTube.js:2:17) warn: [PluginManager] Failed to initialize plugin YouTube. warn: [PluginManager] Some plugins couldn't be loaded. info: [Bot] Plugins loaded. info: [Bot] Permissions configured. info: [Bot] The bot is online! ^Cwarn: [Bot] Shutting down, reason: SIGINT received info: [Bot] Stopping safely all the plugins... info: [Bot] All plugins stopped correctly.

CapacitorSet commented 6 years ago

I pushed 544c09b, that should fix it. Can you git pull and try again?

CapacitorSet commented 6 years ago

Actually, I just pushed another bugfix in 1b2d1ca - you should try pulling once again, if you already did.

koodoxz commented 6 years ago

Hi @CapacitorSet

thank you for fast respon, i think still cant find module for google search, here is the log

warn: [PluginManager] Error: Cannot find module 'google-search' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (/home/Telegram-Bot-Node/src/plugins/GoogleSearch.js:2:22) warn: [PluginManager] Failed to initialize plugin GoogleSearch.

CapacitorSet commented 6 years ago

Oh, in that case, you'll just need to install it: npm install google-search.

koodoxz commented 6 years ago

Ok noted, let me try it, thanks

koodoxz commented 6 years ago

Hi

just try to running, but still found this error

info: [Bot] Plugins loaded. info: [Bot] Permissions configured. info: [Bot] The bot is online! error: [Bot] TypeError: Cannot read property 'sendMessage' of undefined at /home/Telegram-Bot-Node/src/plugins/GoogleSearch.js:49:17 at IncomingMessage. (/home/Telegram-Bot-Node/node_modules/google-search/lib/google-search.js:64:9) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) warn: [Bot] Shutting down, reason: Uncaught exception info: [Bot] Stopping safely all the plugins... info: [Bot] All plugins stopped correctly.

CapacitorSet commented 6 years ago

Hm. Try pulling and running it now?

koodoxz commented 6 years ago

Thanks for the quick respons may i ask you again, how to define call command to google search and google image in bot?

CapacitorSet commented 6 years ago

Simply edit src/plugins/GoogleSearch.js and src/plugins/ImageSearch.js.

For example, at line 34 of GoogleSearch.js you will find if (command !== "google") return;, just change that command.

koodoxz commented 6 years ago

while i put help on bot, its show something like this

/help Google Images search: Search for images on Google. Google: Search on Google.

/help Google Images search Google - Search on Google. /google query

/help google Google - Search on Google. /google query

Edit :

found the script that you said before

thanks

CapacitorSet commented 6 years ago

Thank you for your report. I'm closing this issue as fixed.

koodoxz commented 6 years ago

one moment please

i found another error on youtube plugin, i think is the same error with google search

info: [Bot] Plugins loaded. info: [Bot] Permissions configured. info: [Bot] The bot is online! error: [Bot] TypeError: Cannot read property 'sendMessage' of undefined at /home/Telegram-Bot-Node/src/plugins/YouTube.js:43:17 at Request._callback (/home/Telegram-Bot-Node/node_modules/google-auth-library/lib/transporters.js:106:7) at Request.self.callback (/home/Telegram-Bot-Node/node_modules/google-auth-library/node_modules/request/request.js:187:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (/home/Telegram-Bot-Node/node_modules/google-auth-library/node_modules/request/request.js:1044:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at IncomingMessage. (/home/Telegram-Bot-Node/node_modules/google-auth-library/node_modules/request/request.js:965:12) at emitNone (events.js:91:20) warn: [Bot] Shutting down, reason: Uncaught exception info: [Bot] Stopping safely all the plugins... info: [Bot] All plugins stopped correctly.

CapacitorSet commented 6 years ago

Oh shit, indeed. I also fixed that.

I ran a quick check against the other plugins, there shouldn't be any more issues like that.

koodoxz commented 6 years ago

Well Noted, Thank you for the quick respons :1st_place_medal:

koodoxz commented 6 years ago

Hi i found error again on plugin youtube, should i paste here or i open new issue?

CapacitorSet commented 6 years ago

No way to tell without seeing the problem :)

If you think it's the same type of error, post on this issue; otherwise, open a new issue.

Anyway, I'm going to bed now. It's 4 AM here in Italy, so it might be a while before @crisbal or I can take a look.

Il 26/set/2017 04:02 AM, "koodoxz" notifications@github.com ha scritto:

Hi i found error again on plugin youtube, should i paste here or i open new issue?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/crisbal/Telegram-Bot-Node/issues/129#issuecomment-332064304, or mute the thread https://github.com/notifications/unsubscribe-auth/AI21FUV9fiz0UpNP67L5CrmuU6EhtNf_ks5smFtDgaJpZM4PiVfa .

koodoxz commented 6 years ago

ok, take your time, Have a good rest :1st_place_medal:

CapacitorSet commented 6 years ago

@koodoxz, do you have updates on the issue?

koodoxz commented 6 years ago

Hi @CapacitorSet sorry for late reply

here is the log when i try to find song on youtube with 32 characters including space ex : /yt andra and the backbone - hitamku also with this one, /yt asd it wont work

info: [Bot] Plugins loaded. info: [Bot] Permissions configured. info: [Bot] The bot is online! error: [Bot] Unhandled rejection at Promise Promise { _bitField: 18087936, _fulfillmentHandler0: { Error: ETELEGRAM: 400 Bad Request: can't parse entities in message text: Can't find end of the entity starting at byte offset 92 at BaseError (/home/Telegram-Bot-Node/node_modules/node-telegram-bot-api/src/errors.js:10:5) at TelegramError (/home/Telegram-Bot-Node/node_modules/node-telegram-bot-api/src/errors.js:56:5) at request.then.err (/home/Telegram-Bot-Node/node_modules/node-telegram-bot-api/src/telegram.js:213:15) at tryCatcher (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:693:18) at Async._drainQueue (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/async.js:133:16) at Async._drainQueues (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/async.js:143:10) code: 'ETELEGRAM', response: IncomingMessage { _readableState: [Object], readable: false, domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, socket: [Object], connection: [Object], httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, headers: [Object], rawHeaders: [Object], trailers: {}, rawTrailers: [], upgrade: false, url: '', method: null, statusCode: 400, statusMessage: 'Bad Request', client: [Object], _consuming: true, _dumped: false, req: [Object], request: [Object], toJSON: [Function: responseToJSON], caseless: [Object], read: [Function], body: [Object] } }, _rejectionHandler0: undefined, _promise0: undefined, _receiver0: undefined, _cancellationParent: Promise { _bitField: 16777216, _fulfillmentHandler0: { Error: ETELEGRAM: 400 Bad Request: can't parse entities in message text: Can't find end of the entity starting at byte offset 92 at BaseError (/home/Telegram-Bot-Node/node_modules/node-telegram-bot-api/src/errors.js:10:5) at TelegramError (/home/Telegram-Bot-Node/node_modules/node-telegram-bot-api/src/errors.js:56:5) at request.then.err (/home/Telegram-Bot-Node/node_modules/node-telegram-bot-api/src/telegram.js:213:15) at tryCatcher (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:693:18) at Async._drainQueue (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/async.js:133:16) at Async._drainQueues (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/async.js:143:10) code: 'ETELEGRAM', response: [Object] }, _rejectionHandler0: [Function], _promise0: undefined, _receiver0: undefined, _cancellationParent: undefined, _branchesRemainingToCancel: 1, _onCancelField: undefined } } with reason Error: ETELEGRAM: 400 Bad Request: can't parse entities in message text: Can't find end of the entity starting at byte offset 92 at BaseError (/home/Telegram-Bot-Node/node_modules/node-telegram-bot-api/src/errors.js:10:5) at TelegramError (/home/Telegram-Bot-Node/node_modules/node-telegram-bot-api/src/errors.js:56:5) at request.then.err (/home/Telegram-Bot-Node/node_modules/node-telegram-bot-api/src/telegram.js:213:15) at tryCatcher (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/promise.js:693:18) at Async._drainQueue (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/async.js:133:16) at Async._drainQueues (/home/Telegram-Bot-Node/node_modules/bluebird/js/release/async.js:143:10)

But if i want to search normal song : /yt alicia kara - stay and the another songs is no issue

CapacitorSet commented 6 years ago

I think I got it: when the title contains ], Telegram complains because it thinks it's closing the Markdown link. However, I'll look at it tomorrow.

Can you please open a new issue? It's a different problem than the one discussed here.

koodoxz commented 6 years ago

ok let me open in new issue