<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>bot &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/bot/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Mon, 28 Jul 2025 20:57:33 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>bot &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[Set your domain name as your handle for a BlueSky bot which is bridged from the Fediverse]]></title>
		<link>https://shkspr.mobi/blog/2024/11/set-your-domain-name-as-your-handle-for-a-bluesky-bot-which-is-bridged-from-the-fediverse/</link>
					<comments>https://shkspr.mobi/blog/2024/11/set-your-domain-name-as-your-handle-for-a-bluesky-bot-which-is-bridged-from-the-fediverse/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Thu, 14 Nov 2024 12:34:32 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[BlueSky]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[fediverse]]></category>
		<category><![CDATA[mastodon]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=53849</guid>

					<description><![CDATA[If you&#039;ve found this page, it&#039;s because you are me in the future and want to remember these instructions!   Create an account on the Fediverse using a domain you control   For example @user@bots.example.com  Follow the Fediverse-ATProto bridge @bsky.brid.gy@bsky.brid.gy   Your account will need to be over 2 weeks old and have a name, profile picture, etc.  You now have an account on BSky! Its…]]></description>
										<content:encoded><![CDATA[<p>If you've found this page, it's because you are me in the future and want to remember these instructions!</p>

<ol start="0">
<li>Create an account on the Fediverse using a domain you control

<ul>
<li>For example <code>@user@bots.example.com</code></li>
</ul></li>
<li><a href="https://fed.brid.gy/docs#fediverse-get-started">Follow the Fediverse-ATProto bridge</a> <code>@bsky.brid.gy@bsky.brid.gy</code>

<ul>
<li><a href="https://fed.brid.gy/docs#troubleshooting">Your account will need to be over 2 weeks old and have a name, profile picture, etc</a>.</li>
</ul></li>
<li>You now have an account on BSky! Its name will be something like <code>user.bots.example.com.ap.brid.gy</code></li>
<li>Get the DID of your account

<ul>
<li><code>https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=user.bots.example.com.ap.brid.gy</code></li>
<li>Or <code>https://fed.brid.gy/ap/@user@bots.example.com</code></li>
</ul></li>
<li><a href="https://atproto.com/specs/handle#handle-resolution">Add the DID to your domain</a>

<ul>
<li>I think the easiest way is sticking it in a plain text file at <code>bots.example.com/.well-known/atproto-did</code></li>
</ul></li>
<li>Use the <a href="https://bsky-debug.app/handle?handle=user.bots.example.com.ap.brid.gy">BSky Debugger</a> to make sure it was successful.</li>
<li>Send a Direct Message from the Fediverse to <code>@bsky.brid.gy@bsky.brid.gy</code>. The message must only contain <code>username bots.example.com</code>.

<ul>
<li>That's <em>literally</em> the word <code>username</code>. It isn't your account's username.</li>
</ul></li>
<li>Wait a few moments.</li>
<li>Your bot will now be on BSky as <code>https://bsky.app/profile/bots.example.com</code>!</li>
</ol>

<p>You can see that <a href="https://bot.viii.fi/bot">https://bot.viii.fi/bot</a> is also available at <a href="https://bsky.app/profile/bot.viii.fi">https://bsky.app/profile/bot.viii.fi</a></p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=53849&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2024/11/set-your-domain-name-as-your-handle-for-a-bluesky-bot-which-is-bridged-from-the-fediverse/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Introducing ActivityBot - the simplest way to build Mastodon Bots]]></title>
		<link>https://shkspr.mobi/blog/2024/11/introducing-activitybot-the-simplest-way-to-build-mastodon-bots/</link>
					<comments>https://shkspr.mobi/blog/2024/11/introducing-activitybot-the-simplest-way-to-build-mastodon-bots/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Sun, 10 Nov 2024 12:34:00 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[ActivityPub]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[fediverse]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=53728</guid>

					<description><![CDATA[As you may have read, BotsIn.Space is closing down, I have lots of automated bot accounts living on the Fediverse - and I want them to continue posting.  Installing and maintaining an entire Mastodon instance sounds like hard work. Paying people to host my stuff feels like putting my fate in someone else&#039;s hands.  Say… didn&#039;t I write my own ActivityPub server? Why, yes! Yes I did!  I took the c…]]></description>
										<content:encoded><![CDATA[<p>As you may have read, <a href="https://muffinlabs.com/posts/2024/10/29/10-29-rip-botsin-space/">BotsIn.Space is closing down</a>, I have lots of automated bot accounts living on the Fediverse - and I want them to continue posting.  Installing and maintaining an entire Mastodon instance sounds like hard work. Paying people to host my stuff feels like putting my fate in someone else's hands.</p>

<p>Say… didn't I write <a href="https://shkspr.mobi/blog/2024/03/updates-to-activitypub-in-a-single-php-file/">my own ActivityPub server</a>? Why, yes! Yes I did!</p>

<p>I took the code and stripped it down to the bare essentials. All you need to do is upload two files<sup id="fnref:env"><a href="https://shkspr.mobi/blog/2024/11/introducing-activitybot-the-simplest-way-to-build-mastodon-bots/#fn:env" class="footnote-ref" title="You can also upload a .env file for your configuration if you want." role="doc-noteref">0</a></sup> - <code>index.php</code> and <code>.htaccess</code> - fill in your details, and you're done.</p>

<p><a href="https://gitlab.com/edent/activity-bot/">Get the ActivityBot source code on GitLab</a>.</p>

<p>There's no database, no containers, no caching. It is as simple as I could make it</p>

<p>This bot can do the following:</p>

<ul>
<li>🔍 Be discovered on the Fediverse</li>
<li>👉 Be followed by other accounts</li>
<li>🚫 Be unfollowed by accounts</li>
<li>📩 Send messages to the Fediverse</li>
<li>💌 Send direct messages to users</li>
<li>🖼️ Attach an image &amp; alt text to a message</li>
<li>🕸️ Autolink URls, hashtags, and @ mentions</li>
<li>🚚 Move followers from an old account</li>
<li>🔏 Verify cryptographic signatures</li>
<li>🪵 Log sent messages and error.</li>
</ul>

<p>That's it! Here's what it <em>doesn't</em> do:</p>

<ul>
<li>❌ Receive messages (other than follows and unfollows)</li>
<li>❌ Thread replies</li>
<li>❌ Delete or update a post</li>
<li>❌ Create Polls</li>
<li>❌ Attach multiple images</li>
<li>❌ Set focus point for images</li>
<li>❌ Set sensitivity for images / blur</li>
<li>❌ Set "Content Warning"</li>
<li>❌ Accurate support for converting user's text to HTML</li>
<li>❌ Cannot be discovered by Lemmy instances</li>
</ul>

<p>Grab a subdomain (don't buy a whole new domain name!) and <a href="https://gitlab.com/edent/activity-bot/">stick this code on it</a>. You'll have an ActivityPub bot running in minutes.</p>

<p>You can follow one of my bots <code>@colours@colours.bots.edent.tel</code></p>

<p>Feedback very much welcome.</p>

<div id="footnotes" role="doc-endnotes">
<hr aria-label="Footnotes">
<ol start="0">

<li id="fn:env">
<p>You can also upload a <code>.env</code> file for your configuration if you want.&nbsp;<a href="https://shkspr.mobi/blog/2024/11/introducing-activitybot-the-simplest-way-to-build-mastodon-bots/#fnref:env" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>

</ol>
</div>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=53728&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2024/11/introducing-activitybot-the-simplest-way-to-build-mastodon-bots/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Easy guide to building Mastodon bots]]></title>
		<link>https://shkspr.mobi/blog/2018/08/easy-guide-to-building-mastodon-bots/</link>
					<comments>https://shkspr.mobi/blog/2018/08/easy-guide-to-building-mastodon-bots/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Tue, 21 Aug 2018 06:33:49 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[mastodon]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=30249</guid>

					<description><![CDATA[Twitter is dead! Long live Mastodon!  I&#039;ve written lots of &#039;bots for Twitter - and been part of their developer outreach programme. Lots of us have politely requested improvements to the bot experience on Twitter, but to no avail.  So, today I&#039;m going to show you how to quickly and easily write your first Mastodon-bot.  Bots In Spaaaaaaace  Step 1 - you need to set up a new account for your bot.  …]]></description>
										<content:encoded><![CDATA[<p><a href="https://medium.com/@jukesie/the-great-mastadon-migration-of-2018-495fe79e80c5">Twitter is dead</a>! Long live Mastodon!</p>

<p>I've written lots of 'bots for Twitter - and been part of their developer outreach programme. Lots of us have politely requested improvements to the bot experience on Twitter, but to no avail.</p>

<p>So, today I'm going to show you how to quickly and easily write your first Mastodon-bot.</p>

<h2 id="bots-in-spaaaaaaace"><a href="https://shkspr.mobi/blog/2018/08/easy-guide-to-building-mastodon-bots/#bots-in-spaaaaaaace">Bots In Spaaaaaaace</a></h2>

<p>Step 1 - you need to set up a new account for your bot.  Create it on <a href="https://BotsIn.Space/">https://BotsIn.Space/</a> - a Mastodon instance specifically for robots.</p>

<p>Set it up just like a regular account. Give it a name, an avatar image, and a description.  As you edit the profile, be sure to tick the box marked "This is a bot account".</p>

<img src="https://shkspr.mobi/blog/wp-content/uploads/2018/08/Screenshot_2018-08-19-Edit-profile-botsin-space-fs8.png" alt="Bio set up page." width="440" height="213" class="aligncenter size-full wp-image-30251">

<p>Like Twitter, there's no way to officially link a bot to its owner.  I suggest using the profile metadata to say who you are. But that's optional.</p>

<p>Step 2 - create an application.  Unlike Twitter, you don't have to sign up for a development programme. Nor do you have to verify yourself with a phone number.  Just go to preferences and click Development.</p>

<p>You need to set an application name - that's it. You can ignore all the other fields.  By default your bot can read and write its own timeline.
<img src="https://shkspr.mobi/blog/wp-content/uploads/2018/08/Screenshot_2018-08-19-New-application-botsin-space-fs8.png" alt="New application page." width="698" height="423" class="aligncenter size-full wp-image-30252">
Hit save when you're done.</p>

<p>Click on the name of your application - and you'll see some long alphanumeric strings. These are your secret tokens.
<img src="https://shkspr.mobi/blog/wp-content/uploads/2018/08/Screenshot_2018-08-19-Application-test-botsin-space-fs8.png" alt="API keys." width="414" height="258" class="aligncenter size-full wp-image-30250">
Do not share these with anyone. Don't take screenshots of them and post them online.</p>

<p>You're going to need "Your access token" for the next stage.</p>

<h2 id="python"><a href="https://shkspr.mobi/blog/2018/08/easy-guide-to-building-mastodon-bots/#python">Python</a></h2>

<p>I'm going to assume you're using Python 3.  These instructions will work on Linux. You may need to adjust this depending on your software.</p>

<p>Step 3 - we're going to use the <a href="https://github.com/halcy/Mastodon.py">Mastodon.py</a> library.</p>

<p>On the commandline, run:</p>

<pre><code class="language-_">pip3 install Mastodon.py
</code></pre>

<p>After a few moments, your library will be installed.</p>

<p>Step 4 - create a new file called <code>token.secret</code>
In this file, paste the long alphanumeric string from "Your access token". Make sure you don't have a space at the start or end of the string. Save the file.</p>

<p>Step 5 - create a new file called <code>bot.py</code>
Paste the following into the file:</p>

<pre><code class="language-python">from mastodon import Mastodon

#   Set up Mastodon
mastodon = Mastodon(
    access_token = 'token.secret',
    api_base_url = 'https://botsin.space/'
)

mastodon.status_post("hello world!")
</code></pre>

<p>Step 6 - run the file using</p>

<pre><code class="language-_">python3 bot.py
</code></pre>

<p>You bot will "toot" - that is, post a message on Mastodon.</p>

<p>If all you want to do is automagically toot something - that's it. You're done. Shouldn't take you longer than 5 minutes.</p>

<h2 id="images"><a href="https://shkspr.mobi/blog/2018/08/easy-guide-to-building-mastodon-bots/#images">Images</a></h2>

<p>You can post up to 4 images on Mastodon.</p>

<p>Assuming you have the image save as <code>test.png</code> here's the code you need:</p>

<pre><code class="language-python">media = mastodon.media_post("test.png", description="Some alt text.")
mastodon.status_post("What a great image!", media_ids=media)
</code></pre>

<p>Want to upload multiple images?</p>

<pre><code class="language-python">media1 = mastodon.media_post("1.jpg", description="A photo of a lovely horse.")
media2 = mastodon.media_post("2.png", description="A diagram of a starship's warp core.")
media3 = mastodon.media_post("3.jpg", description="A drawing .")
media4 = mastodon.media_post("4.gif", description="An animation of a dancing polar bear.")
mastodon.status_post("Lots of photos.", media_ids=[media1,media2,media3,media4])
</code></pre>

<p>There we go, nice and easy!</p>

<h2 id="demo"><a href="https://shkspr.mobi/blog/2018/08/easy-guide-to-building-mastodon-bots/#demo">Demo!</a></h2>

<p>You can follow my <a href="https://web.archive.org/web/20200924123941/https://botsin.space/@colours">Colours bot</a></p>

<h2 id="what-about"><a href="https://shkspr.mobi/blog/2018/08/easy-guide-to-building-mastodon-bots/#what-about">What about...?</a></h2>

<p>This is just a basic guide to getting your bot to post to Mastodon. If there's interest, I'll write about other topics.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=30249&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2018/08/easy-guide-to-building-mastodon-bots/feed/</wfw:commentRss>
			<slash:comments>23</slash:comments>
		
		
			</item>
	</channel>
</rss>
