summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-xkim.py19
2 files changed, 21 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d489f33
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.jpg
+.env \ No newline at end of file
diff --git a/kim.py b/kim.py
new file mode 100755
index 0000000..04b6086
--- /dev/null
+++ b/kim.py
@@ -0,0 +1,19 @@
+import random, os, pathlib
+from mastodon import Mastodon
+from decouple import config
+
+# Mastodon token and domain
+mastodon = Mastodon(
+ access_token = config('token',default=''),
+ api_base_url = 'https://botsin.space/'
+)
+
+random_filename = random.choice([
+ x for x in os.listdir(pathlib.Path(__file__).parent.absolute())
+ if os.path.isfile(os.path.join(pathlib.Path(__file__).parent.absolute(), x)) and
+ x.endswith('.jpg')
+])
+
+# Upload PNG file to Mastodon
+media = mastodon.media_post(random_filename)
+mastodon.status_post("", media_ids=media) \ No newline at end of file