Discord Bot

Notes Token generation was tricky because I already created one. To create a new one, I needed to navigate to Bot then click on the Reset Token button. I’ll need to regenerate a new one since I showed it to everyone on stream. Oops. Unsure what Discord Intents are used for. I got it to work but what is the difference between this and scopes. Initially did not work because of the following error message:...

November 27, 2022

Chatbot With Yuka

!focus command and she copies the person + description to a spreadsheet !raffle that maybe picks a winner or at least preps counts of entries. This could be a good idea but we could get this done on the monthly rotation. How we will maybe do things !focus command and she copies the person + description to a spreadsheet !raffle that maybe picks a winner or at least preps counts of entries...

October 9, 2022

Puppeteer Interceptor

Save requests and responses with puppeteer From apify’s blog post, they intercept requests from puppeteer using the following code snippet: // On top of your code const cache = {}; // The code below should go between newPage function and goto function await page.setRequestInterception(true); page.on('request', async(request) => { const url = request.url(); if (cache[url] && cache[url].expires > Date.now()) { await request.respond(cache[url]); return; } request.continue(); }); page.on('response', async(response) => { const url = response....

October 2, 2022

Asyncio Tasks, Part 2

Investigation Bot and asyncio task block each other for reason. Tried calling asyncio.create_task separately from the chatbot. This appears to block the chat commands. Tried to move logic for the word tracker in the chatbot on event_ready. This did not work because any chat commands that get called after the asyncio.ensure_future(recordWordsFromMicrophone(self.wt)) appears to block / none of the commands work. Digging into the documentation, it appears that ensure future blocks until future is cancelled so this definitely should not work....

September 24, 2022

Asyncio Tasks, Part 1

Task Completed Changed WordPair to TrackedWord Create journal using colemak layout to type. Future work Fire and forgetting. We could use the twichio.ext.routines to schedule sending chat the top words said during stream in an interval. Call the chat bot and word tracker separately without blocking each other. Use GitHub integrations to run Python test with Poetry. Useful Links Fire and forget python https://stackoverflow.com/a/37345564 Asycio tasks https://docs.python.org/3/library/asyncio-task.html#creating-tasks

September 14, 2022

Chatbot Connect With Asyncio

From yesterday off stream try: bot = Bot() await bot.connect() await asyncio.wait_for(bot.wait_for_ready(), timeout=10.0) print(f"connected at {time.strftime('%X')}") channel = bot.get_channel("bedtimebear_808") await channel.send("hello world") print(f"sent a hello world message at {time.strftime('%X')}") finally: await channel.send("closed") print(f"sent a closed message at {time.strftime('%X')}") await bot.close() print(f"closed at {time.strftime('%X')}") console log ➤ python3 main.py started at 20:05:36 Logged in as | bedtimebear_bot User id is | 549829723 connected at 20:05:36 sent a hello world message at 20:05:36 sent a closed message at 20:05:36 closed at 20:05:36 output at twitch....

September 12, 2022

Asyncio Word Tracker (part 2)

Tasks completed Debug asyncio gather and coroutines in Python. Shortened the record time and used the asyncio.gather function to run them in parallel. This change allowed updates to the word counts dictionary along with getting the top words on the list. We fixed all words to lowercase. This is helpful to prevent the following: [WordPair(word='Fish', count=6)] and [WordPair(word='fish', count=11)] Code snippet: async def getWords(wt): words = wt.getTopWordsTracker() print(f"time: {time.strftime('%X')}") print(words) async def main(): wt = WordTracker() while True: L = await asyncio....

September 10, 2022

Asyncio Word Tracker

Things we tried We tried to run an async function without awaiting. This is not possible in Python. We tried to run a multiple async functions that do not end. The problem is that function 1 does not return and function 2 never seems to start. We tried this with the asyncio.gather function. See code snippet: await asyncio.gather( asyncFunThatNeverEnds1(), asyncFunThatNeverEnds2() ) Alternatively, the gather function should have shorter lived functions. What we should check are timestamps here so that we do not miss words....

August 21, 2022

Hugo Firebase

How do we move our website to firebase? https://gohugo.io/hosting-and-deployment/hosting-on-firebase/ Setup npm install -g firebase-tools firebase login firebase init at the base on the hugo project During setup, I was able to associate this project with the GCP project already created (“cnishina-dev-blog”). In addition, I selected the following options: hosting default for the publish directory as public selected “No” in reference to deploying a single-page app Deploying hugo && firebase deploy...

August 8, 2022

Help With Server Stats Website

Stream Notes This was another short stream. Hopefully I do not have covid. Earlier today I was watching sockheadrps on stream working on this chart. This is to help with his main project https://github.com/sockheadrps/ServerStats and the code he was working on was https://github.com/sockheadrps/test_chart. The test chart code was based on a Gist on shifting data. During the stream we helped debug how if the data was being shifted off the array and drawn....

August 7, 2022