Giter Club home page Giter Club logo

Comments (20)

emirn avatar emirn commented on July 3, 2024

Hi Alberto, congrats on making first steps as programmer! Seems like you missing something in the config.js file. Make sure that all ' or " have the matching symbol (to close it).

from google_sheet_reader_bot.

albo94 avatar albo94 commented on July 3, 2024

Thank you emirn for your quick answer!
I've just checked what you asked me but it seems all okay:

module.exports = {
'TelegramProductionURL': 'https://guilizzoni.herokuapp.com', // do not forget trailing "/" !!
'TelegramToken': '12345-sometoken', // Telegram token
'googleSheetKey': 'https://docs.google.com/spreadsheets/d/SOMEKEYHERE/pubhtml', // the key of the google sheet (should be public!), extract key from the google sheet doc public url
"confTimeZone": "Europe/Berlin" // time zone of the conference in the form like "Europe/Berlin", see http://momentjs.com/timezone/
}

Thank you again

Alberto

from google_sheet_reader_bot.

emirn avatar emirn commented on July 3, 2024

Alberto, thank you for the code sample.
Important: for security purposes I've edited your reply and changed your google sheet key and Telegram token with sample text.
I would regenerate Telegram bot key anyway to avoid issues with the security (if someone saw your telegram secret key then she/he can use your bot instead of you. You should keep this key (token) private.

Your code seems to be OK except that you should change
https://guilizzoni.herokuapp.com to https://guilizzoni.herokuapp.com/ (with / symbol at the end)

from google_sheet_reader_bot.

emirn avatar emirn commented on July 3, 2024

You may also try this (if you are running the bot on Cloud9):
Change
bot = new Bot(config.TelegramToken, { polling: true });
to this (it will set the webhook callback address to your cloud9 ip address
bot = new Bot(config.TelegramToken, { polling: true }); bot.setWebHook("https://" + process.env.IP + ":" + process.env.PORT + "/" + bot.token );

from google_sheet_reader_bot.

albo94 avatar albo94 commented on July 3, 2024

As you said me, I've just corrected:

https://guilizzoni.herokuapp.com/

and I changed file "bot.js" in this way:

if(process.env.NODE_ENV === 'production') {
bot = new Bot(config.TelegramToken);
bot.setWebHook(config.TelegramProductionURL + bot.token);
}
else {
bot = new Bot(config.TelegramToken, { polling: true }); bot.setWebHook("https://" + process.env.IP + ":" + process.env.PORT + "/" + bot.token );
}

But these are the results in the terminal window:

Unhandled rejection Error: 400 {"ok":false,"error_code":400,"description":"Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 or 8443"}
at /home/ubuntu/workspace/node_modules/node-telegram-bot-api/src/telegram.js:136:15
at tryCatcher (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:507:31)
at Promise._settlePromiseAt (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:581:18)
at Promise._settlePromises (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:697:14)
at Async._drainQueue (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues as _onImmediate
at processImmediate as _immediateCallback
Unhandled rejection Error: 409 {"ok":false,"error_code":409,"description":"Conflict: terminated by other long poll or web hook"
at /home/ubuntu/workspace/node_modules/node-telegram-bot-api/src/telegramPolling.js:72:15
at tryCatcher (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:507:31)
at Promise._settlePromiseAt (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:581:18)
at Promise._settlePromises (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:697:14)
at Async._drainQueue (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues as _onImmediate
at processImmediate as _immediateCallback}

from google_sheet_reader_bot.

emirn avatar emirn commented on July 3, 2024

Have you tried to deploy it to Heroku? Cloud9 has the limitations on the ports used to run the node.js app as it is intended for dev purposes only. So please try to deply to Heroku, is it working there?

from google_sheet_reader_bot.

albo94 avatar albo94 commented on July 3, 2024

I'm sorry but I don't know how to deploy it to Heroku

from google_sheet_reader_bot.

albo94 avatar albo94 commented on July 3, 2024

Hi,
thank you for all your assistance!
Today I’ve just tried to deploy the app to Heroku. I say you again that I’m not a programmer, so I’ve tried to do these things that I saw on Heroku website:

  1. I installed “Heroku toolbelt”
  2. I logged in my account
  3. in Heroku web page I connected my app “mat-ban” to my repository in Github “albo94/google_sheet_reader_bot”
  4. in my repository in Github I copied “config.js.example” into “config.js” and I changed the parameters you explained me in the guide (telegram key, google key,…)
  5. I went to Heroku console and I wrote “git add .” , “git commit -am "make it better” and “git push heroku master”
    Now I don’t know what else I’ve to do to run my application

Thank you for your time and help

Alberto

from google_sheet_reader_bot.

emirn avatar emirn commented on July 3, 2024

Hi Alberto, great! Deploying to heroku is really next big step!
Seems like you did all things right. Once you called git push heroku master it should be deployed and run automatically.
Check the status of the app using the heroku logs command heroku logs -t and it will show live logs from your node.js app (the telegram bot is just a node.js app that responds to requests from Telegram network).

from google_sheet_reader_bot.

emirn avatar emirn commented on July 3, 2024

Try to run
heroku logs -t
and then try to send something to your bot. So the Telegram bot will talk to your app and you should be able to see errors in the log (will be displayed in the console in live mode)

from google_sheet_reader_bot.

albo94 avatar albo94 commented on July 3, 2024

Unfortunately I always obtain the same error:

2016-08-20T14:43:41.809346+00:00 heroku[router]: at=info method=POST path="/240357515:AAHAre71NZtGulhKW7jXk_Svxk--GSp6tH4" host=mat-ban.herokuapp.com request_id=dcd34792-8c9a-4d2c-8d65-cf4f6bfcb449 fwd="149.154.167.229" dyno=web.1 connect=0ms service=59ms status=200 bytes=196
2016-08-20T14:43:41.947157+00:00 app[web.1]: Error: null
2016-08-20T14:43:41.947192+00:00 app[web.1]: Status code: 400

from google_sheet_reader_bot.

emirn avatar emirn commented on July 3, 2024

you need to debug your code. stop heroku app.
then run cloud9 app using menu Run - Debug
Set the breakpoint (click on the left near the line where it should stop) right after the line with bot started..
Then it will stop on this line and you may go line by line using Run - Step Over from menu.

The issue is that it is not clear which line causes this error message (Error: null)

from google_sheet_reader_bot.

albo94 avatar albo94 commented on July 3, 2024

I selected show debugger at break and I run it
but I haven't found the line with bot started so I didn't set the breakpoint
is bot started in "bot.js"?

from google_sheet_reader_bot.

albo94 avatar albo94 commented on July 3, 2024

Hi Emirn,
I’m sorry but I think I haven’t understood some of your previous steps:
(referring to your initial simple guide)

  1. I create Google Sheet with data (OK!)
  2. I publish it to web and I obtain a key (OK!)
  3. I create an app on Heroku called “ban20”; now I’ve some doubts: 1) I just have to create the app and nothing else, or I’ve to connect the app with my repository in Github “albo94/google_sheet_reader_bot”? 2) Do I need to deploy it to Heroku or not? (The first time I’ve done it, I’ve just created the app and nothing else..is it ok?)
  4. I create an account in c9.io and I create a Node.js workspace called again “ban20”; now, in the process of creation, I put in an option field called “Clone from Git” the string “[email protected]:albo94/google_sheet_reader_bot.git”…..is it ok?
  5. I create a new telegram bot with BotFather and I obtain a telegram key (OK!)
  6. in Cloud9 website, I copy config.js.example into config.js and I replace my keys (OK!)
  7. in a terminal windows in Cloud9 website, I write these commands: nam install, git add ., git commit -m “initial version”, git push
  8. always in the same terminal windows (in Cloud9 website), I write the last command node .
  9. I open the telegram bot and I write Hi

I write you all "my" detailed guide because maybe I haven't understood something and I commit a banal error because it seems strange to me that I've so many problems following your guide.

Thank you again for all your help!

Alberto

from google_sheet_reader_bot.

emirn avatar emirn commented on July 3, 2024

All seems to be right and that is why can't advise any particular thing except placing debugger command into the code (like this) so node.js will stop the console where you may type n to go line by line and find where it causes the crash.

about Heroku and Cloud9: you may run the app on Cloud9 but it is for development purposes. For production you should deploy to Heroku (it hosts the production server app).

from google_sheet_reader_bot.

emirn avatar emirn commented on July 3, 2024

you don't have to connect Heroku to Github because Heroku itself is the Git. For some developers who store the code in Github this connection makes autosync of the code from Github to Heroku.
Actually you may use Heroku to store the code too using git (it just don't have issues, discussion and interface to edit files on web)

from google_sheet_reader_bot.

albo94 avatar albo94 commented on July 3, 2024

Referring to your second message, I deleted the connection between Github and Heroku and I deployed again to Heroku. When I write git push heroic master, the result is:

error: src refspec master does not match any.
error: failed to push some refs to 'https://git.heroku.com/ban20.git'

now I try to do what you explained me in the first message
thank you

from google_sheet_reader_bot.

albo94 avatar albo94 commented on July 3, 2024

now I put the debugger in the bot.js file and it seems all right (from beginning to end)
I'm so sorry but which file is my source code?

from google_sheet_reader_bot.

emirn avatar emirn commented on July 3, 2024

sorry for delays - need to try to reproduce it! Don't have any ideas - I suggest you to find JS developer who could check your code live.
I've checked the telegram bot which is running on Heroku based on this code and it is all works fine still but maybe something was changed in the npm packages used and so on

from google_sheet_reader_bot.

albo94 avatar albo94 commented on July 3, 2024

thank you again for all your help and your time
i'll try another way
thanks

alberto

from google_sheet_reader_bot.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.