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",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"from time import sleep\n",
"from mastodon import Mastodon # https://github.com/halcy/Mastodon.py"
]
},
@ -48,20 +47,20 @@
"outputs": [],
"source": [
"instance = 'https://botsin.space'\n",
"username = 'info@varia.zone'\n",
"password = 'INSERTPASSWORDHERE'"
"# username = 'USERNAME'\n",
"# password = 'PASSWORD'"
]
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Register the bot as an application.\n",
"# Register the bot as an application, save details as a (.secret) plain text file.\n",
"\n",
"# This only needs to be done once!\n",
"# (we already did it :--))\n",
"# (we already did it)\n",
"\n",
"# Mastodon.create_app(\n",
"# 'bots-as-infrapunctures',\n",
@ -76,18 +75,21 @@
"metadata": {},
"outputs": [],
"source": [
"# First login.\n",
"# Write your login details to a (.secret) plain text file.\n",
"\n",
"mastodon = Mastodon(\n",
" client_id = 'mastodon-bot.secret',\n",
" api_base_url = instance\n",
")\n",
"# This only needs to be done once!\n",
"# (we already did it)\n",
"\n",
"mastodon.log_in(\n",
" username,\n",
" password,\n",
" to_file = 'mastodon-bot-usercred.secret'\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",
"# )"
]
},
{
@ -103,12 +105,34 @@
"metadata": {},
"outputs": [],
"source": [
"# Now let's run the bot!\n",
"# Start up the bot....\n",
"\n",
"mastodon = Mastodon(\n",
" access_token = 'mastodon-bot-usercred.secret',\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",
"toots = [\n",
" 'Sentence 1',\n",
@ -120,8 +144,62 @@
"\n",
"for toot in toots:\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": {

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

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