Skip to content

Commit

Permalink
Add all default plugins to core repository and remove the plugin down…
Browse files Browse the repository at this point in the history
…loading from the scripts
  • Loading branch information
Akul2010 committed Jul 30, 2023
1 parent 108f211 commit 53843ec
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 27 deletions.
26 changes: 26 additions & 0 deletions plugins/calendar/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const fs = require("fs");
const events = [];

const addEvent = (event, date) => {
events.push({event, date});
fs.writeFileSync("events.json", JSON.stringify(events));
console.log("Event added: " + event);
};

const checkEvents = () => {
setInterval(() => {
const now = new Date();
events.forEach((event) => {
const eventDate = new Date(event.date);
if (now.getTime() >= eventDate.getTime()) {
console.log("Reminder: " + event.event);
akulAI.speak("Reminder: " + event.event);
}
});
}, 60000);
};

module.exports = {
addEvent,
checkEvents
};
3 changes: 3 additions & 0 deletions plugins/calendar/plugin.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
author: Akul Goel
dependencies: fs
description: This plugin asks for events and stores them in a JSON database. When the time comes, it will remind you to do your saved event.
36 changes: 36 additions & 0 deletions plugins/stock_prices/main.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/perl

use LWP::UserAgent;

sub fetch_stock_price {
my $ticker = shift;

# Get stock information from Google Finance
my $url = "https://www.google.com/finance?q=$ticker";
my $ua = LWP::UserAgent->new;
my $response = $ua->get($url);

# Check if request was successful
if ($response->is_success) {
my $html = $response->decoded_content;

# Extract the stock price
if ($html =~ /ref_.*_l">(.*?)<\/span>/i) {
return "The current stock price for $ticker is $1.";
} else {
return "Unable to find stock price for $ticker.";
}
} else {
return "Error fetching stock price for $ticker: " . $response->status_line;
}
}

sub handle {
my $command = shift;
if ($command =~ /stock price for (.*)/i) {
return fetch_stock_price($1);
}
return "Invalid command.";
}

1;
3 changes: 3 additions & 0 deletions plugins/stock_prices/plugin.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
author: Akul Goel
dependencies: LWP::UserAgent
description: This plugin tells you the stock prices when you ask it to.
12 changes: 12 additions & 0 deletions plugins/time_date/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import datetime

# define all commonly used variables here
now = datetime.datetime.now()

def handle(command):
if "time" in command:
time_now = now.strftime("%H:%M:%S")
akulai.speak(f"The current time is{time_now}")
if "date" in command:
date_now = now.strftime("%Y-%m-%d")
akulai.speak(f"The current date is{date_now}")
3 changes: 3 additions & 0 deletions plugins/time_date/plugin.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
author: Akul Goel
dependencies: datetime
description: This plugin tells you the time/date when you ask it to.
11 changes: 11 additions & 0 deletions plugins/weather/main.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/perl

use strict;
use warnings;
use Weather::Google;

my $location = shift;

my $weather = Weather::Google->new($location);

print "The weather in $location is currently " . $weather->condition->temp . "F and " . $weather->condition->text . "\n";
3 changes: 3 additions & 0 deletions plugins/weather/plugin.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
author: Akul Goel
dependencies: Weather::Google
description: This plugin checks Google for the weather around you.
6 changes: 0 additions & 6 deletions setup/setup.bat
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
@echo off

cd ".."
SET repo_url=https://github.com/Akul-AI/akulai-plugins
SET subdir=plugins
git "submodule" "add" "%repo_url%"
git "submodule" "update" "--init" "--recursive"
mv "akulai-plugins/%subdir%" "akulai/"
DEL /S "akulai-plugins"
SET vosk_url=https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip
curl "-o" "vosk-model-small-en-us-0.15.zip" "%vosk_url%"
unzip "vosk-model-small-en-us-0.15.zip" "-d" "akulai"
Expand Down
15 changes: 0 additions & 15 deletions setup/setup.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
# If using this script on Windows, just keep in mind that this script needs to be run with administrator permissions.
import os
import shutil
import zipfile
import requests
import platform

# Change directory to the parent directory of the script
os.chdir("..")

# Define the GitHub repository URL and subdirectory
repo_url = "https://github.com/Akul-AI/akulai-plugins"
subdir = "plugins"

# Use git submodules to fetch the plugins subdir in the akulai plugins repo
os.system("git submodule add {} --name akulai-plugins".format(repo_url))
os.system("git submodule update --init --recursive")

# Move the files from the subdirectory to the local "akulai/plugins" folder
shutil.move("{}/".format(f"akulai-plugins/{subdir}"), "akulai/")

# Delete the files after copying them
shutil.rmtree("akulai-plugins")

# Use requests library to download vosk
vosk_url = "https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip"
response = requests.get(vosk_url)
Expand Down
6 changes: 0 additions & 6 deletions setup/setup.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/bin/bash

cd ..
repo_url="https://github.com/Akul-AI/akulai-plugins"
subdir="plugins"
git submodule add $repo_url
git submodule update --init --recursive
mv "akulai-plugins/$subdir" "akulai/"
rm -r "akulai-plugins"
vosk_url="https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip"
curl -o "vosk-model-small-en-us-0.15.zip" $vosk_url
unzip "vosk-model-small-en-us-0.15.zip" -d "akulai"
Expand Down

0 comments on commit 53843ec

Please sign in to comment.