From 4d7c2844ab1e99b33bce67d53d6cfe3209a71b02 Mon Sep 17 00:00:00 2001 From: manetta Date: Fri, 2 Oct 2020 12:47:50 +0200 Subject: [PATCH] adding a mastodon bot notebook --- .../1-introduction.md | 0 .../10-theoretical-perspectives-on-bots.md | 0 .../11-andreas-question-1.md | 0 .../12-andreas-question-2.md | 0 .../13-andreas-question-3.md | 0 .../14-andreas-question-4.md | 0 .../15-andreas-question-5.md | 0 .../2-examples.md | 0 .../3-bot-logic.md | 0 .../4-bots-and-infrastructures.md | 0 .../5-question-1.md | 0 .../6-question-2.md | 0 .../7-question-3.md | 0 .../8-question-4.md | 0 .../9-question-5.md | 0 .../1-introduction.md | 0 .../2-step-1.md | 0 .../3-step-2.md | 0 .../4-step-3.md | 0 .../5-step-4.md | 0 .../1-introduction.md | 0 .../2-example-bot.md | 0 .../3-situated-bot-code.md | 0 .../mastodon-bot.ipynb | 213 ++++++++++++++++++ 24 files changed, 213 insertions(+) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/1-introduction.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/10-theoretical-perspectives-on-bots.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/11-andreas-question-1.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/12-andreas-question-2.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/13-andreas-question-3.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/14-andreas-question-4.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/15-andreas-question-5.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/2-examples.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/3-bot-logic.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/4-bots-and-infrastructures.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/5-question-1.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/6-question-2.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/7-question-3.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/8-question-4.md (100%) rename content/{Section 3 - Bot Logic => Section 3 - Bots}/9-question-5.md (100%) rename content/{Section 4 - Infrapunctural Imaginaries (exercise) => Section 5 - Infrapunctural Imaginaries (exercise)}/1-introduction.md (100%) rename content/{Section 4 - Infrapunctural Imaginaries (exercise) => Section 5 - Infrapunctural Imaginaries (exercise)}/2-step-1.md (100%) rename content/{Section 4 - Infrapunctural Imaginaries (exercise) => Section 5 - Infrapunctural Imaginaries (exercise)}/3-step-2.md (100%) rename content/{Section 4 - Infrapunctural Imaginaries (exercise) => Section 5 - Infrapunctural Imaginaries (exercise)}/4-step-3.md (100%) rename content/{Section 4 - Infrapunctural Imaginaries (exercise) => Section 5 - Infrapunctural Imaginaries (exercise)}/5-step-4.md (100%) rename content/{Section 5 - Critical Interventions Through Bots (exercise) => Section 6 - Critical Interventions Through Bots (exercise)}/1-introduction.md (100%) rename content/{Section 5 - Critical Interventions Through Bots (exercise) => Section 6 - Critical Interventions Through Bots (exercise)}/2-example-bot.md (100%) rename content/{Section 5 - Critical Interventions Through Bots (exercise) => Section 6 - Critical Interventions Through Bots (exercise)}/3-situated-bot-code.md (100%) create mode 100644 content/Section 6 - Critical Interventions Through Bots (exercise)/mastodon-bot.ipynb diff --git a/content/Section 3 - Bot Logic/1-introduction.md b/content/Section 3 - Bots/1-introduction.md similarity index 100% rename from content/Section 3 - Bot Logic/1-introduction.md rename to content/Section 3 - Bots/1-introduction.md diff --git a/content/Section 3 - Bot Logic/10-theoretical-perspectives-on-bots.md b/content/Section 3 - Bots/10-theoretical-perspectives-on-bots.md similarity index 100% rename from content/Section 3 - Bot Logic/10-theoretical-perspectives-on-bots.md rename to content/Section 3 - Bots/10-theoretical-perspectives-on-bots.md diff --git a/content/Section 3 - Bot Logic/11-andreas-question-1.md b/content/Section 3 - Bots/11-andreas-question-1.md similarity index 100% rename from content/Section 3 - Bot Logic/11-andreas-question-1.md rename to content/Section 3 - Bots/11-andreas-question-1.md diff --git a/content/Section 3 - Bot Logic/12-andreas-question-2.md b/content/Section 3 - Bots/12-andreas-question-2.md similarity index 100% rename from content/Section 3 - Bot Logic/12-andreas-question-2.md rename to content/Section 3 - Bots/12-andreas-question-2.md diff --git a/content/Section 3 - Bot Logic/13-andreas-question-3.md b/content/Section 3 - Bots/13-andreas-question-3.md similarity index 100% rename from content/Section 3 - Bot Logic/13-andreas-question-3.md rename to content/Section 3 - Bots/13-andreas-question-3.md diff --git a/content/Section 3 - Bot Logic/14-andreas-question-4.md b/content/Section 3 - Bots/14-andreas-question-4.md similarity index 100% rename from content/Section 3 - Bot Logic/14-andreas-question-4.md rename to content/Section 3 - Bots/14-andreas-question-4.md diff --git a/content/Section 3 - Bot Logic/15-andreas-question-5.md b/content/Section 3 - Bots/15-andreas-question-5.md similarity index 100% rename from content/Section 3 - Bot Logic/15-andreas-question-5.md rename to content/Section 3 - Bots/15-andreas-question-5.md diff --git a/content/Section 3 - Bot Logic/2-examples.md b/content/Section 3 - Bots/2-examples.md similarity index 100% rename from content/Section 3 - Bot Logic/2-examples.md rename to content/Section 3 - Bots/2-examples.md diff --git a/content/Section 3 - Bot Logic/3-bot-logic.md b/content/Section 3 - Bots/3-bot-logic.md similarity index 100% rename from content/Section 3 - Bot Logic/3-bot-logic.md rename to content/Section 3 - Bots/3-bot-logic.md diff --git a/content/Section 3 - Bot Logic/4-bots-and-infrastructures.md b/content/Section 3 - Bots/4-bots-and-infrastructures.md similarity index 100% rename from content/Section 3 - Bot Logic/4-bots-and-infrastructures.md rename to content/Section 3 - Bots/4-bots-and-infrastructures.md diff --git a/content/Section 3 - Bot Logic/5-question-1.md b/content/Section 3 - Bots/5-question-1.md similarity index 100% rename from content/Section 3 - Bot Logic/5-question-1.md rename to content/Section 3 - Bots/5-question-1.md diff --git a/content/Section 3 - Bot Logic/6-question-2.md b/content/Section 3 - Bots/6-question-2.md similarity index 100% rename from content/Section 3 - Bot Logic/6-question-2.md rename to content/Section 3 - Bots/6-question-2.md diff --git a/content/Section 3 - Bot Logic/7-question-3.md b/content/Section 3 - Bots/7-question-3.md similarity index 100% rename from content/Section 3 - Bot Logic/7-question-3.md rename to content/Section 3 - Bots/7-question-3.md diff --git a/content/Section 3 - Bot Logic/8-question-4.md b/content/Section 3 - Bots/8-question-4.md similarity index 100% rename from content/Section 3 - Bot Logic/8-question-4.md rename to content/Section 3 - Bots/8-question-4.md diff --git a/content/Section 3 - Bot Logic/9-question-5.md b/content/Section 3 - Bots/9-question-5.md similarity index 100% rename from content/Section 3 - Bot Logic/9-question-5.md rename to content/Section 3 - Bots/9-question-5.md diff --git a/content/Section 4 - Infrapunctural Imaginaries (exercise)/1-introduction.md b/content/Section 5 - Infrapunctural Imaginaries (exercise)/1-introduction.md similarity index 100% rename from content/Section 4 - Infrapunctural Imaginaries (exercise)/1-introduction.md rename to content/Section 5 - Infrapunctural Imaginaries (exercise)/1-introduction.md diff --git a/content/Section 4 - Infrapunctural Imaginaries (exercise)/2-step-1.md b/content/Section 5 - Infrapunctural Imaginaries (exercise)/2-step-1.md similarity index 100% rename from content/Section 4 - Infrapunctural Imaginaries (exercise)/2-step-1.md rename to content/Section 5 - Infrapunctural Imaginaries (exercise)/2-step-1.md diff --git a/content/Section 4 - Infrapunctural Imaginaries (exercise)/3-step-2.md b/content/Section 5 - Infrapunctural Imaginaries (exercise)/3-step-2.md similarity index 100% rename from content/Section 4 - Infrapunctural Imaginaries (exercise)/3-step-2.md rename to content/Section 5 - Infrapunctural Imaginaries (exercise)/3-step-2.md diff --git a/content/Section 4 - Infrapunctural Imaginaries (exercise)/4-step-3.md b/content/Section 5 - Infrapunctural Imaginaries (exercise)/4-step-3.md similarity index 100% rename from content/Section 4 - Infrapunctural Imaginaries (exercise)/4-step-3.md rename to content/Section 5 - Infrapunctural Imaginaries (exercise)/4-step-3.md diff --git a/content/Section 4 - Infrapunctural Imaginaries (exercise)/5-step-4.md b/content/Section 5 - Infrapunctural Imaginaries (exercise)/5-step-4.md similarity index 100% rename from content/Section 4 - Infrapunctural Imaginaries (exercise)/5-step-4.md rename to content/Section 5 - Infrapunctural Imaginaries (exercise)/5-step-4.md diff --git a/content/Section 5 - Critical Interventions Through Bots (exercise)/1-introduction.md b/content/Section 6 - Critical Interventions Through Bots (exercise)/1-introduction.md similarity index 100% rename from content/Section 5 - Critical Interventions Through Bots (exercise)/1-introduction.md rename to content/Section 6 - Critical Interventions Through Bots (exercise)/1-introduction.md diff --git a/content/Section 5 - Critical Interventions Through Bots (exercise)/2-example-bot.md b/content/Section 6 - Critical Interventions Through Bots (exercise)/2-example-bot.md similarity index 100% rename from content/Section 5 - Critical Interventions Through Bots (exercise)/2-example-bot.md rename to content/Section 6 - Critical Interventions Through Bots (exercise)/2-example-bot.md diff --git a/content/Section 5 - Critical Interventions Through Bots (exercise)/3-situated-bot-code.md b/content/Section 6 - Critical Interventions Through Bots (exercise)/3-situated-bot-code.md similarity index 100% rename from content/Section 5 - Critical Interventions Through Bots (exercise)/3-situated-bot-code.md rename to content/Section 6 - Critical Interventions Through Bots (exercise)/3-situated-bot-code.md diff --git a/content/Section 6 - Critical Interventions Through Bots (exercise)/mastodon-bot.ipynb b/content/Section 6 - Critical Interventions Through Bots (exercise)/mastodon-bot.ipynb new file mode 100644 index 0000000..8fc55b2 --- /dev/null +++ b/content/Section 6 - Critical Interventions Through Bots (exercise)/mastodon-bot.ipynb @@ -0,0 +1,213 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Defaulting to user installation because normal site-packages is not writeable\n", + "Requirement already satisfied: Mastodon.py in /home/mb/.local/lib/python3.7/site-packages (1.5.1)\n", + "Requirement already satisfied: python-magic in /usr/local/lib/python3.7/dist-packages (from Mastodon.py) (0.4.15)\n", + "Requirement already satisfied: pytz in /home/mb/.local/lib/python3.7/site-packages (from Mastodon.py) (2020.1)\n", + "Requirement already satisfied: python-dateutil in /home/mb/.local/lib/python3.7/site-packages (from Mastodon.py) (2.8.1)\n", + "Requirement already satisfied: blurhash>=1.1.4 in /home/mb/.local/lib/python3.7/site-packages (from Mastodon.py) (1.1.4)\n", + "Requirement already satisfied: requests>=2.4.2 in /usr/lib/python3/dist-packages (from Mastodon.py) (2.21.0)\n", + "Requirement already satisfied: decorator>=4.0.0 in /usr/lib/python3/dist-packages (from Mastodon.py) (4.3.0)\n", + "Requirement already satisfied: six in /usr/lib/python3/dist-packages (from Mastodon.py) (1.12.0)\n" + ] + } + ], + "source": [ + "import sys\n", + "!{sys.executable} -m pip install Mastodon.py" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "from mastodon import Mastodon" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "instance = 'INSERTYOURINSTANCEURLHERE'\n", + "username = 'INSERTEMAILADDRESSHERE'\n", + "password = 'INSERTPASSWORDSHERE'" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('ijslOh1kdBmHnlycZUhP6bpB0wXayAXqZ_Qr4DMB09Y',\n", + " '-TZBLBW2XOrwOoCb2mbIWdxALRS8QiHIgIosrq2PqsE')" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Register your app! This only needs to be done once. Uncomment the code and substitute in your information.\n", + "\n", + "Mastodon.create_app(\n", + " 'bots-as-infrapuncture',\n", + " api_base_url = instance,\n", + " to_file = 'mastodon-bot.secret'\n", + ")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'497bMScwM_Z1goP0Q_lNUsmbmbYByw3XXb-6KBxt-K8'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Then login. This can be done every time, or use persisted.\n", + "\n", + "mastodon = Mastodon(\n", + " client_id = 'mastodon-bot.secret',\n", + " api_base_url = instance\n", + ")\n", + "\n", + "mastodon.log_in(\n", + " username,\n", + " password,\n", + " to_file = 'mastodon-bot-usercred.secret'\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'id': 104964779309814302,\n", + " 'created_at': datetime.datetime(2020, 10, 2, 10, 43, 46, 538000, tzinfo=tzutc()),\n", + " 'in_reply_to_id': None,\n", + " 'in_reply_to_account_id': None,\n", + " 'sensitive': False,\n", + " 'spoiler_text': '',\n", + " 'visibility': 'public',\n", + " 'language': 'en',\n", + " 'uri': 'https://post.lurk.org/users/manetta/statuses/104964779309814302',\n", + " 'url': 'https://post.lurk.org/@manetta/104964779309814302',\n", + " 'replies_count': 0,\n", + " 'reblogs_count': 0,\n", + " 'favourites_count': 0,\n", + " 'local_only': False,\n", + " 'activity_pub_type': '',\n", + " 'favourited': False,\n", + " 'reblogged': False,\n", + " 'muted': False,\n", + " 'bookmarked': False,\n", + " 'pinned': False,\n", + " 'content': '

Testing to toot for the very very first time, excitingly using #mastodonpy !

',\n", + " 'reblog': None,\n", + " 'application': {'name': 'bagofwords', 'website': None},\n", + " 'account': {'id': 4791,\n", + " 'username': 'manetta',\n", + " 'acct': 'manetta',\n", + " 'display_name': 'manetta',\n", + " 'locked': False,\n", + " 'bot': False,\n", + " 'discoverable': False,\n", + " 'group': False,\n", + " 'created_at': datetime.datetime(2018, 5, 2, 18, 32, 50, 698000, tzinfo=tzutc()),\n", + " 'note': '

software studies networks publishing (#nobot)

',\n", + " 'url': 'https://post.lurk.org/@manetta',\n", + " 'avatar': 'https://post.lurk.org/system/accounts/avatars/000/004/791/original/9ce0ebe273ada8aa.jpg?1584822874',\n", + " 'avatar_static': 'https://post.lurk.org/system/accounts/avatars/000/004/791/original/9ce0ebe273ada8aa.jpg?1584822874',\n", + " 'header': 'https://post.lurk.org/system/accounts/headers/000/004/791/original/5e99159ef049b6dc.png?1584823076',\n", + " 'header_static': 'https://post.lurk.org/system/accounts/headers/000/004/791/original/5e99159ef049b6dc.png?1584823076',\n", + " 'followers_count': 134,\n", + " 'following_count': 175,\n", + " 'statuses_count': 154,\n", + " 'last_status_at': datetime.datetime(2020, 10, 2, 0, 0),\n", + " 'emojis': [],\n", + " 'fields': []},\n", + " 'media_attachments': [],\n", + " 'mentions': [],\n", + " 'tags': [{'name': 'mastodonpy',\n", + " 'url': 'https://post.lurk.org/tags/mastodonpy'}],\n", + " 'emojis': [],\n", + " 'card': None,\n", + " 'poll': None}" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# To post, create an actual API instance.\n", + "\n", + "mastodon = Mastodon(\n", + " access_token = 'mastodon-bot-usercred.secret',\n", + " api_base_url = instance\n", + ")\n", + "\n", + "mastodon.toot('Testing to toot for the very very first time, excitingly using #mastodonpy !')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}