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
https://onlinenotepad.org/notepad
save as .py upload to Google drive gg
Thank you very much!
Yes i've hoped to be able to split stuff up and have commands, at least bigger/complex ones, in its own files.
I'll read the article you've linked and will try my best from there!
is there any "official" guideline how to do that? Or do i "just" create additional python codefiles and use "import" in the right order to load them into the main bot file?
In the old PHP Based Library there was a dedicated Command folder where every command would have/need its own .php file, and i'm trying to figure out if PTB has something like this build in or not ^^'
obviously I recommend to split code responsibilities when the project starts to get more complex
Читать полностью…
excluding the Library itself of course!
i meant the part that I "have" to write/code.
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?
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?
Читать полностью…
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
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?
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
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
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
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
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
Читать полностью…
Hi, does anyone know if I can create a bot from my mobile phone and how to export the code???
Читать полностью…
Are software asset listings permitted in a designated channel or thread?
Читать полностью…
i personally think that not only you gonna find it's easy to work with multiple files but you probably gonna need it to not make your mind blow.
now working with multiple files is more a general pyhton kwnoledge thing so i recommend you read some sources to learn how to do it, but in short terms recalling a file using import statements is enough until you need internal packages, altough even with packages you won't go far away from the import statement logic (you just gonna switch to from x import y statements)
You can put the commands in one function while the command's callback can be in anywhere else since what important is what the command should "call" when user sent this or that.
Читать полностью…
yeah surely you can fit everything you need to run a bot inside one file, as shown in the starting example you just tried
Читать полностью…
with enough certainty i can say ptb is far more complex then a single python file
Читать полностью…
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
When you do get_file the file Is downloaded by the api server
When you call save_to_drive a copy Is performed
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.
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 -> messagebussudo 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,
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?
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?
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?
Host, there's no need of -s, the size isn't relevant. Btw i'd like to see the file permissions
Читать полностью…