Code Monkey home page Code Monkey logo

Comments (8)

Jzarecta avatar Jzarecta commented on May 22, 2024

I want to learn how the module handles the declared commands assigned by botfather and be able to route them to the desired action.

from python-telegram-bot.

leandrotoledo avatar leandrotoledo commented on May 22, 2024

Hi @Jzarecta, it doesn't. Bot API doesn't provide methods to get declared commands, you have to create your own handlers parsing text messages when polling updates from their servers. Have a look at examples folder from this repository, hopefully it will be a good start.

Feel free to reach out me for any further questions.

from python-telegram-bot.

Jzarecta avatar Jzarecta commented on May 22, 2024

Actually the example folder didn't gave me much insight. Perhaps I didnt read it right, but I was able to declare updates on the api, but that was it, the rest was a lonely def that supposely was the command to use, but it didnt work as expected. I had the following code:

def p(value):
    #Buscamos el API
    bitapeso=urllib2.urlopen("http://bitapeso.com/json/").read()
    jobject = json.loads(mxn, 'utf-8')
    val=jobject['mxn']
    if val == None:
        peso = float(val)
    else:
        peso = float(val) * value
    return peso.strip()

Maybe I miss something, or a lot.

from python-telegram-bot.

franciscod avatar franciscod commented on May 22, 2024

We could get the token from an env-var

from python-telegram-bot.

franciscod avatar franciscod commented on May 22, 2024

are these tests https://travis-ci.org/leandrotoledo/python-telegram-bot/jobs/87105084 from #87 failing due to a testing token issue?

from python-telegram-bot.

franciscod avatar franciscod commented on May 22, 2024

there are a lot of hardcoded things, right? message/file ids, message contents

from python-telegram-bot.

leandrotoledo avatar leandrotoledo commented on May 22, 2024

The way it's writen atm I'm the only one who can see the bot interation (as it sends messages to chat_id corresponding my telegram user). @jh0ker has suggested a public channel so anyone planning to submit a feature can see the results for their thats. In order to accomplish that we would need to change some tests and avoid hardcoding as @franciscod mentioned. I'll spend some time on it this week.

from python-telegram-bot.

leandrotoledo avatar leandrotoledo commented on May 22, 2024

Seems like the amount of efforts to have the same result does justify this rework right now.
The token and the chat_id are now shared on tests/base.py so anyone can run tests. Until we have a better (and easier way) to emulate client requests or generic tests I'd say to keep the way we have.

from python-telegram-bot.

Related Issues (20)

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.