While tinkering about NWC and twitter I decided to hack a python script that might perhaps begin something good
Here's a high-level overview of how you could connect your Twitter account to a Nostr Wallet using NWC and automate a 21 satoshi payment for every like:
Prerequisites:
- Twitter Developer Account
- Nostr Wallet with NWC support (e.g., Alby, Nostrify)
- Twitter API credentials (API key, API secret key, Access token, Access token secret)
- Python script with Tweepy (Twitter API library) and nostr-client (Nostr library)
Step 1: Set up Twitter API credentials
Create a Twitter Developer account and obtain API credentials Install Tweepy using pip: pip install tweepy
Step 2: Connect Nostr Wallet using NWC
Choose a Nostr Wallet with NWC support (e.g., Alby, Nostrify) Set up the wallet and obtain the NWC credentials (e.g., public key, private key)
Step 3: Create a Python script
Import Tweepy and nostr-client libraries Authenticate with Twitter API using Tweepy Connect to Nostr Wallet using NWC credentials Define a function to send 21 satoshis for every like Use Tweepy to stream likes and trigger the payment function
Python
script:import tweepy
from nostr_client import Client
# Twitter API credentials
twitter_api_key = "YOUR_API_KEY"
twitter_api_secret_key = "YOUR_API_SECRET_KEY"
twitter_access_token = "YOUR_ACCESS_TOKEN"
twitter_access_token_secret = "YOUR_ACCESS_TOKEN_SECRET"
# Nostr Wallet NWC credentials
nwc_public_key = "YOUR_NWC_PUBLIC_KEY"
nwc_private_key = "YOUR_NWC_PRIVATE_KEY"
# Set up Tweepy
auth = tweepy.OAuthHandler(twitter_api_key, twitter_api_secret_key)
auth.set_access_token(twitter_access_token, twitter_access_token_secret)
api = tweepy.API(auth)
# Set up Nostr Client
nwc_client = Client()
nwc_client.connect(nwc_public_key, nwc_private_key)
# Define payment function
def send_satoshis():
# Create a new Nostr event with 21 satoshis
event = nwc_client.create_event(21)
# Send the event to the Nostr network
nwc_client.send_event(event)
# Stream likes and trigger payment function
class LikeStream(tweepy.StreamListener):
def on_like(self, like):
send_satoshis()
stream = tweepy.Stream(auth, LikeStream())
stream.filter(track=["likes"])