pythontelegrambotgroup | Unsorted

Telegram-канал pythontelegrambotgroup - >>> telegram.Bot()

10206

This group is for questions, answers and discussions around the python-telegram-bot library. Off-topic group: @pythontelegrambottalk | Website: https://python-telegram-bot.org

Subscribe to a channel

>>> telegram.Bot()

yeah surely you can fit everything you need to run a bot inside one file, as shown in the starting example you just tried

Читать полностью…

>>> telegram.Bot()

with enough certainty i can say ptb is far more complex then a single python file

Читать полностью…

>>> telegram.Bot()

Letsgo 😝

You need to set the read_timeout in get_file call, maybe concurrent_updates(True) and block=False can help if you bot get stuck in handling new updates

For progress, I don’t think you can get a real percentage. The server doesn’t expose any progress, get_file just blocks until it’s done. You could try to guess the path where the file is being written and watch its size grow, but I don’t know if tdlib writes it there incrementally or into a temp folder and moves it at the end. So that would be pretty hacky...

P.s.
For upload with a local api server you can pass directly the path (this doesn't need to match between container and host, but must be a valid path inside the container)
Here I don't think there is a simple way to get a percentage...

Maybe for small files you can pass open(.., "rb") ad o serve fp.tell() / file_size * 100

Читать полностью…

>>> telegram.Bot()

When you do get_file the file Is downloaded by the api server
When you call save_to_drive a copy Is performed

Читать полностью…

>>> telegram.Bot()

Hi Nandu 😋 Python Expert Please post code or tracebacks using a pastebin rather than via plain text or a picture. https://pastebin.com/ is quite popular, but there are many alternatives out there. Of course, for very short snippets, text is fine. Please at least format it as monospace in that case., we like to keep our groups readable and thus require long code to be in a pastebin.

⚠️ The code snippet(s) in your message have been moved to https://pastebin.poolitzer.eu/p/1I4eRw.py. Your original message will be deleted in a minute, please reply to this message with your query.

Читать полностью…

>>> telegram.Bot()

this time it woks because what i found by taking the copy paste a lot of thigns waht i found maybe the solution was, as the 101 in the continaer was writing the file in my host so what i found in my os i found a user of id 101 and 101 in my host was -> messagebus

sudo usermod -aG messagebus my_host_username
and then restart my machine and maybe this solve the problem fully, this line uppper cause the solution of the problem.
Can you say is this how this happens,

Читать полностью…

>>> telegram.Bot()

so i have still a confusion, here i am using bind -mount it means my docker container can directly read write on the folder i passed in my docker volume label in the compose, is this the right concept here?

so my confusion when i run the aigram's docker image it start a localhost:8081 so this server actually do download the file from telegram and keep save in my folder i passed in compose or the ptb code do download the file there?

Читать полностью…

>>> telegram.Bot()

so i was today messed up with my system with a lot of claud given permission related command run in my terminal and i found any way this is running in local bot api i did some now any way i found it say downloading, but i forget i even run 100 command today by copy pasteing now i need to found what i did maybe the problem was of user id 101.
The thing is maybe the contianer's user trying to save the file in my os file manager is this cause the permission error is this can be?

Читать полностью…

>>> telegram.Bot()

So What i understand for using aiogram's local bot api's docker and use PTB i need to only setup these,

(base_url, base_file_url, local_mode) i need to change this in my applicaiotn handler and then i need to give permission of my docker to run with bind-mount. will this the main logic there?

Читать полностью…

>>> telegram.Bot()

Host, there's no need of -s, the size isn't relevant. Btw i'd like to see the file permissions

Читать полностью…

>>> telegram.Bot()

from my host machine i eill run this but why ls -ls ?

Читать полностью…

>>> telegram.Bot()

why …botTOKEN//var… though

Читать полностью…

>>> telegram.Bot()

I also tried with claud the error it say i paste and i give back still claud free plan expired still not solve it yet 😅
Just for some information what i found this is happening due to some issue in permission error of file and it say ptb library cannot decide if htis is due to the permission error it thinks this is just http url path so it got problem it cannot solve this

http://localhost:8081/file/botTOKEN//var/lib/telegram-bot-api/TOKEN/documents/file_4.txt

Читать полностью…

>>> telegram.Bot()

Oh, hey! There's someone new joining our awesome community of Python developers ❤️ We have compiled a list of learning resources just for you:

• As Beginner
• As Programmer
• Official Tutorial
• Dive into Python
• Learn Python
• Computer Science Circles
• MIT OpenCourse
• Hitchhiker’s Guide to Python
• The @PythonRes Telegram Channel.
• Corey Schafer videos for beginners and in general
• Project Python

Читать полностью…

>>> telegram.Bot()

Are you trying to forward the message as yourself or as a bot in rich message text?

"

The Rich Text Editor is currently available to Telegram Premium users only. Why? Because otherwise, we'd have to call it the Poor Text Editor — and you don't want that.


"

https://telegram.org/blog/communities-editor-invisible-messages

Читать полностью…

>>> telegram.Bot()

excluding the Library itself of course!

i meant the part that I "have" to write/code.

Читать полностью…

>>> telegram.Bot()

Hello ^^
I'm new to PTB, coming from an older PHP based library, and have read through the tutorial section so far and managed to start the bot with the basic tutorial functions.

Am I under the wrong impression (or did i miss something) or are all commands and functions written in the one python file?

Читать полностью…

>>> telegram.Bot()

so here the problem was if i will use docker thta the server will store the path of the download file and my python's host if not keep the same folder structure there it will say file not found and as a result this will try to looks into the tg clound http url that cause the problem so in docker and host machine the /var/lib/telegrambotapi just need to match and the user id 101 need to be have permission here and it will solve this issue there sweet solution, btw i will check tomorrow other important thigns of how to send large file and what about any article here in ptb says i can say how much file mb left to download or upload?

Читать полностью…

>>> telegram.Bot()

Now i am little happy that my os is able to download files from the user large mb file also 🙏 PTB teams here, thanks @tmp905220 a lot you have solve a lot of confusion of me and solve a working way.

Now this is working, but now i think i dont know if my bot actually the local bot api will downlaod the big file maybe it will take 30 or 3000 seconds as the file size got increase so how and what should my code here to make the applicaiotn handler so that donwload it will not fails it will wait long time, and any way i can inform user every 10 seconds how much percentage or how much mb has been downloded or how much left to download there, btw i am using this i still found some timeout when downloading what values do you say to keep here and my percentage of download or upload here what to do?

https://pastebin.poolitzer.eu/p/1I4eRw.py

Читать полностью…

>>> telegram.Bot()

So finally i foudn when i will use local bot api of aigram's docker then

when i will do get_file() -> /var/lib/telegram-bot-api/<token>/documents/ here the file will download and save there a copy.

and then when i will do download_to_drive() -> this will actually save the file in my desired folder or Path place i will want.
so in the host system's /var/lib/telegram-bot-api/Token/docuemtns/*.files all fiels kept store in this folder always is this right always?

The path inside the container and the path on the host must be identical. 😅

so when i am in local bot api server, and i do .get_file() the file just keep saved in my os 's file manager the .save_to_drive is just optional() this actually not need righ?

Читать полностью…

>>> telegram.Bot()

get_file -> the server downloads the file to disk -> returns the absolute path as seen inside its own container -> PTB checks Path.exists() on that path

If the path exists where PTB runs, it just reads the file from disk and you’re done. If it doesn’t, PTB falls back to http://localhost:8081/file/bot<token>/<path>, but that doesn’t work either because in --local mode the server doesn’t serve files over HTTP. (If you set TELEGRAM_LOCAL=0, you would have same limits as online bot api)

So the Path returned by the api server in container must be the same of your host (where your bot Is running)

ls doesn't return any error, so I was asking you how you start your bot and with which user

Читать полностью…

>>> telegram.Bot()

Idk, try to figure out what you did

Anyway, the server writes the file fine, so writing isn’t the issue

Also, I think the “downloading” you saw was just Docker pulling the image

Читать полностью…

>>> telegram.Bot()

I was excepting a "no such file or directory" or somehow a symlink

Anyway this Is so strange... How do you start your bot? Can you try to run It as root or as user 101?

Using another container doesn't help too much...

Ye, the AI answer Is correct

Читать полностью…

>>> telegram.Bot()

ls -ls /var/lib/telegram-bot-api/TOKEN/documents/file_0.txt
12 -rw-r----- 1 messagebus messagebus 11245 Oct 25 18:10 /var/lib/telegram-bot-api/TOKEN/documents/file_0.txt

WHAT YOU HAVE UNDERSTAND BY THIS,

i am confused how and why the messagebus came here 😅
so i think the solution will be run local bot api in its own docker container and run my python ptb code in another docker container and use volume?

Ai say this:
When the container writes a file as user 101, your host shows the owner as whatever name it has for 101, and that’s messagebus. It’s a coincidence of numbering, and messagebus has nothing to do with your bo

Читать полностью…

>>> telegram.Bot()

https://github.com/python-telegram-bot/python-telegram-bot/blob/v22.8/src%2Ftelegram%2F_bot.py#L4130-L4131

Читать полностью…

>>> telegram.Bot()

yaa this is confusing me also this is coming as like this

Читать полностью…

>>> telegram.Bot()

What Is the output of
ls -ls /var/lib/telegram-bot-api/TOKEN/documents/file_0.txt?

Читать полностью…

>>> telegram.Bot()

if you read the news article

The Rich Text Editor is currently available to Telegram Premium users only. Why? Because otherwise, we'd have to call it the Poor Text Editor — and you don't want that.

Читать полностью…

>>> telegram.Bot()

Manually, by myself.


Ah, forget it, bro. I was just asking out of curiosity and for knowledge purposes, fr. This topic's lowkey giving me a headache now, so I'm just gonna let it go.

Читать полностью…

>>> telegram.Bot()

Forget about that—it's not a big deal.

Читать полностью…
Subscribe to a channel