mirror of
https://github.com/bytedream/aion.git
synced 2025-06-27 06:50:32 +02:00
Add files via upload
This commit is contained in:
11
aion_data/etc/install.sh
Normal file
11
aion_data/etc/install.sh
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -d "/usr/local/aion-"]; then
|
||||
apt-get install git
|
||||
git --clone https://github.com/blueShard-dev/aion /tmp/aion_installation
|
||||
bash /tmp/aion_installation/install.sh
|
||||
|
||||
rm -r /tmp/aion_installation
|
||||
else
|
||||
echo "Aion is already installed"
|
||||
fi
|
10
aion_data/language/de_DE.acph
Normal file
10
aion_data/language/de_DE.acph
Normal file
@ -0,0 +1,10 @@
|
||||
<activate_phrases>
|
||||
<erzähle__and__über skill="skills" method="Wikipedia"/>
|
||||
<erzähl__and__über skill="skills" method="Wikipedia"/>
|
||||
<ip-adresse skill="skills" method="IpAddress"/>
|
||||
<prozessor_auslastung skill="skills" method="CpuUsage"/>
|
||||
<spiele skill="skills" method="Play"/>
|
||||
<spiel skill="skills" method="Play"/>
|
||||
<uhr skill="skills" method="CurrentTime"/>
|
||||
<zeit skill="skills" method="CurrenTime"/>
|
||||
</activate_phrases>
|
19
aion_data/language/de_DE.lng
Normal file
19
aion_data/language/de_DE.lng
Normal file
@ -0,0 +1,19 @@
|
||||
<de_DE>
|
||||
<skills.cpu_ram_usage>Der Prozessor wird zu {cpu_usage} und der RAM zu {ram_usage} prozent genutzt</skills.cpu_ram_usage>
|
||||
<skills.cpu_usage>Der Prozessor wird zu {cpu_usage} genutzt</skills.cpu_usage>
|
||||
<skills.current_time_full_am/>
|
||||
<skills.current_time_full_pm/>
|
||||
<skills.current_time_half_am/>
|
||||
<skills.current_time_half_pm/>
|
||||
<skills.current_time_past_am/>
|
||||
<skills.current_time_past_pm/>
|
||||
<skills.current_time_to_am/>
|
||||
<skills.current_time_to_pm/>
|
||||
<skills.current_time_full>Es ist {hour} Uhr</skills.current_time_full>
|
||||
<skills.current_time_half>Es ist {hour} Uhr {minute}</skills.current_time_half>
|
||||
<skills.current_time_etc>Es ist {hour} Uhr {minute}</skills.current_time_etc>
|
||||
<skills.ip_address>Meine IP ist {ip_address}</skills.ip_address>
|
||||
<skills.ram_usage>Der RAM wird zu {ram_usage} prozent genutzt</skills.ram_usage>
|
||||
<skills.wikipedia>{article_text}</skills.wikipedia>
|
||||
<skills.wikipedia_article_not_found>Der Artikel {article_text} existiert nicht</skills.wikipedia_article_not_found>
|
||||
</de_DE>
|
10
aion_data/language/en_US.acph
Normal file
10
aion_data/language/en_US.acph
Normal file
@ -0,0 +1,10 @@
|
||||
<activate_phrases>
|
||||
<cpu_usage skill="skills" method="CpuUsage"/>
|
||||
<ip_address skill="skills" method="IpAddress"/>
|
||||
<play skill="skills" method="Play"/>
|
||||
<processor_usage skill="skills" method="CpuUsage"/>
|
||||
<ram_usage skill="skills" method="RamUsage"/>
|
||||
<tell__and__about skill="skills" method="Wikipedia"/>
|
||||
<time skill="skills" method="CurrentTime"/>
|
||||
<virtual_memory_usage skill="skills", method="RamUsage"/>
|
||||
</activate_phrases>
|
19
aion_data/language/en_US.lng
Normal file
19
aion_data/language/en_US.lng
Normal file
@ -0,0 +1,19 @@
|
||||
<en_US>
|
||||
<skills.cpu_ram_usage>The processor uses {cpu_usage} and the ram {ram_usage} percent</skills.cpu_ram_usage>
|
||||
<skills.cpu_usage>The processor uses {cpu_usage} percent</skills.cpu_usage>
|
||||
<skills.current_time_full_am>It's {hour} a.m.</skills.current_time_full_am>
|
||||
<skills.current_time_full_pm>It's {hour} p.m.</skills.current_time_full_pm>
|
||||
<skills.current_time_half_am>It's half past {hour} a.m.</skills.current_time_half_am>
|
||||
<skills.current_time_half_pm>It's half past {hour} p.m.</skills.current_time_half_pm>
|
||||
<skills.current_time_past_am>It's {minute} past {hour} a.m.</skills.current_time_past_am>
|
||||
<skills.current_time_past_pm>It's {minute} past {hour} p.m.</skills.current_time_past_pm>
|
||||
<skills.current_time_to_am>It's {minute} to {hour} a.m.</skills.current_time_to_am>
|
||||
<skills.current_time_to_pm>It's {minute} to {hour} p.m.</skills.current_time_to_pm>
|
||||
<skills.current_time_full>It's {hour} o'clock</skills.current_time_full>
|
||||
<skills.current_time_half>It's half past {hour}</skills.current_time_half>
|
||||
<skills.current_time_etc>It's {hour} {minute}</skills.current_time_etc>
|
||||
<skills.ip_address>My IP is {ip_address}</skills.ip_address>
|
||||
<skills.ram_usage>The ram uses {ram_usage} percent</skills.ram_usage>
|
||||
<skills.wikipedia>{article_text}</skills.wikipedia>
|
||||
<skills.wikipedia_article_not_found>The article {article_name} doesnt exist</skills.wikipedia_article_not_found>
|
||||
</en_US>
|
2
aion_data/plugins/run_after/run_after.xml
Normal file
2
aion_data/plugins/run_after/run_after.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<run_after>
|
||||
</run_after>
|
2
aion_data/plugins/run_before/run_before.xml
Normal file
2
aion_data/plugins/run_before/run_before.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<run_before>
|
||||
</run_before>
|
235
aion_data/skills/skills.py
Normal file
235
aion_data/skills/skills.py
Normal file
@ -0,0 +1,235 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
from glob import glob
|
||||
from sys import path
|
||||
|
||||
path.insert(0, glob("/usr/local/aion-*/aion_core")[0])
|
||||
|
||||
from aion_core import config as aconf
|
||||
from aion_core import language as alang
|
||||
|
||||
from aion_core.skill import Skill
|
||||
|
||||
|
||||
class CpuRamUsage(Skill):
|
||||
"""
|
||||
skill class to get the cpu and ram usage
|
||||
"""
|
||||
|
||||
def main(self):
|
||||
from psutil import cpu_percent, virtual_memory
|
||||
from statistics import mean
|
||||
from time import sleep
|
||||
|
||||
testing_time = 10
|
||||
print_process = False
|
||||
|
||||
cpu_list = []
|
||||
ram_list = []
|
||||
|
||||
while True:
|
||||
cpu = cpu_percent()
|
||||
cpu_list.append(cpu)
|
||||
ram = virtual_memory()[2]
|
||||
ram_list.append(ram)
|
||||
if print_process is True:
|
||||
print("CPU: " + str(cpu) + "%")
|
||||
print("RAM: " + str(ram) + "%")
|
||||
sleep(1)
|
||||
|
||||
if 0.0 in cpu_list:
|
||||
cpu_list.remove(0.0)
|
||||
if len(cpu_list) == testing_time and len(ram_list) == testing_time:
|
||||
cpu = mean(cpu_list)
|
||||
ram = mean(ram_list)
|
||||
break
|
||||
elif len(cpu_list) == testing_time - 1 and len(ram_list) == testing_time:
|
||||
cpu = cpu_percent()
|
||||
cpu_list.append(cpu)
|
||||
cpu = mean(cpu_list)
|
||||
ram = mean(ram_list)
|
||||
break
|
||||
|
||||
self.speech_output(alang.start("skills", "cpu_ram_usage", {"cpu_usage": round(cpu, 2), "ram_usage": round(ram, 2)}))
|
||||
|
||||
|
||||
class CpuUsage(Skill):
|
||||
"""
|
||||
skill class to get the cpu usage
|
||||
"""
|
||||
|
||||
def main(self):
|
||||
from statistics import mean
|
||||
from psutil import cpu_percent
|
||||
from time import sleep
|
||||
|
||||
testing_time = 10
|
||||
print_process = False
|
||||
|
||||
cpu_list = []
|
||||
|
||||
while True:
|
||||
cpu = cpu_percent()
|
||||
cpu_list.append(cpu)
|
||||
if print_process is True:
|
||||
print("CPU: " + str(cpu) + "%")
|
||||
sleep(1)
|
||||
|
||||
if 0.0 in cpu_list:
|
||||
cpu_list.remove(0.0)
|
||||
if len(cpu_list) == testing_time:
|
||||
cpu = (mean(cpu_list))
|
||||
break
|
||||
|
||||
self.speech_output(alang.start("skills", "cpu_usage", {"cpu_usage": round(cpu, 2)}))
|
||||
|
||||
|
||||
class CurrentTime(Skill):
|
||||
"""
|
||||
skill class to get the current time
|
||||
"""
|
||||
|
||||
def main(self):
|
||||
from datetime import datetime
|
||||
|
||||
current_time = datetime.now()
|
||||
time_dict = {"hour": current_time.hour, "minute": current_time.minute, "second": current_time.second, "microsecond": current_time.microsecond}
|
||||
if aconf.Aion().get_time_format() == "12":
|
||||
if time_dict["minute"] == 0:
|
||||
if time_dict["hour"] < 13:
|
||||
self.speech_output(alang.start("skills", "current_time_full_am", time_dict))
|
||||
else:
|
||||
time_dict["hour"] = time_dict["hour"] - 12
|
||||
self.speech_output(alang.start("skills", "current_time_full_pm", time_dict))
|
||||
elif time_dict["minute"] == 30:
|
||||
if time_dict["hour"] < 13:
|
||||
self.speech_output(alang.start("skills", "current_time_half_am", time_dict))
|
||||
else:
|
||||
time_dict["hour"] = time_dict["hour"] - 12
|
||||
self.speech_output(alang.start("skills", "current_time_half_pm", time_dict))
|
||||
elif 0 < time_dict["minute"] < 30:
|
||||
if time_dict["hour"] < 13:
|
||||
self.speech_output(alang.start("skills", "current_time_past_am", time_dict))
|
||||
else:
|
||||
time_dict["hour"] = time_dict["hour"] - 12
|
||||
self.speech_output(alang.start("skills", "current_time_past_pm", time_dict))
|
||||
elif time_dict["minute"] > 30:
|
||||
time_dict["minute"] = 60 - time_dict["minute"]
|
||||
if time_dict["hour"] < 13:
|
||||
self.speech_output(alang.start("skills", "current_time_to_am", time_dict))
|
||||
else:
|
||||
time_dict["hour"] = time_dict["hour"] - 12
|
||||
self.speech_output(alang.start("skills", "current_time_to_pm", time_dict))
|
||||
else:
|
||||
self.speech_output(alang.start("skills", "current_time_etc", time_dict))
|
||||
else:
|
||||
if time_dict["minute"] == 0:
|
||||
self.speech_output(alang.start("skills", "current_time_full", time_dict))
|
||||
elif time_dict["minute"] == 30:
|
||||
self.speech_output(alang.start("skills", "current_time_half", time_dict))
|
||||
else:
|
||||
self.speech_output(alang.start("skills", "current_time_etc", time_dict))
|
||||
|
||||
|
||||
class IpAddress(Skill):
|
||||
"""
|
||||
skill class to get the ip address
|
||||
"""
|
||||
|
||||
def main(self):
|
||||
from socket import gethostname, gethostbyname
|
||||
|
||||
self.speech_output(alang.start("skills", "ip_address", {"ip_address": gethostbyname(gethostname() + ".local")}))
|
||||
|
||||
|
||||
class Play(Skill):
|
||||
"""
|
||||
skill class to play a audio from youtube
|
||||
"""
|
||||
|
||||
def main(self):
|
||||
from aion_core.utils import get_full_directory_data, vlc
|
||||
|
||||
file_or_search_element = self.speech_input.lower().replace(self.activate_phrase.lower(), "")
|
||||
for file in get_full_directory_data(file_or_search_element):
|
||||
if file_or_search_element in file:
|
||||
return vlc(file_or_search_element)
|
||||
import urllib.parse, urllib.request
|
||||
from pafy import new
|
||||
from re import findall
|
||||
search_query = urllib.parse.urlencode({"search_query": file_or_search_element})
|
||||
for i in range(10): # sometimes the video url's cannot be found
|
||||
try:
|
||||
html_content = urllib.request.urlopen("https://www.youtube.com/results?" + search_query)
|
||||
search_results = findall(r'href=\"\/watch\?v=(.{11})', html_content.read().decode())
|
||||
vlc(new(str("https://www.youtube.com/watch?v=" + search_results[0])).getbestaudio().url)
|
||||
break
|
||||
# i do it this way, because vlc sometimes don't extract the 'only audio url' from the youtube url
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
def run_after(self):
|
||||
for plugin in self.run_after_plugins:
|
||||
self.start_run_after_plugin(plugin["name"])
|
||||
|
||||
|
||||
class RamUsage(Skill):
|
||||
"""
|
||||
skill class to get ram usage
|
||||
"""
|
||||
|
||||
def main(self):
|
||||
from statistics import mean
|
||||
from psutil import virtual_memory
|
||||
from time import sleep
|
||||
|
||||
testing_time = 10
|
||||
print_process = False
|
||||
|
||||
ram_list = []
|
||||
|
||||
while True:
|
||||
ram = virtual_memory()[2]
|
||||
ram_list.append(ram)
|
||||
if print_process is True:
|
||||
print("RAM: " + str(ram) + "%")
|
||||
sleep(1)
|
||||
|
||||
if len(ram_list) == testing_time:
|
||||
ram = mean(ram_list)
|
||||
break
|
||||
|
||||
self.speech_output(alang.start("skills", "ram_usage", {"ram_usage": round(ram, 2)}))
|
||||
|
||||
|
||||
class Shutdown(Skill):
|
||||
"""
|
||||
skill class to shutdown the system
|
||||
"""
|
||||
|
||||
def main(self):
|
||||
from os import system
|
||||
|
||||
system("sudo shutdown -h 0")
|
||||
|
||||
|
||||
class Wikipedia(Skill):
|
||||
"""
|
||||
skill class to search an article on wikipedia
|
||||
"""
|
||||
|
||||
def main(self):
|
||||
from aion_core.utils import remove_brackets, remove_space, remove_string_sequence
|
||||
from wikipediaapi import Wikipedia
|
||||
|
||||
splitted_acph = self.activate_phrase.split("__and__")
|
||||
searched_article = remove_string_sequence(self.speech_input, splitted_acph[0], splitted_acph[-1])
|
||||
wiki = Wikipedia(aconf.Aion().get_language().split("_")[0])
|
||||
article = wiki.page(searched_article)
|
||||
|
||||
if article.exists():
|
||||
article_text = remove_brackets(article.summary)
|
||||
article_text = remove_space(article_text)
|
||||
self.speech_output(alang.start("skills", "wikipedia", {"article_text": article_text}))
|
||||
else:
|
||||
self.speech_output(alang.start("skills", "wikipedia_article_not_found", {"article_name": searched_article}))
|
10
aion_data/skills/skills.xml
Normal file
10
aion_data/skills/skills.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<skills>
|
||||
<skills author="blueShard">
|
||||
<additional_directories>None</additional_directories>
|
||||
<description>The official skill library</description>
|
||||
<license>MIT</license>
|
||||
<main_file>skills.py</main_file>
|
||||
<required_python3_packages>['psutil', 'statistics', 'Wikipedia-API']</required_python3_packages>
|
||||
<version>1.0.0</version>
|
||||
</skills>
|
||||
</skills>
|
Reference in New Issue
Block a user