Browse Source

adding the bot example WIP

master
manetta 4 years ago
parent
commit
c74c3956ef
  1. 2
      content/bot-example/mastodon-bot-usercred.secret
  2. 118
      content/bot-example/mastodon-bot.ipynb
  3. 3
      content/bot-example/mastodon-bot.secret

2
content/bot-example/mastodon-bot-usercred.secret

@ -0,0 +1,2 @@
3u3Y62FlUHMw4mDkSn3fBNusSUJLstnfOQcG9jLxkqI
https://botsin.space

118
content/bot-example/mastodon-bot.ipynb

@ -33,11 +33,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from time import sleep\n",
"from mastodon import Mastodon # https://github.com/halcy/Mastodon.py" "from mastodon import Mastodon # https://github.com/halcy/Mastodon.py"
] ]
}, },
@ -48,20 +47,20 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"instance = 'https://botsin.space'\n", "instance = 'https://botsin.space'\n",
"username = 'info@varia.zone'\n", "# username = 'USERNAME'\n",
"password = 'INSERTPASSWORDHERE'" "# password = 'PASSWORD'"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# Register the bot as an application.\n", "# Register the bot as an application, save details as a (.secret) plain text file.\n",
"\n", "\n",
"# This only needs to be done once!\n", "# This only needs to be done once!\n",
"# (we already did it :--))\n", "# (we already did it)\n",
"\n", "\n",
"# Mastodon.create_app(\n", "# Mastodon.create_app(\n",
"# 'bots-as-infrapunctures',\n", "# 'bots-as-infrapunctures',\n",
@ -76,18 +75,21 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# First login.\n", "# Write your login details to a (.secret) plain text file.\n",
"\n", "\n",
"mastodon = Mastodon(\n", "# This only needs to be done once!\n",
" client_id = 'mastodon-bot.secret',\n", "# (we already did it)\n",
" api_base_url = instance\n",
")\n",
"\n", "\n",
"mastodon.log_in(\n", "# mastodon = Mastodon(\n",
" username,\n", "# client_id = 'mastodon-bot.secret',\n",
" password,\n", "# api_base_url = instance\n",
" to_file = 'mastodon-bot-usercred.secret'\n", "# )\n",
")" "\n",
"# mastodon.log_in(\n",
"# username,\n",
"# password,\n",
"# to_file = 'mastodon-bot-usercred.secret'\n",
"# )"
] ]
}, },
{ {
@ -103,12 +105,34 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# Now let's run the bot!\n", "# Start up the bot....\n",
"\n", "\n",
"mastodon = Mastodon(\n", "mastodon = Mastodon(\n",
" access_token = 'mastodon-bot-usercred.secret',\n", " access_token = 'mastodon-bot-usercred.secret',\n",
" api_base_url = instance\n", " api_base_url = instance\n",
")\n", ")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Start tooting!\n",
"\n",
"mastodon.toot('testing tooting')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Another one, automized over a longer period of time\n",
"\n",
"from time import sleep\n",
"\n", "\n",
"toots = [\n", "toots = [\n",
" 'Sentence 1',\n", " 'Sentence 1',\n",
@ -120,8 +144,62 @@
"\n", "\n",
"for toot in toots:\n", "for toot in toots:\n",
" mastodon.toot(toot)\n", " mastodon.toot(toot)\n",
" sleep(300) # 5 minutes" " sleep(300) # 300 seconds = 5 minutes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Something with a dictionary\n",
"\n",
"vocabulary = {\n",
" \n",
"}"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Generate sentences ? \n",
"\n",
"names = ['', '', '']\n",
"objects = ['', '', '']\n",
"actions = ['', '', '']"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2020-11-05 17:31:54.233814\n"
]
}
],
"source": [
"# Using the current time\n",
"\n",
"from datetime import datetime\n",
"\n",
"print(datetime.now())\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {

3
content/bot-example/mastodon-bot.secret

@ -0,0 +1,3 @@
2wz3hSdmLQt4t16EORxzb87153nzDQknj0adFQW7eAc
eBarZRyu7EGyDWkiR8esBGeCkrpC12lJSJoHu0SywAI
https://botsin.space
Loading…
Cancel
Save