Compare commits
No commits in common. "d7e74db70371ac693a361ee3491dd69b3787fb08" and "55c0733a4016ede2072c548b601d20ec7c571dc7" have entirely different histories.
d7e74db703
...
55c0733a40
1 changed files with 2 additions and 38 deletions
40
main.py
Executable file → Normal file
40
main.py
Executable file → Normal file
|
@ -2,12 +2,11 @@
|
|||
from mastodon import Mastodon
|
||||
import twitter
|
||||
|
||||
import sqlite3, json, re
|
||||
import sqlite3, json
|
||||
|
||||
cfg = {
|
||||
"cw":None,
|
||||
"mark_sensitive":True,
|
||||
"site":"https://botsin.space"
|
||||
"mark_sensitive":True
|
||||
}
|
||||
try:
|
||||
j = json.load(open("config.json"))
|
||||
|
@ -53,44 +52,9 @@ if "twitter" not in cfg:
|
|||
|
||||
json.dump(cfg, open("config.json", "w+"))
|
||||
|
||||
# log in to twitter
|
||||
api = twitter.Api(**cfg['twitter'])
|
||||
|
||||
if "accounts" not in cfg:
|
||||
print("Please specify the accounts you'd like Twitter Image Poster to learn from. Enter one account at a time formatted as '@user', followed by a blank line.")
|
||||
i = None
|
||||
accounts = []
|
||||
while i != "":
|
||||
i = input("User: ")
|
||||
if not re.match("@(\w){1,15}$", i):
|
||||
print("Invalid username")
|
||||
continue
|
||||
if i == "" and len(accounts) == 0:
|
||||
print("You must enter at least one account")
|
||||
continue
|
||||
print("Checking account...")
|
||||
print(api.GetUser(screen_name=i))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# connect to database
|
||||
|
||||
db = sqlite3.connect("tip.db")
|
||||
db.text_factory=str
|
||||
c = db.cursor()
|
||||
|
||||
c.execute("CREATE TABLE IF NOT EXISTS `images` (post_id INT NOT NULL UNIQUE PRIMARY KEY, user_id INT NOT NULL, image_url VARCHAR) WITHOUT ROWID")
|
||||
db.commit()
|
||||
last_tweet = c.execute("SELECT post_id FROM `images` WHERE user_id LIKE ? ORDER BY post_id DESC LIMIT 1", (f.id,)).fetchone()
|
||||
|
||||
print("Downloading tweets from {}".format())
|
||||
|
||||
client = Mastodon(
|
||||
client_id=cfg['client']['id'],
|
||||
client_secret = cfg['client']['secret'],
|
||||
access_token=cfg['secret'],
|
||||
api_base_url=cfg['site'])
|
||||
|
||||
|
||||
|
|
Reference in a new issue