创建此python脚本以添加100个成员,但仅添加3到5个成员并自动停止

创建此python脚本以添加100个成员,但仅添加3到5个成员并自动停止,python,python-2.x,telethon,termux,Python,Python 2.x,Telethon,Termux,创建此python脚本以添加100个成员,但只添加了3到5个成员,有时仅添加1个成员,之后它会自动停止,不知道问题出在哪里,但可能我认为问题出在时间戳中 创建这个python脚本是为了添加100个成员,但只添加了3到5个成员,有时只添加了1个成员,之后它会自动停止,不知道问题出在哪里,但可能我认为问题出在时间戳上 from telethon.sync import TelegramClient from telethon.tl.functions.messages import GetDialo

创建此python脚本以添加100个成员,但只添加了3到5个成员,有时仅添加1个成员,之后它会自动停止,不知道问题出在哪里,但可能我认为问题出在时间戳中
创建这个python脚本是为了添加100个成员,但只添加了3到5个成员,有时只添加了1个成员,之后它会自动停止,不知道问题出在哪里,但可能我认为问题出在时间戳上

from telethon.sync import TelegramClient
from telethon.tl.functions.messages import GetDialogsRequest
from telethon.tl.types import InputPeerEmpty, InputPeerChannel, InputPeerUser, PeerUser
from telethon.errors.rpcerrorlist import PeerFloodError, UserPrivacyRestrictedError, ChatWriteForbiddenError, UserAlreadyParticipantError
from telethon.tl.functions.channels import InviteToChannelRequest
from telethon.tl.functions.channels import GetFullChannelRequest, JoinChannelRequest
from telethon import types, utils, errors
import configparser
import sys
import csv
from csv import reader
import traceback
import time
import random
from telethon.sessions import StringSession

print("                                     ")

print("                          " )

print("                                               ")

print("                                                ")


delta = 1

with open('../phone.csv', 'r') as read_obj:
    csv_reader = reader(read_obj)
    list_of_rows = list(csv_reader)    
    row_number = delta
    col_number = 1
    value = list_of_rows[row_number - 1][col_number - 1]
    
with open('../api.csv', 'r') as api_obj_id:
    csv_reader = reader(api_obj_id)
    list_of_rows = list(csv_reader)
    row_number = delta
    col_number = 1
    deltaop = list_of_rows[row_number - 1][col_number - 1]
    
with open('../api.csv', 'r') as hash_obj:
    csv_reader = reader(hash_obj)
    list_of_rows = list(csv_reader)  
    row_number = delta
    col_number = 2
    deltaxd = list_of_rows[row_number - 1][col_number - 1]
    
api_id = int(deltaop)
api_hash = str(deltaxd)
pphone = value

config = configparser.ConfigParser()
config.read("../config.ini")
to_group = config['Telegram']['to_channel']


def autos():
    
    channel_username = to_group
    phone = utils.parse_phone(pphone)

    client = TelegramClient(f"../sessions/{phone}", api_id, api_hash)

    client.connect()
    if not client.is_user_authorized():
        print('some thing has changed')
        client.send_code_request(phone)
        client.sign_in(phone, input    ('Enter the code: '))


    input_file = '../data.csv'
    users = []
    with open(input_file, encoding='UTF-8') as f:
        rows = csv.reader(f, delimiter=",", lineterminator="\n")
        next(rows, None)
        for row in rows:
            user = {}
            user['srno'] = row[0]
            user['username'] = row[1]
            user['id'] = int(row[2])
        #user['access_hash'] = int(row[2])
            user['name'] = row[3]
            users.append(user)

    startfrom = int(input("Start From = "))
    endto = int(input("End To = "))


    

    for user in users:
        if (int(startfrom) <= int    (user['srno'])) and (int(user['srno']) <= int(endto)):
            try:
                status = 'delta'
                if user['username'] == "":
                    print("no username, moving to next")
                    continue
            
                    
                
                client(InviteToChannelRequest(channel_username,[user['username']]))
                status = 'DONE'
                
                    #print("Waiting for 60-180 Seconds...")
                time.sleep(random.randrange(0, 5))
                
            except UserPrivacyRestrictedError:
                status = 'PrivacyRestrictedError'
                
            
            except UserAlreadyParticipantError:
                status = 'ALREADY'
                
            
            except PeerFloodError as g:
                status = 'PeerFloodError :('
                print('Script Is Stopping Now')
                time.sleep(86400)
                
            
                
            
                
            except ChatWriteForbiddenError as cwfe:
                
           
                client(JoinChannelRequest(channel_username))
                continue
                
            except errors.RPCError as e:
                status = e.__class__.__name__
        
    
            except Exception as d:
                status = d

            except:
                traceback.print_exc()
                print("Unexpected Error")
                continue
            channel_connect = client.get_entity(channel_username)
            channel_full_info = client(GetFullChannelRequest(channel=channel_connect))
            countt = int(channel_full_info.full_chat.participants_count)

            print(f"ADDING {user['name']} TO {channel_username} TOTAL: {countt} - {status}")
        elif int(user['srno']) > int(endto):
            print("Members Added Successfully!")
            stat = input('Done!\nChoose From Below:\n\n1 - Repeat The Script\nOR Just Hit Enter To Quit\n\nEnter: ')
            if stat == '1':
                autos()
            else:
                quit()
             
autos()    


从telethon.sync导入客户端
从telethon.tl.functions.messages导入GetDialogsRequest
从telethon.tl.types导入InputPeerEmpty、InputPeerChannel、InputPeerUser、PeerUser
从telethon.errors.rpcerrorlist导入PeerFloodError、UserPrivacyRestrictedError、ChatWriteForbiddenError、UseralReadyParticipatificInterror
从telethon.tl.functions.channels导入邀请到channelrequest
从telethon.tl.functions.channels导入GetFullChannelRequest、JoinChannelRequest
从telethon导入类型、UTIL、错误
导入配置分析器
导入系统
导入csv
从csv导入读取器
导入回溯
导入时间
随机输入
从telethon.sessions导入StringSession
打印(“”)
打印(“”)
打印(“”)
打印(“”)
δ=1
打开('../phone.csv',r')作为读取对象:
csv\u reader=读卡器(读取对象)
行列表=列表(csv\U读卡器)
行数=增量
列数=1
值=行列表[行编号-1][列编号-1]
以open('../api.csv',r')作为api对象id:
csv_reader=读卡器(api_obj_id)
行列表=列表(csv\U读卡器)
行数=增量
列数=1
deltaop=行列表[行编号-1][列编号-1]
将open('../api.csv',r')作为散列对象:
csv_reader=读取器(散列对象)
行列表=列表(csv\U读卡器)
行数=增量
列数=2
deltaxd=行列表[行编号-1][列编号-1]
api_id=int(deltaop)
api_hash=str(deltaxd)
pphone=值
config=configparser.configparser()
config.read(“../config.ini”)
to_group=config['Telegram']['to_channel']
def autos():
频道\用户名=至\组
phone=utils.parse_phone(pphone)
client=TelegramClient(f.。/sessions/{phone}),api_id,api_hash)
client.connect()
如果不是客户端。用户是否已授权()
打印('某些内容已更改')
客户端。发送密码请求(电话)
客户端。登录(电话,输入('输入代码:'))
输入文件=“../data.csv”
用户=[]
打开(输入_文件,将='UTF-8'编码为f):
rows=csv.reader(f,delimiter=“,”,lineterminator=“\n”)
下一步(行,无)
对于行中的行:
用户={}
用户['srno']=行[0]
用户['username']=行[1]
用户['id']=int(第[2]行)
#用户['access_hash']=int(第[2]行)
用户['name']=行[3]
附加(用户)
startfrom=int(输入(“起始=”))
endto=int(输入(“End To=”))
对于用户中的用户:
if(int(从开始)