Wow, for FREE i just prompted a whole (untested!) javascript bot code for a twitter hive account creation mirror upvote like bot. Wow. But can anyone test or help me test this google gemini ai javascript code i asked it to make me? Looks incredible.

in voilk •  2 days ago

    Ok first i asked the FREE google gemini (successor to OK Google) if it could code me custom json hive blog blockchain transaction javascript thingies and it gave me this first. And below is the second question where i asked for the actual code of a specific example javascript bot that creates an account and upvotes it when uts linked account in twitte gets a link. Altho now i realize it will need to specificy how ro name and keep track etc and limit ro 12 characters so may need more custom libraries etc. It will be fun thiigh to use this to learn coding wow just wow i already learned so much with this. Bit i see it will need to be NUANCED by an exoeiremced hive dev! But now we can all PRACTICE and have ai make us hive dapp code and we can run it and practice trouble shooting learning hives limits etc. But this is so fun. And useful. Just wow. And i cant believe its all free.

    Eventually we will not even have to run the codes ourselevs althoigh that i believe will.be great practice...but gemini will even soon just start running it live and we will have dapps that actuveky evolve and change like they are alive or hah just dynamic hive dapps with ai coding them changing them to adaot to hive blockchain actions etc

    Screenshot_20250107_124012_Google.jpg

    Screenshot_20250107_123948_Google.jpg

    Screenshot_20250107_123943_Google.jpg

    Screenshot_20250107_123933_Google.jpg

    Screenshot_20250107_123922_Google.jpg

    Screenshot_20250107_123910_Google.jpg


    Then i got this Gem of a google gemini answer when i asked to make me a javascript not that upvotes and creatds an account on hive when its liked twitter account likes an account on twitter.

    https://g.co/gemini/share/7028c146a315 - public link to a record of my prompt convo

    Screenshot_20250107_125309_Google.jpg

    Screenshot_20250107_125304_Google.jpg

    Screenshot_20250107_125258_Google.jpg

    Screenshot_20250107_125253_Google.jpg

    Screenshot_20250107_125249_Google.jpg

    Screenshot_20250107_125245_Google.jpg

    Screenshot_20250107_125241_Google.jpg

    Screenshot_20250107_125235_Google.jpg

    Screenshot_20250107_125231_Google.jpg

    Screenshot_20250107_125215_Google.jpg

    const { Api } = require('hive-js');

    const api = new Api();

    // Replace with your active Hive account keys
    const postingKey = 'YOUR_POSTING_KEY';

    // Twitter API credentials (replace with your own)
    const twitterClient = require('twitter');
    const client = new twitterClient({
    consumer_key: 'YOUR_CONSUMER_KEY',
    consumer_secret: 'YOUR_CONSUMER_SECRET',
    access_token_key: 'YOUR_ACCESS_TOKEN_KEY',
    access_token_secret: 'YOUR_ACCESS_TOKEN_SECRET'
    });

    // Define the trigger command (e.g., "!hiveup < username>")
    const triggerCommand = "!hiveup ";

    // Function to handle incoming tweets
    const onTweet = async (tweet) => {
    try {
    if (tweet.text.startsWith(triggerCommand)) {
    const username = tweet.text.replace(triggerCommand, '').trim();

      // Create a Hive account (replace with your desired account creation logic)
      const newAccount = await api.createAccount(username, postingKey);
    
      // Upvote the new account's first post (assuming they make one immediately)
      const options = {
        voter: 'your_hive_username',
        author: username,
        permlink: 'first-post', // Replace with the actual permlink of the first post
        weight: 100 
      };
      await api.vote(options, postingKey);
    
      console.log(`Successfully upvoted ${username}'s first post on Hive.`);
    }
    

    } catch (error) {
    console.error(Error processing tweet:, error);
    }
    };

    // Stream tweets that match the user's mentions
    const stream = client.stream('statuses/filter', { track: @${client.getScreenName()} });

    stream.on('data', onTweet);

    stream.on('error', (error) => {
    console.error(error);
    });

    console.log("Bot started. Listening for tweets...");

    Explanation:

    • Import necessary libraries:
      • hive-js: For interacting with the Hive blockchain.
      • twitter: For interacting with the Twitter API.
    • Initialize Hive API and Twitter Client:
      • Create an instance of the Api class from hive-js.
      • Initialize the Twitter client with your API credentials.
    • Define Trigger Command:
      • Define the command that will trigger the bot (e.g., !hiveup < username>).
    • onTweet Function:
      • This function handles incoming tweets.
      • It checks if the tweet starts with the trigger command.
      • If it does, it extracts the target username.
      • Create Hive Account:
        • This part needs to be implemented. You'll need to define the logic for creating a Hive account using the api.createAccount method from hive-js.
        • Important: Ensure you have the necessary permissions and follow Hive's terms of service for account creation.
      • Upvote First Post:
        • Upvote the target user's first post on Hive using the api.vote method.
    • Stream Tweets:
      • Use the Twitter client to stream tweets that mention the bot's account.
      • Pass the onTweet function to the stream's data event to handle incoming tweets.
    • Error Handling:
      • Implement error handling to gracefully handle potential issues like network errors, API rate limits, or invalid input.
        Important Notes:
    • Replace placeholders:
      • Replace YOUR_POSTING_KEY, YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET, YOUR_ACCESS_TOKEN_KEY, and YOUR_ACCESS_TOKEN_SECRET with your actual API keys.
      • Replace your_hive_username with your actual Hive username.
    • Account Creation Logic:
      • This is a crucial part of the bot. You need to carefully consider the logic for creating Hive accounts. Ensure that you comply with Hive's terms of service and avoid any actions that could be considered spam or abuse.
    • Rate Limits: Be mindful of Twitter and Hive API rate limits. Implement appropriate rate-limiting mechanisms to avoid exceeding these limits and getting your bot blocked.
    • Security:
      • Store your API keys securely and avoid hardcoding them directly in your code.
    • Testing:
      • Thoroughly test your bot in a development environment before deploying it to production.
        This is a basic example, and you can customize it further based on your specific requirements.
        Remember to prioritize security, ethical considerations, and compliance with the terms of service of both Twitter and Hive.
        I hope this helps! Let me know if you have any further questions or require more specific guidance.

    ------ok thats the end of the google gemini code----
    Now this is me ackza again

    Ok so did this javascript pass? Or is it trash?

    Is this actually useful as a tool? Is that code i made usable? I bet if i just learned all the detailed nuances of how hive needs to work this could be a great to practice coding where the code itself is posted on hive blog and shared on chain etc. I dunno this stuff just seems so exciting and is what ive been daying we would hqve for the last few years...ive been excited for this for a while now.

      Authors get paid when people like you upvote their post.
      If you enjoyed what you read here, create your account today and start earning FREE VOILK!