Merhaba arkadaşlar kendi grubumda hesapların otomatik mesaj göndermesini istiyorum hazır bu kod buldum çalıştırdığım zaman şu hatayı alıyorum.
File "dogan.py", line 30
async def send_message(phone,message,image):
^
SyntaxError: invalid syntax
Kodlar doğrumu onu bile bilmiyorum çok basit sadece kendi grubum için böyle bi bot istiyorum açık kaynak var ise bildiğiniz tavsiye ederseniz sevinirm.
Kod;
import asyncio
import datetime
import configparser
from telethon import TelegramClient
from telethon.errors import SessionPasswordNeededError
from telethon.tl.functions.messages import (GetHistoryRequest)
from telethon.tl.types import (
PeerChannel
)
#TELEGRAM API
config_tg = configparser.ConfigParser()
config_tg.read("config.ini")
# Setting configuration values
api_id = api_id azıyorum
api_hash = "apihashyazıyorum"
api_hash = str(api_hash)
phone = +90-numaramı yazıyorum
username_tg = "kullaniciadim"
# Create the client and connect
client1 = TelegramClient(username_tg, api_id, api_hash)
async def send_TG_message(phone,message,image):
await client1.start()
print("Client Created")
# Ensure you're authorized
if await client1.is_user_authorized() == False:
await client1.send_code_request(phone)
try:
await client1.sign_in(phone, input('Enter the code: '))
except SessionPasswordNeededError:
await client1.sign_in(password=input('Password: '))
#me = await client1.get_me()
#await client1.send_file('https://t.me/Doganchannell',image,caption=message) # açık kanal
#await asyncio.sleep(2)
# VIP TELEGRAM CHANNEL
#await client1.send_file('https://t.me/joinchat/ObnByZ1kYr4wNOlk',image,caption=message_vip) #gizli kanal linki
#await asyncio.sleep(2)
@client.event
async def on_ready():
while True:
mesaj=" doğan mesaj 1"
#ex_image=dogan.jpg
#image ='imgs/'+ex_image
mesaj2="Çalışması lazım"
x = datetime.datetime.now()
x = int(x.strftime("%H"))
async with client1:
if(x==16): # saat 16da paylaş
await send_TG_message(phone,mesaj,image,mesaj2)
await asyncio.sleep(3000)
else:
print("Saat gelmedi daha")
await asyncio.sleep(4)
client1.run()