diff --git a/Dockerfile b/Dockerfile index 81118b0..99a0c15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ ADD . /app WORKDIR /app -RUN pip install -r requirements.txt +RUN sudo apt update +RUN sudo apt install -y python3-pip +RUN pip3 install -r requirements.txt -CMD ["python", "main.py"] +CMD ["python3", "main.py"] diff --git a/env.sh b/env.sh new file mode 100755 index 0000000..0700f12 --- /dev/null +++ b/env.sh @@ -0,0 +1,6 @@ +#!/bin/sh +export FF_PASSWORD= +export FF_ACCOUNT= +export M_INSTANCE= +export M_TOKEN= +export YOUR_CONTAINER_NAME=mas2ff diff --git a/last_id.txt b/last_id.txt new file mode 100644 index 0000000..1c89816 --- /dev/null +++ b/last_id.txt @@ -0,0 +1,2 @@ +107896829133801546 +107897040775908429 diff --git a/main.py b/main.py index 7761ddb..097c5a8 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,32 @@ from mastodon import Mastodon import argparse +from selenium import webdriver +from selenium.webdriver.common.by import By +import time +def post_fanfou(webdrive_, fanfou_status, images=None): + if not images: + images = [] + # post status + if not images: + input_field = webdrive_.find_element(by=By.NAME, value='content') + input_field.send_keys(fanfou_status) + input_field.submit() + else: + # post with images + pass + +def run(instance, access_token, fanfou_account, fanfou_password): + chrome = webdriver.Chrome() + # login to fanfou + chrome.get('https://m.fanfou.com/') + login_name = chrome.find_element(by=By.NAME, value='loginname') + login_pass = chrome.find_element(by=By.NAME, value='loginpass') + login_name.send_keys(fanfou_account) + login_pass.send_keys(fanfou_password) + login_pass.submit() -def run(instance, access_token): mastodon_cli = Mastodon( access_token=access_token, api_base_url=instance) me_info = mastodon_cli.me() @@ -12,11 +35,58 @@ def run(instance, access_token): me_id, exclude_replies=True) min_id = None max_id = None + # first time run + # init min_id for status in me_timeline: if not status['reblog'] and status['visibility'] == 'public': min_id = status['id'] + print(status['content']) break + # if is in already posted status + posted_ids = [] + # if file not exist, create it + with open('last_id.txt', 'a+') as f: + f.seek(0) + # read lines + posted_ids = f.readlines() + # remove \n + posted_ids = [x.strip() for x in posted_ids] + print(posted_ids) + if str(min_id) not in posted_ids: + content = status['content'].replace('
', '').replace('
', '').replace('', '').replace('
', '').replace('