georgGrankvist / TelegramShiller9000

Telegram marketing client, built in Python using Telethon framework.
14 stars 8 forks source link

NameError: name 'client' is not defined #1

Open Mooncopdev opened 3 years ago

Mooncopdev commented 3 years ago

hoping this gets to you. not a supreme being of coding so i am having difficulty understanding this error when i attempt to start this bot.

C:\Users\Moonc\AppData\Local\Programs\Python\Python39>telegramshiller.py Traceback (most recent call last): File "C:\Users\Moonc\AppData\Local\Programs\Python\Python39\TelegramShiller.py", line 17, in client.start("telegram.client") NameError: name 'client' is not defined

any assistance to get me where i am going would be much appreciated.

cheerz

georgGrankvist commented 3 years ago

Hi there, i am on vacation currently without access to a computer, so the exact reason for your error message would be hard for me to nail down. If I would hazard a guess, it could be that the name of the client in the source code does not correspond to the name you use in your telegram client. Try changing that field.

On Sunday, August 15, 2021, Mooncopdev @.***> wrote:

hoping this gets to you. not a supreme being of coding so i am having difficulty understanding this error when i attempt to start this bot.

C:\Users\Moonc\AppData\Local\Programs\Python\Python39>telegramshiller.py Traceback (most recent call last): File "C:\Users\Moonc\AppData\Local\Programs\Python\Python39\TelegramShiller.py", line 17, in client.start("telegram.client") NameError: name 'client' is not defined

any assistance to get me where i am going would be much appreciated.

cheerz

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/georgGrankvist/TelegramShiller9000/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO6WPOQB647FLPGMKR6CRMTT47GLZANCNFSM5CGHVN4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

georgGrankvist commented 3 years ago

Make sure that your import statements are declared properly and that telethon is installed on your machine, and that the parameters for the client declared on line 17 (api_id, api_hash) are correct (retrieved from my.telegram.org). If you have changed anything in the source code, please provide your current version and I would happily have a look at it.

Mooncopdev commented 3 years ago

i have re uploaded a copy of the telegramshiller.py file renamed as "tg" on my forked repository. i do not know where i am going wrong. my client is registering it as line 19 now. and i have not altered any coding apart from the quotation marks as defined by you.

i am trying to operate the script from command prompt, as i am still unfamiliar with python. very early stage learner here (sorry)

https://github.com/Mooncopdev/TelegramShiller9000

it is still not defining the client, however i have confirmed telethon and telegram modules are installed and up to date via pip install. i have the script out at the start of the python folder ( where the python.exe is for windows), maybe i need it in a different location for it to be recognised?

agnaldoroz commented 3 years ago

Hello, it's happening the same with me...Did you solve it? How?

What do we fill in client.start()?

Thanks in advance!.

Mooncopdev commented 3 years ago

I have not yet sorted my copy out. Been very busy elsewhere and have yet to get back to it

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: @.> Sent: Monday, 27 September 2021 7:24 PM To: @.> Cc: @.>; @.> Subject: Re: [georgGrankvist/TelegramShiller9000] NameError: name 'client' is not defined (#1)

Hello, it's happening the same with me...Did you solve it? How?

What do we fill in client.start()?

Thanks in advance!.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/georgGrankvist/TelegramShiller9000/issues/1#issuecomment-927781027, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AT45N7JOYKNHVJ7GTBNHLPDUEBH7VANCNFSM5CGHVN4Q. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

georgGrankvist commented 2 years ago

I have not yet sorted my copy out. Been very busy elsewhere and have yet to get back to it Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10 From: @.> Sent: Monday, 27 September 2021 7:24 PM To: @.> Cc: @.>; @.> Subject: Re: [georgGrankvist/TelegramShiller9000] NameError: name 'client' is not defined (#1) Hello, it's happening the same with me...Did you solve it? How? What do we fill in client.start()? Thanks in advance!. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#1 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AT45N7JOYKNHVJ7GTBNHLPDUEBH7VANCNFSM5CGHVN4Q. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Hello, it's happening the same with me...Did you solve it? How?

What do we fill in client.start()?

Thanks in advance!.

Make sure you do not change anything in the source code aside from entering the api_id and api_hash values. Mooncopdev, in one of your forks of this repository I saw that you altered the main function definition on line 10, which is why your error is most likely occuring. Another issue could be a faulty telethon installation. I would recommend running it in an IDE such as PyCharm as it will make installing these packages easier and give useful hints.

if name == 'main': api_id = 'ENTER API_ID HERE' api_hash = 'ENTER API_HASH HERE'

client = TelegramClient('', api_id, api_hash)
channel_list = fetch_list()
message = fetch_text()

client.start()

for var in channel_list: time.sleep(10) result = client(functions.channels.JoinChannelRequest( channel=var ))

wiucha commented 2 years ago

Traceback (most recent call last): File "C:\ShillBot\TelegramShiller9000-main\TelegramShiller.py", line 31, in client.send_message(entity, message) File "C:\ShillBot\TelegramShiller9000-main\telethon\sync.py", line 39, in syncified return loop.run_until_complete(coro) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64qbz5n2kfra8p0\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "C:\ShillBot\TelegramShiller9000-main\telethon\client\messages.py", line 872, in send_message
result = await self(request) File "C:\ShillBot\TelegramShiller9000-main\telethon\client\users.py", line 30, in
call__ return await self._call(self._sender, request, ordered=ordered) File "C:\ShillBot\TelegramShiller9000-main\telethon\client\users.py", line 84, in _call result = await future telethon.errors.rpcerrorlist.ChatWriteForbiddenError: You can't write in this chat (caused by SendMessageRequest)

Why?