def replyProcess(tweet): tome = False try: for i in range(len(tweet["entities"]["user_mentions"])): if tweet["entities"]["user_mentions"][i][ "screen_name"] == currentuser: tome = True except: return if not (tome): return replytxt = tweet["text"] replytxt = replytxt.split(" ") ### reply => "@$currentuser $request $message" if not (len(replytxt) == 3): return request = replytxt[1] followUser = "" if not (request == "follow"): return followUser = replytxt[2] fromUser = tweet["user"]["screen_name"] twitter.follow(followUser, fromUser)
def replyProcess(tweet): tome = False try: for i in xrange(len(tweet["entities"]["user_mentions"])): if tweet["entities"]["user_mentions"][i][ "screen_name"] == "best_of_asi": tome = True except: return if not (tome): return replytxt = tweet["text"] replytxt = replytxt.split(" ") ### reply => "@best_of_asi $request $message" if not (len(replytxt) == 3): return request = replytxt[1] followUser = "" if request == "follow": followUser = replytxt[2] fromUser = tweet["user"]["screen_name"] print "ReplyFrom : " + fromUser print "request : " + request print "{0}to : {1}".format(request, followUser) twitter.follow(followUser, fromUser)
statuses = tw.buscar(busqueda, usuario) #Creo la lista de usuario de la busqueda listaUsuariosBusqueda = tw.listaUsuarios(statuses) #Elimino los duplicados list(set(listaUsuariosBusqueda)) #Creo una lista de la gente que sigo listaFollowingL = tw.listaFollowing(usuario) #hago follow en el caso en que el usuario no este en la lista de gente que sigo for l in listaUsuariosBusqueda: if l not in listaFollowingL: try: #Hago follow si usuario l no está en la linsta listaFollowingL tw.follow(l, usuario) #Añado ese usuario a la lista listaFollowing listaFollowingL.append(l) except: print "Error over Capacity" print "sigo a " + l segundos = random.randint(30, 200) print str(segundos) + ' de espera' time.sleep(int(segundos))
#! /usr/bin/python from twitter import user, tweet, follow user = user() user.cleanAll() tweet = tweet() follow = follow() user.addUser("ich") user.addUser("du") user.addUser("er") follow.follows("du", "ich") follow.follows("er", "ich") users = user.getAllUsers() for u in users : print u tweet.addTweet("ich", None, "ein neuer tweet") print "tweets von ich" tweets = tweet.getTweetsForUser("ich") for t in tweets : print t print "followers von ich" followers = follow.getFollowersOfUser("ich") for f in followers : print f
def execute(text: str, user_id: str, screen_name: str, name: str, from_tweet: bool) -> Optional[str]: account = 'twitter-' + user_id name = name.split('@')[0] if not name.startswith('@') else name command = get_command(text) if command['method'] == None: return None if command['method'] == 'tip': if len(command['params']) < 2: text = 'tipkotoneの使い方をご確認ください! https://github.com/akarinS/tipkotone/blob/master/README.md' return get_message(text, screen_name) if from_tweet else get_message(text) if re.match('^@', command['params'][0]): to_screen_name = command['params'][0][1:] str_amount = command['params'][1] elif re.match('^@', command['params'][1]): to_screen_name = command['params'][1][1:] str_amount = command['params'][0] else: text = '宛先が間違っています・・・' return get_message(text, screen_name) if from_tweet else get_message(text) if to_screen_name == screen_name: text = '自身には投げ銭できません・・・' return get_message(text, screen_name) if from_tweet else get_message(text) if to_screen_name == BOTSCREENNAME: to_account = 'FREE' else: to_user = twitter.user(to_screen_name) if to_user.get('error') is not None: text = '宛先が見つかりませんでした・・・' return get_message(text, screen_name) if from_tweet else get_message(text) to_user_id = to_user['id_str'] to_account = 'twitter-' + to_user_id to_name = to_user['name'] to_name = to_name.split('@')[0] if not to_name.startswith('@') else name result = aw.move(account, to_account, str_amount) if result == 'wrong': text = '不正な金額です・・・' return get_message(text, screen_name) if from_tweet else get_message(text) elif result == 'few': text = '金額が小さすぎです・・・' return get_message(text, screen_name) if from_tweet else get_message(text) elif result == 'insufficient': text = '残高が足りません・・・' return get_message(text, screen_name) if from_tweet else get_message(text) amount = Decimal_to_str(result) if to_screen_name == BOTSCREENNAME: text = f'{amount}KOTO 寄付していただきありがとうございます!' return get_message(text, screen_name) if from_tweet else get_message(text) text = f'{name}さんから {to_name}さんへ お心付けです! {amount}KOTO' return get_message(text, screen_name, to_screen_name) if from_tweet else get_message(text) if command['method'] == 'balance': balance, confirming_balance = aw.get_account_balance(account) balance = Decimal_to_str(balance) if confirming_balance == 0: text = f'{name}さんの残高は {balance}KOTO です!' else: confirming_balance = Decimal_to_str(confirming_balance) text = f'{name}さんの残高は {balance}KOTO (+{confirming_balance}KOTO 承認中) です!' return get_message(text, screen_name) if from_tweet else get_message(text) if command['method'] == 'deposit': address = aw.get_account_address(account) text = f'{address} に送金してください!' return get_message(text, screen_name) if from_tweet else get_message(text) if command['method'] == 'withdraw': if len(command['params']) < 2: text = 'tipkotoneの使い方をご確認ください! https://github.com/akarinS/tipkotone/blob/master/README.md' return get_message(text, screen_name) if from_tweet else get_message(text) if re.match('^(k|jz)', command['params'][0]): address = command['params'][0] str_amount = command['params'][1] elif re.match('^(k|jz)', command['params'][1]): address = command['params'][1] str_amount = command['params'][0] else: text = 'アドレスが間違っています・・・' return get_message(text, screen_name) if from_tweet else get_message(text) if not coinrpc.call('validateaddress', address)['isvalid']: text = 'アドレスが間違っています・・・' return get_message(text, screen_name) if from_tweet else get_message(text) result = aw.add_withdrawal_request(account, address, str_amount) if result == 'wrong': text = '不正な金額です・・・' return get_message(text, screen_name) if from_tweet else get_message(text) elif result == 'few': text = '金額が小さすぎです・・・' return get_message(text, screen_name) if from_tweet else get_message(text) elif result == 'insufficient': text = '残高が足りません・・・' return get_message(text, screen_name) if from_tweet else get_message(text) amount = Decimal_to_str(result) text = f'{amount}KOTO の出金リクエストを受け付けました!' return get_message(text, screen_name) if from_tweet else get_message(text) if command['method'] == 'help': text = 'tipkotoneの使い方はこちらです! https://github.com/akarinS/tipkotone/blob/master/README.md' return get_message(text, screen_name) if from_tweet else get_message(text) if command['method'] == 'follow': twitter.follow(user_id) text = 'フォローしました!' return get_message(text, screen_name) if from_tweet else get_message(text) return None
usuario = sys.argv[1] #Lista de gente que me sigue genteQueMeSigue = tw.listaSeguidores(usuario) #Creo una lista de la gente que sigo genteQueSigo = tw.listaFollowing(usuario) #hago follow en el caso en que el usuario no este en la lista de gente que sigo contador = 0 for l in range(0, len(genteQueMeSigue)): #buscarElemento(listaFollowing, listaFollowers[l]) if genteQueMeSigue[l] not in genteQueSigo: try: print genteQueMeSigue[l] if contador < 50: tw.follow(str(genteQueMeSigue[l]), usuario) print "Devolver follow a: "+str(genteQueMeSigue[l]) contador = contador + 1 segundos = random.randint(30, 200) print str(segundos) + ' segundos de espera' time.sleep(segundos) except: print "Error Follow"
parser = ArgumentParser( description="Twitter unfollow and follow API") parser.add_argument('-m', '--myaccount', help="my account") parser.add_argument('-c', '--copyaccount', help="account to copy followers") args = parser.parse_args() #print twitter.application.rate_limit_status() myaccount = 'PancakeMick' copyaccount = touse #delete all people not following back if myaccount and copyaccount: #print myaccount #people following followingme = follow(twitter, myaccount, False) #print lookup(twitter, userids) #followers myfollowers = follow(twitter, myaccount, True) #print lookup(twitter, followers) print 'These people are following me: ' print myfollowers tounfollow = [] for id in followingme: if id not in myfollowers: tounfollow.append(id) print len(tounfollow) #print lookup(twitter, tounfollow) #uncomment below when u run print 'These people will be unfollowed ' print tounfollow