telegram-bot | Telegram Bot using AWS API Gateway and AWS Lambda | Bot library
kandi X-RAY | telegram-bot Summary
kandi X-RAY | telegram-bot Summary
A tutorial on creating a Node.js Telegram bot using AWS Lambda with AWS API Gateway.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Processes the Commands .
- Send a message to a chat
telegram-bot Key Features
telegram-bot Examples and Code Snippets
Community Discussions
Trending Discussions on telegram-bot
QUESTION
This is my first time interacting with Google API and I'm using python3.9 with this library Python Telegram Bot I want to access a user Google API Calendar via a telegram bot and I can't seem to find any article to guide me through it. My key problem (I think) is redirecting the success authorization flow back to telegram bot.
This is what I have in mind:
- In the telegram app, user send '/send' to bot
- Bot receive message and return a google an authorization link to user
- User clink on authorization link and allow access
- Bot receive authorization access and completes the Oauth flow
The problem lies betweeen step 3 and 4. A standard authorization link is
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=&redirect_uri=&scope=&state&access_type=offline
How do I send the authorization link back to my telegram bot? Should I create another API endpoint to receive that authorization link? Or can I send telegram api send_message() in the to redirect the success message to my bot.
Update 1
Thanks to CallMeStag, I manage to figure out a way to complete the oauth process. For people who faced the same problem, this is what I did Pre-requisite: Credentials is created in google console api - Web application. redirect_uri set as localhost:8000 (During development phase)
- User send '/send' to bot
- Bot receive message and return an authorization link ...
ANSWER
Answered 2022-Mar-29 at 06:44It's currently indeed not very straight forward for a PTB-application to listen for external updates (the auth verification in this cas) - see also this issue. Currently it might be easiest for you to set up a custom webhook application that runs in parallel to the Updater
- e.g. using flask/django/starlette/fastapi/…. Alternatively, if you're using webhooks for your bot anyway, you can patch the Updater
to do the job for you. Although that requires some manual work - see here for an example.
Once you are able to listen to updates coming from Google, handling them can be done via PTBs usual handler setup, specifically via the TypeHandler
or even a custom Handler
subclass - see this FAQ entry.
Regarding the redirect url: You'll want to redirect your user back to your bot, so you'll have to provide a link that does that. Bot.link
should probably do the trick.
Disclaimer: I'm currently the maintainer of python-telegram-bot
.
QUESTION
I'm working with Python Telegram Bot https://python-telegram-bot.readthedocs.io/
I'm trying to implement a bot function into a 3rd party listener, so when the handle_event() is fired, with a telegram username as parameter, the bot bans that member from the group. here we go with an example:
...ANSWER
Answered 2022-Mar-29 at 10:26Update
is a class and the property Update.effective_chat
can only be properly evaluated for instances of that class. If you want to make simple calls to the Bot API, you should instantiate an instance of the telegram.Bot
class and call its methods - in your case Bot.ban_chat_member
. Please see the Introduction to the API for a more detailed explanation of how to use the API methods.
QUESTION
I'm working with Python Telegram Bot https://python-telegram-bot.readthedocs.io/en/stable/telegram.chat.html and trying to build my first bot on telegram.
I've followed the example https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/chatmemberbot.py as a template
I want to add a functionality that if a user is not in the list, the bot should kick him out but I'm having some issues implementing this function. My code is as follows:
...ANSWER
Answered 2022-Mar-21 at 17:05Handler callbacks must have exactly two positional arguments - that's just how python-telegram-bot
is designed. That's why your first approach doesn't work.
Moreover, Chat.ban_member
is a bounded method, not a class/static method. Chat
is a class, not an instance of that class, so Chat.ban_member(user_id)
can't work either. You need an instance of the Chat
class to call that method. In your case probably update.chat_member.chat
or update.effective_chat
(the latter being a shortcut for the former).
Disclaimer: I'm currently the maintainer of python-telegram-bot
.
QUESTION
I see some bots acts regarding args passed to the bot. For example:
...ANSWER
Answered 2022-Mar-21 at 04:36I never tested it before but it seems you have it in documentation as deep linking.
start=something
should run command /start something
Link can use only start
or startgroup
QUESTION
How I can save a file from a stream or from an url in nodejs? I have a telegram bot that will get files from users. I'm able to get the file url or the stream but I'm not sure how to save it in a temporary directory before process.
Here is the link to the library I'm using
How I can proceed?Here is the code
...ANSWER
Answered 2022-Mar-19 at 11:28You can do this:
QUESTION
I am writing a small project related to userbots in telegram. I had a problem when trying to forward a message from a supergroup to another user, but when I try to forward messages from a regular chat, everything is successful. I found a similar question, but unfortunately bots are used there, not userbots.
Lib: pyrogram
Version: 1.4.8
my code:
...ANSWER
Answered 2022-Mar-16 at 16:28Firstly, the error you get is clear. The Session of your userbot has not yet met the group and cannot identify it based on its ID. You will have to receive any kind of update from that entity first.
See this FAQ entry: https://docs.pyrogram.org/faq/peer-id-invalid-error
Secondly, the group you are trying to forward from may have forwards restricted in its group settings. Since you can forward via an official client, this is likely not the case.
QUESTION
I develop a telegram bot using the python-telegram-bot module. I attempt to run a function without executing it using dispatcher.run_async(myfunction)
but how I can do a task for example sending a message from inside the dispatcher.run_async()
?
I have all the users id in my database. And this is the snippet of my code.
...ANSWER
Answered 2022-Mar-09 at 11:00Not sure if this is the intended way, but you can pass the bot the the function by passing it to run_async
:
QUESTION
is it possible to install copy protection in a telegram bot?
the bot sends docx files, images and text.
I would like to make it so that they cannot be copied but can be viewed. I couldn't find anything in the telegram bot api documentation, I can't Google it either.
the bot is written in node.js
. used the node-telegram-bot-api
library
For the third day I have been struggling with the question, suddenly who knows if it is possible at all. Maybe it can be done in some other way. For example, to raise a web server where you can watch content and send only links in the bot.
ANSWER
Answered 2022-Feb-24 at 12:35You can de-activate buttons like "Save As..." or "Share to..." by adding a protect_content
parameter. It is available for many methods, including sendMessage, sendPhoto, sendDocument.
Of course anything that can be viewed can also be copied in some way or another. Nonetheless it provides some protection.
QUESTION
I'm trying to make my first Telegram bot on Python. I use the python-telegram-bot, Flask, run it in Google Cloud Run. Locally on my machine everything works fine, when I deploy it (using Docker) to Google Cloud Run everything also works fine until the moment when Google Cloud Run stops the instance. That's what I see in Gloud Run logs:
...ANSWER
Answered 2022-Feb-24 at 07:51TBF, I'm not familiar with Google Cloud Run, but if I understand correctly the point is that you code will only be invoked when a request is made to the app, i.e. it's one of those "serverless" setups - is that correct?
If so: What updater.start_polling()
does is start a long running background thread that fetches updates continuously. To have your bot responsive 24/7 with this method, your script needs to run 24/7. Now the point of serverless setups is that your code only runs on demand, so for this hosting method a more reasonable approach would be to only invoke your code when your bot receives an update. This can achieved using a webhook instead of long polling. There is a section on this in the PTB wiki. See also this thread about AWS Lambda, which is similar AFAIK.
However one should note that stateful logic like ConversationHandler
is hard to realize in such setups: By default ConversationHandler
keeps track of the current state in memory, so the information is lost on shutdown of the process. You can use persistence to store the data, but I'm not sure how well this works with serverless setups - there might be race conditions if multiple updates come in at the same time.
So another idea would be to switch to a different hosting service that allows to run your process 24/7.
Disclaimer: I'm currently the maintainer of python-telegram-bot
.
QUESTION
I have been checking on forums(stack overflow, git, Telegram APIs) to check how could I extract contents from a pdf file which is sent by user? I have created Telegram bot using python's python-telegram-bot
library and as an efforts to try to solve my question, I had checked links eg: https://pypi.org/project/python-telegram-bot/ and https://python-telegram-bot.readthedocs.io/en/stable/index.html in search of functions but couldn't find anything there.
I did find methods to send a pdf file to user from bot and send a file from user to bot but there is nothing available where BOT can extract contents of pdf sent by user. Will be grateful if experts could guide me here.
...ANSWER
Answered 2022-Feb-23 at 14:59python-telegram-bot
is a library that provides a wrapper for the Telegram Bot API. As such, it provides all the methods from the API as well as auxiliary functionality to build chat bots in general, including downloading files sent by users. Extracting contents from a received PDF file after download is however far beyond the scope of this library.
Of course there are other libraries that provide such functionality and that can be used in combinantion with python-telgram-bot
. See e.g. camelot
.
Disclaimer: I'm currently the maintainer of python-telegram-bot
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install telegram-bot
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page