Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch ChatWriteForbiddenError #84

Closed
joan-carles opened this issue Dec 31, 2020 · 3 comments
Closed

Catch ChatWriteForbiddenError #84

joan-carles opened this issue Dec 31, 2020 · 3 comments
Assignees
Milestone

Comments

@joan-carles
Copy link

joan-carles commented Dec 31, 2020

  • telegram-upload version: 0.4.0
  • Python version: Debian testing: (3.9) Raspberry Pi (3.7)
  • Operating System: Debian testing and Raspberry Pi
  • Dependencies list (run pip freeze):
Raspberry pi
pi@raspberrypi:~ $ pip freeze
arandr==0.1.9
asn1crypto==0.24.0
automationhat==0.2.0
blinker==1.4
blinkt==0.1.2
buttonshim==0.0.2
Cap1xxx==0.1.3
certifi==2018.8.24
chardet==3.0.4
Click==7.0
colorama==0.3.7
colorzero==1.1
configparser==3.5.0b2
cookies==2.2.1
cryptography==2.6.1
drumhat==0.1.0
entrypoints==0.3
enum34==1.1.6
envirophat==1.0.0
ExplorerHAT==0.4.2
Flask==1.0.2
fourletterphat==0.1.0
funcsigs==1.0.2
gpiozero==1.5.1
idna==2.6
ipaddress==1.0.17
itsdangerous==0.24
Jinja2==2.10
keyring==17.1.1
keyrings.alt==3.1.1
MarkupSafe==1.1.0
microdotphat==0.2.1
mock==2.0.0
mote==0.0.4
motephat==0.0.3
numpy==1.16.2
oauthlib==2.1.0
olefile==0.46
pantilthat==0.0.7
pbr==4.2.0
phatbeat==0.1.1
pianohat==0.1.0
picamera==1.13
piglow==1.2.5
pigpio==1.44
Pillow==5.4.1
pyaes==1.6.1
pyasn1==0.4.8
pycairo==1.16.2
pycrypto==2.6.1
pygame==1.9.4.post1
PyGObject==3.30.4
pyinotify==0.9.6
PyJWT==1.7.0
pyOpenSSL==19.0.0
pyserial==3.4
pyxdg==0.25
rainbowhat==0.1.0
requests==2.21.0
requests-oauthlib==1.0.0
responses==0.9.0
RPi.GPIO==0.7.0
rsa==4.5
RTIMULib==7.2.1
scrollphat==0.0.7
scrollphathd==1.2.1
SecretStorage==2.3.1
sense-hat==2.2.0
simplejson==3.16.0
six==1.12.0
skywriter==0.0.7
sn3218==1.2.7
spidev==3.4
Telethon==0.18.2.3
touchphat==0.0.1
twython==3.7.0
typing==3.7.4.3
unicornhathd==0.0.4
urllib3==1.24.1
Werkzeug==0.14.1
Debian testing
joan@debian:~$ pip freeze
beautifulsoup4==4.9.3
Brlapi==0.8.1
caffeine==2.9.8
catfish==1.4.13
certifi==2020.6.20
cffi==1.14.4
chardet==3.0.4
click==7.1.2
cryptg==0.2.post2
cryptography==3.2.1
cupshelpers==1.0
dbus-python==1.2.16
distro==1.5.0
ewmh==0.1.6
eyeD3==0.8.10
feedparser==5.2.1
gpodder==3.10.17
hachoir==3.1.1
html5lib==1.1
idna==2.10
louis==3.16.0
lxml==4.6.2
menulibre==2.2.1
musicbrainzngs==0.7.1
mutagen==1.45.1
mygpoclient==1.8
numpy==1.19.4
olefile==0.46
pexpect==4.6.0
Pillow==8.0.1
podcastparser==0.6.5
psutil==5.7.3
pyaes==1.6.1
pyasn1==0.4.8
pycairo==1.16.2
pycparser==2.20
pycups==2.0.1
PyGObject==3.38.0
pyinotify==0.9.6
pysmbc==1.0.23
python-apt==2.1.7
python-debian==0.1.39
python-magic==0.4.16
python-xlib==0.29
pyxattr==0.7.2
pyxdg==0.26
quodlibet==4.3.0
Recoll==1.0
recollchm==0.8.4.1+git
requests==2.24.0
rsa==4.6
simplejson==3.17.0
six==1.15.0
soupsieve==2.1
specan==0.0.0
telegram-upload==0.4.0
Telethon==1.18.2
ufw==0.36
urllib3==1.25.11
webencodings==0.5.1
youtube-dl==2020.12.29

Description

When I try to upload a file or a set of files I get next error in debian testing:

user@debian:~$ telegram-upload --to pics --force-file --directories recursive /media/DATOS/media/pics/
Uploading "me.jpg"  [####################################]  100%
Traceback (most recent call last):
  File "/usr/local/bin/telegram-upload", line 8, in <module>
    sys.exit(upload_cli())
  File "/usr/local/lib/python3.9/dist-packages/telegram_upload/exceptions.py", line 50, in wrap
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/telegram_upload/management.py", line 101, in upload
    client.send_files(to, files, delete_on_success, print_file_id, force_file, forward, caption, thumbnail)
  File "/usr/local/lib/python3.9/dist-packages/telegram_upload/client.py", line 139, in send_files
    message = self.send_file(entity, file, thumb=thumb,
  File "/usr/local/lib/python3.9/dist-packages/telethon/sync.py", line 39, in syncified
    return loop.run_until_complete(coro)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.9/dist-packages/telethon/client/uploads.py", line 372, in send_file
    return self._get_response_message(request, await self(request), entity)
  File "/usr/local/lib/python3.9/dist-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "/usr/local/lib/python3.9/dist-packages/telethon/client/users.py", line 79, in _call
    result = await future
telethon.errors.rpcerrorlist.ChatWriteForbiddenError: You can't write in this chat (caused by SendMediaRequest)

In the raspberry Pi I get very similar error doing the same:

pi@raspberrypi:~ $ telegram-upload --to pics --force-file --directories recursive /media/DATOS/media/pics/
Uploading "me.jpg"  [####################################]  100%
Traceback (most recent call last):
  File "/usr/local/bin/telegram-upload", line 10, in <module>
    sys.exit(upload_cli())
  File "/usr/local/lib/python3.7/dist-packages/telegram_upload/exceptions.py", line 50, in wrap
    return fn(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/telegram_upload/management.py", line 101, in upload
    client.send_files(to, files, delete_on_success, print_file_id, force_file, forward, caption, thumbnail)
  File "/usr/local/lib/python3.7/dist-packages/telegram_upload/client.py", line 142, in send_files
    progress_callback=progress, attributes=attributes)
  File "/usr/local/lib/python3.7/dist-packages/telethon/sync.py", line 39, in syncified
    return loop.run_until_complete(coro)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.7/dist-packages/telethon/client/uploads.py", line 372, in send_file
    return self._get_response_message(request, await self(request), entity)
  File "/usr/local/lib/python3.7/dist-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "/usr/local/lib/python3.7/dist-packages/telethon/client/users.py", line 79, in _call
    result = await future
telethon.errors.rpcerrorlist.ChatWriteForbiddenError: You can't write in this chat (caused by SendMediaRequest)

What I Did

I installed the software through

sudo pip3 install -U telegram-upload

Then I went to 

https://my.telegram.org/auth

and the in API development tools I got My API id and API hash.

Then I ran the command:

telegram-upload --to pics --force-file --directories recursive /media/DATOS/media/pics/

and then introduced api_id, api-hash, phone number and code received by phone
@Nekmo
Copy link
Owner

Nekmo commented Dec 31, 2020

@joan-carles reads the error message:

telethon.errors.rpcerrorlist.ChatWriteForbiddenError: You can't write in this chat (caused by SendMediaRequest)

However, Telegram-upload should catch this error if there are no permissions for the chat id.

@Nekmo Nekmo self-assigned this Dec 31, 2020
@Nekmo Nekmo changed the title Error when upload a file Catch ChatWriteForbiddenError Dec 31, 2020
@Nekmo Nekmo added this to the v0.5.0 milestone Dec 31, 2020
@joan-carles
Copy link
Author

joan-carles commented Dec 31, 2020

Hi

I'm trying to upload files in a private channel. The private channel only has 1 member and this member is the administrator. And this user absolutely has all the permissions.

https://imgur.com/Xmj4tCD.png

Do I have to add another user in order upload with telegram upload?

Any solution in order to fix the problem? Right now in my case the software is completely broken.

How can I have permission for an specific chat id? I really thought that if you introduce information about api, your phone number and the access code then you should have permissions. Oww I see you are Spanish :D (Yo también)

If I miss something trivial sorry.

@joan-carles
Copy link
Author

It was my mistake. Instead of invitation link to channel I used the channel name. So the software works well. Was my mistake

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants