CyberPig123 / VirtualPet

A virtual pet
https://cyberpig123.github.io/VirtualPet
MIT License
5 stars 4 forks source link

i like it and have a little add to use with twitch #1

Open RonXTCdaBass opened 1 month ago

RonXTCdaBass commented 1 month ago

i found this and like it at the first view.

i made some lil changes in the design and addet a few lines to let the egg connect with twitch chat so i can use it as overlay in OBS or similar programs...

adding in the head of the "index.html"

<script src="https://github.com/tmijs/tmi.js/releases/download/v1.8.5/tmi.min.js"></script>

then i`ve addet in the "index.js"

/*************** Twitch Connection *********************/

const client = new tmi.Client({
    options: { debug: true },
                identity: {
                    username: 'YOUR-BOTNAME',
                    password: 'OAUTH:AAASSSDDDFFFXXX'
                },
    channels: [ 'YOUR-CHANNEL' ]
});

client.connect();

client.on('message', (channel, tags, message, self) => {
  // What we want to happen when a comment occurs
  console.log(`${tags['display-name']}: ${message}`);
  if (message === '!food') {
                        // select the element by finding the id of food button
document.querySelector(".food1").click();
      // say out loud.
        client.say(channel, `Thanks ${tags['display-name']} for feeding the Bot!!!`);
   }
   if (message === '!pet') {
                        // select the element by finding the id of pet
document.querySelector(".pet").click();
      // say out loud.
        client.say(channel, `Thank you ${tags['display-name']} for Bot petting!!!`);
   }
});

/************** Twitch Connection END *********************/

maybe someone like ^^ test_video

platy11 commented 2 days ago

Very nice idea, thank you for sharing it with us! I'm glad that you liked the virtual pet!