maple3142 / saucenao-search-tgbot

A telegram bot enable you to search SauceNAO in telegram.
34 stars 15 forks source link

Not Working #8

Closed soulspark666 closed 4 years ago

soulspark666 commented 4 years ago

I tried to deploy it as it is told but it is showing some errors. error

Please Help

maple3142 commented 4 years ago

You have to correctly configure your .env file first:

SAUCENAO_APIKEY=
TG_TOKEN=
HOST=127.0.0.1
WEBHOOK_URL=
DEBUG=saucenao-tg:*
DATABASE_URL=
MINIUM_SIMILARITY=50
MAX_RESULT_COUNT=3

It is because your WEBHOOK_URL is empty, and it has to be some URL that is publicly accessible through the Internet. For example, http://your.domain.com or http://123.45.67.89 is okay.

soulspark666 commented 4 years ago

Will 127.0.0.1 work as WEBHOOK_URL?? Can you please elaborate what can be used as WEBHOOK_URL??

_Is the bot that you have given (@SauceNAO_Searchbot), working???

maple3142 commented 4 years ago

Will 127.0.0.1 work as WEBHOOK_URL??

http://127.0.0.1 is a valid WEBHOOK_URL but it won't work since 127.0.0.1 points to your local computer. WEBHOOK_URL should be an address that can be used to connect to the server on your computer.

soulspark666 commented 4 years ago

Can https://doc-robot.000webhostapp.com/ be used as WEBHOOK_URL??? If not what can be used!!

maple3142 commented 4 years ago

WEBHOOK_URL should points to a server running this Telegram bot, and the URL you provided is a free PHP hosting, so it won't work. I don't know where would you host this bot.

soulspark666 commented 4 years ago

I am running it on my pc. and trying to access it via my telegram. Please Can you give proper instructions on where I can deploy it???

soulspark666 commented 4 years ago

Can you tell me if @SauceNAO_Search_bot is working?? Because last time I tried it, it did not give any reply.

maple3142 commented 4 years ago

Can you tell me if @SauceNAO_Search_bot is working??

Yes, it is working.

soulspark666 commented 4 years ago

I am running it on my pc. and trying to access it via my telegram. Please Can you give proper instructions on where I can deploy it???

maple3142 commented 4 years ago

I would recommend you to do some research in "Whats is server, ip, domain, http...", since it is too hard to explain these things to people who without these concepts.

maple3142 commented 4 years ago

Besides, there is another way to easily run your bot on your PC, but it is less efficient. Simple replace this line with polling: true, and it should work.

soulspark666 commented 4 years ago

I would recommend you to do some research in "Whats is server, ip, domain, http...", since it is too hard to explain these things to people who without these concepts.

I am trying to deploy it on heroku, so what should I add in the WEBHOOK_URL now.

I am little aware of server, ip, and domain, but I am still new to this. Please help me.

soulspark666 commented 4 years ago

Besides, there is another way to easily run your bot on your PC, but it is less efficient. Simple replace this line with polling: true, and it should work.

I tried this sollution. Here is the output to it, but I was not getting answers to it.

C:\Users\anime\Desktop\New Pull\saucenao-search-tgbot>yarn start
yarn run v1.19.1
$ tsc && node dist/index.js
Unhandled rejection Error: EFATAL: WebHook and Polling are mutually exclusive
    at TelegramBot.openWebHook (C:\Users\anime\Desktop\New Pull\saucenao-search-tgbot\node_modules\node-telegram-bot-api\src\telegram.js:433:29)
    at Object.<anonymous> (C:\Users\anime\Desktop\New Pull\saucenao-search-tgbot\dist\index.js:19:5)
    at Module._compile (internal/modules/cjs/loader.js:777:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:840:10)
    at internal/main/run_main_module.js:17:11

(node:10588) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14)
(node:10588) 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:10588) [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.
  saucenao-tg:info 695797195 {
  message_id: 13,
  from: {
    id: 695797195,
    is_bot: false,
    first_name: 'Soul',
    last_name: 'Spark',
    username: 'soul_spark',
    language_code: 'en'
  },
  chat: {
    id: 695797195,
    first_name: 'Soul',
    last_name: 'Spark',
    username: 'soul_spark',
    type: 'private'
  },
  date: 1571145035,
  photo: [
    {
      file_id: 'AgADBQADM6kxGzgfMFXbyTQSg2KmOc6m-TIABAEAAwIAA20AA0SlBAABFgQ',
      file_size: 25890,
      width: 210,
      height: 320
    },
    {
      file_id: 'AgADBQADM6kxGzgfMFXbyTQSg2KmOc6m-TIABAEAAwIAA3gAA0WlBAABFgQ',
      file_size: 134068,
      width: 525,
      height: 800
    },
    {
      file_id: 'AgADBQADM6kxGzgfMFXbyTQSg2KmOc6m-TIABAEAAwIAA3kAA0KlBAABFgQ',
      file_size: 273302,
      width: 788,
      height: 1200
    }
  ]
} +0ms
  saucenao-tg:info 695797195 https://api.telegram.org/file/bot952510669:AAHIdNbDlVNpkaqnv0xI1bjGU4OSYttOc1o/photos/file_1.jpg [
  {
    header: {
      similarity: '92.57',
      thumbnail: 'https://img1.saucenao.com/res/pixiv/7517/75174343_p0_master1200.jpg?auth=BNPYWHQBNhostuShYSSXWg&exp=1571148636',
      index_id: 5,
      index_name: 'Index #5: Pixiv Images - 75174343_p0_master1200.jpg'
    },
    data: {
      ext_urls: [Array],
      title: '4月のウサギ',
      pixiv_id: 75174343,
      member_name: 'Renian@日-西I40b',
      member_id: 760140
    }
  },
  {
    header: {
      similarity: '91.47',
      thumbnail: 'https://img3.saucenao.com/booru/6/4/643aa26a99fbe0cb02125a903e1a8eeb_0.jpg',
      index_id: 9,
      index_name: 'Index #9: Danbooru - 643aa26a99fbe0cb02125a903e1a8eeb_0.jpg'
    },
    data: {
      ext_urls: [Array],
      danbooru_id: 3534066,
      gelbooru_id: 4772663,
      creator: 'rednian',
      material: 'original',
      characters: '',
      source: 'https://i.pximg.net/img-original/img/2019/06/11/19/18/11/75174343'
    }
  },
  {
    header: {
      similarity: '59.65',
      thumbnail: 'https://img1.saucenao.com/res/pixiv/7579/75794085_p0_master1200.jpg?auth=6EDVkCu-9KwLXBjqJNIrQw&exp=1571148636',
      index_id: 5,
      index_name: 'Index #5: Pixiv Images - 75794085_p0_master1200.jpg'
    },
    data: {
      ext_urls: [Array],
      title: 'らくがきせんが190717',
      pixiv_id: 75794085,
      member_name: 'ふぁるこまち',
      member_id: 5327274
    }
  },
  {
    header: {
      similarity: '59.74',
      thumbnail: 'https://img1.saucenao.com/res/pixiv/7606/manga/76067002_p17.jpg?auth=D2mnMasWrwI8j6S6RY6M1g&exp=1571148636',
      index_id: 5,
      index_name: 'Index #5: Pixiv Images - 76067002_p17.jpg'
    },
    data: {
      ext_urls: [Array],
      title: '万アツログ',
      pixiv_id: 76067002,
      member_name: 'さんふじ',
      member_id: 155135
    }
  },
  {
    header: {
      similarity: '59.58',
      thumbnail: 'https://img1.saucenao.com/res/mangadex/463/463357/Y37.jpg?auth=oIY0LiuH0zpjZg1dSpnYOQ&exp=1571148636',
      index_id: 37,
      index_name: 'Index #37: MangaDex - Y37.jpg'
    },
    data: {
      ext_urls: [Array],
      md_id: 463357,
      mu_id: 14017,
      mal_id: 13043,
      source: 'Johyou to Chuujitsu na Geboku',
      part: ' - Chapter 4',
      artist: 'KATSUMOTO Kasane',
      author: 'KATSUMOTO Kasane'
    }
  },
  {
    header: {
      similarity: '59.56',
      thumbnail: 'https://img3.saucenao.com/madokami/Manga/I/IT/ITOS/Itoshikute Nikui Hito/Itoshikute Nikui Hito (Complete).zip/Itoshikute Nikui Hito vol01 ch01[SMS]/016.jpg',
      index_id: 36,
      index_name: 'Index #36: Madokami (Manga) - 016.jpg'
    },
    data: {
      ext_urls: [Array],
      mu_id: 27542,
      source: 'Itoshikute Nikui Hito',
      part: 'Itoshikute Nikui Hito (Complete)',
      type: 'Manga'
    }
  }
] +2s

Capture

As you can see there is no reply from the bot but the script shows an answer.

maple3142 commented 4 years ago

Besides, there is another way to easily run your bot on your PC, but it is less efficient. Simple replace this line with polling: true, and it should work.

I tried this sollution. Here is the output to it, but I was not getting answers to it.

You should also remove these lines too.

As you can see there is no reply from the bot but the script shows an answer.

Have you configure DATABASE_URL?

maple3142 commented 4 years ago

I would recommend you to do some research in "Whats is server, ip, domain, http...", since it is too hard to explain these things to people who without these concepts.

I am trying to deploy it on heroku, so what should I add in the WEBHOOK_URL now.

I am little aware of server, ip, and domain, but I am still new to this. Please help me.

On heroku, WEBHOOK_URL and HOST should be your-app-name.herokuapp.com.

soulspark666 commented 4 years ago

Have you configure DATABASE_URL?

Nope, what should I add there!!??

maple3142 commented 4 years ago

Have you configure DATABASE_URL?

Nope, what should I add there!!??

You will need a PostgreSQL database, and fill in the corresponding values into the following string. postgresql://DB_USER:DB_USER_PASS@DB_URL:DB_PORT/DB_NAME

If you are using Heroku, it is much easier to do so. Simple install https://elements.heroku.com/addons/heroku-postgresql to your app, and find URI in the settings page of Heroku Postgres, then fill the value of URI into DATABASE_URL.

soulspark666 commented 4 years ago

While using the offline deployment, with your suggested changes, I added the postgresql url in the DATABASEURL part but it is still not replying to the sent images, similar to your @SauceNAO_Searchbot Capture

maple3142 commented 4 years ago

@SauceNAO_Search_bot works for me though: https://streamable.com/0w1uo

soulspark666 commented 4 years ago

@SauceNAO_Search_bot works for me though: https://streamable.com/0w1uo

I even tried sending it the same photo, still no reply!! Capture

soulspark666 commented 4 years ago

I tried to deploy the app on heroku, it is not replying not even to /start command!! Here is the log for deploying https://hastebin.com/gisepomofa.makefile

Please help me deploy it and I will be glad to make a beginners guide for this repo.

maple3142 commented 4 years ago

@SauceNAO_Search_bot works for me though: streamable.com/0w1uo

I even tried sending it the same photo, still no reply!! Capture

Could you use https://t.me/jsondumpbot and give me the result? If you think that is private, you could simply PM the result to me. I'd like to find what happens when you try to send photo to my bot.

I tried to deploy the app on heroku, it is not replying not even to /start command!! Here is the log for deploying hastebin.com/gisepomofa.makefile

Please help me deploy it and I will be glad to make a beginners guide for this repo.

README.md said that you should create a .env file and fill in some required info.

soulspark666 commented 4 years ago

I have created .env file and filled in all the info.. Capture As you can see in the image above

maple3142 commented 4 years ago

Your .env is probably not committed to heroku as it is in .gitignore. You may need to remove it from .gitignore. Besides, heroku's environment makes package managers to install production dependencies by default, so devDependencies are getting ignored. You could go to app setting page on heroku and add a Config Vars YARN_PRODUCTION and its value is false.

soulspark666 commented 4 years ago

I am still getting the same error, as the one I sent on your PM. 2019-10-16T04:19:55.808865+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="//bot9525:AAHIdNbDlVNpka1bjGU4OSYttOc1o" host=saucenao.herokuapp.com request_id=f0d1d632-cae5-470c-b8ea-9becc4653086 fwd="91.108.6.119" dyno= connect= service= status=503 bytes= protocol=https

As I searched for solutions I came across this. Is this, the solution to my problem or there is something else.

I checked my postgresql database. There are no connections till now Screenshot_2019-10-16 postgresql-flexible-70497 Heroku Data

This is what is there in my .gitignore now.

maple3142 commented 4 years ago

This is what is there in my .gitignore now.

.env is still being ignored...

soulspark666 commented 4 years ago

Removed that too

Here is my file structure at heroku:

Running bash on ⬢ saucenao... up, run.8148 (Free)

~ $ ls -al
total 84
drwx------   6 u22500 dyno  4096 Oct 16 07:09 .
drwxr-xr-x  15 root   root  4096 Sep 23 08:55 ..
-rw-------   1 u22500 dyno   401 Oct 16 06:54 .env
-rw-------   1 u22500 dyno  1044 Oct 16 06:54 .gitignore
drwx------   5 u22500 dyno  4096 Oct 16 06:55 .heroku
drwx------   2 u22500 dyno  4096 Oct 16 06:54 .profile.d
-rw-------   1 u22500 dyno   616 Oct 16 06:54 README.md
-rw-------   1 u22500 dyno    81 Oct 16 06:54 init.sql
drwx------ 111 u22500 dyno  4096 Oct 16 06:55 node_modules
-rw-------   1 u22500 dyno   556 Oct 16 06:54 package.json
drwx------   2 u22500 dyno  4096 Oct 16 06:54 src
-rw-------   1 u22500 dyno   132 Oct 16 06:54 tsconfig.json
-rw-------   1 u22500 dyno 34090 Oct 16 06:54 yarn.lock
soulspark666 commented 4 years ago

Also there is some settings called Webhook in heroku Screenshot_2019-10-16 saucenao · Webhooks Heroku

Do I have to do something here!!??

maple3142 commented 4 years ago

Also there is some settings called Webhook in heroku Screenshot_2019-10-16 saucenao · Webhooks Heroku

Do I have to do something here!!??

No, it has nothing to do with this at all.

soulspark666 commented 4 years ago

Now the bot is replying to my messages (/start and /set) but its not giving results to me. Similar to what was happening to your bot yesterday!

Heroku Logs

maple3142 commented 4 years ago

Follow this and run heroku psql -a YOUR_APP_NAME -c "CREATE TABLE userdata (uid VARCHAR(20),min_similarity int,max_result_count int);"

soulspark666 commented 4 years ago

Thanks man, its now working. I will push a PR regarding a detailed deployment on heroku for noobs like me, so that other people can also use this app without any error.