コード例 #1
0
def autofollow(mastodon, user_id, domain, zodiac):
    member = get_member(zodiac.id)

    for user in member:
        a_tk, u_id, dmin = user
        if user_id == u_id and domain == dmin:
            continue
        api_base_url = 'https://' + dmin
        mstdn = Mastodon(access_token=a_tk, api_base_url=api_base_url)
        uri = u_id + '@' + dmin
        try:
            mastodon.follows(uri)
        except:
            pass
        uri = user_id + '@' + domain
        try:
            mstdn.follows(uri)
        except:
            pass

    if zodiac.uri is '' or zodiac.uri is None:
        return
    try:
        mastodon.follows(zodiac.uri)
    except:
        pass
コード例 #2
0
ファイル: peertubetomasto.py プロジェクト: PhieF/MiscConfig
index = 0

# Follow PeerTube user

while (cont):
    response = urllib2.urlopen(api_url + '/accounts?start=' + str(index))
    html = response.read()
    data = json.loads(html)
    index += 15
    if (len(data['data']) < 15):
        cont = False

    for account in data['data']:
        if (account['host'] == host):
            if account['name'] not in result['followed']:
                dicti = mastodon.follows(account['name'] + "@" + host)
                result['followed'][account['name']] = dicti.id

# Retoot
if (rt):
    for account in result['followed']:
        #print(result['followed'][account])
        for status in reversed(
                mastodon.account_statuses(result['followed'][account])):
            if ("comment" not in status.uri
                    and status.id not in result['retoot']):
                print "rebloging " + status.content
                rb = mastodon.status_reblog(status.id)
                result['retoot'].append(status.id)
                if (unrt):
                    mastodon.status_unreblog(rb.reblog.id)
コード例 #3
0
        for acct in follower_list:
            if acct not in all_follower_list:
                continue
            domain_write = acct[acct.find('@', 1) + 1:]
            if data.get_domain2_follow_time(domain_write, domain) is not None:
                continue
            print('CDYEVXKP detect @{0} followed {1}'.format(
                data.get_username(domain), acct))
            data.set_domain2_follow_time(domain_write, domain, timestamp)

        for acct in add_follower_list:
            try:
                print('QXXETPXT {0} follow {1}'.format(
                    data.get_username(domain), acct))
                mastodon.follows(acct[1:])
                domain_write = acct[acct.find('@', 1) + 1:]
                data.set_domain2_follow_time(domain_write, domain, timestamp)
            except:
                print('OJLWGRRB {0}'.format(refreshtime_domain_tuple[1]))
                traceback.print_exc()
    except:
        print('XACXTJIH {0}'.format(refreshtime_domain_tuple[1]))
        traceback.print_exc()

# check read
for refreshtime_domain_tuple in refreshtime_domain_tuple_list:
    try:
        domain = refreshtime_domain_tuple[1]
        username = test_domain_username_dict[domain]
        bot_client_secret_fn = os.path.join('data', 'instances', domain,