stendhal icon indicating copy to clipboard operation
stendhal copied to clipboard

Trader Mastodon Bot

Open ghost opened this issue 4 years ago • 2 comments

💡 Describe your idea

Let's have a Mastodon bot for Harold, just like we have one on Twitter!

I, for one, would surely follow it :wink:

🔬 Motivation

Some players (like myself) do not use Twitter but do use Mastodon, and might like to have a Stendhal bot to follow there.

Its presence might also attract a new player or two.

📝 Alternatives

I had a look through the code to see how this is done. If I understand correctly, PrepareOfferHandler is where we start a AsynchronousProgramExecutor which runs an executable (configured in the stendhal.program.trade property) with the tweet message as a parameter.

Variant 1

I'm thinking of starting a second instance of AsynchronousProgramExecutor, for the new program that will "toot" (that's like tweeting, but for Mastodon).

Variant 2

Alternatively, we could adjust the existing program for Twitter to also post to Mastodon. By the way, is the source for the tweet program available somewhere?

🔭 Additional information

A possible instance for the bot account might be botsin.space, for example. Any other idea is welcome. Also, I would be willing to try to implement this feature myself.

Thoughts?

ghost avatar Aug 14 '20 12:08 ghost

The twitter program is basically the tutorial application:

#!/usr/bin/env python
 
import sys
import tweepy
 
CONSUMER_KEY = '...'
CONSUMER_SECRET = '...'

ACCESS_KEY = '....'
ACCESS_SECRET = '...'

 
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
api.update_status(sys.argv[1])

nhnb avatar Aug 14 '20 20:08 nhnb

I went with variant 1: a second instance of AsynchronousProgramExecutor. I did something similar to the tweet script, and tested on my test Mastodon instance.

#!/usr/bin/env python

import sys
from mastodon import Mastodon

CLIENT_KEY = '*****'
CLIENT_SECRET = '*****'
ACCESS_TOKEN = '*****'
API_BASE_URL = 'https://example.com/'

mastodon = Mastodon(
    client_id=CLIENT_KEY,
    client_secret=CLIENT_SECRET,
    access_token=ACCESS_TOKEN,
    api_base_url=API_BASE_URL
)

mastodon.toot(sys.argv[1])

Here's a screenshot of it in action: toot @nhnb, if you'd like to integrate this let's have a private chat.

ghost avatar Aug 15 '20 07:08 ghost

Sorry, this took years, literally.

https://mastodon.social/@stendhaltrade

nhnb avatar Oct 06 '23 17:10 nhnb