mirror of
https://github.com/MarkParker5/STARK.git
synced 2025-02-12 11:46:14 +02:00
updated namespace with imports for new layout
This commit is contained in:
parent
9a08765f70
commit
4ebb687d34
9
.gitignore
vendored
9
.gitignore
vendored
@ -8,10 +8,7 @@ __pycache__
|
|||||||
*.save
|
*.save
|
||||||
|
|
||||||
*.xls
|
*.xls
|
||||||
/audio
|
|
||||||
/tts-gc-key.json
|
|
||||||
/test.py
|
|
||||||
/sandbox.py
|
|
||||||
/logs.txt
|
|
||||||
/config.py
|
/config.py
|
||||||
/status.json
|
/tts-gc-key.json
|
||||||
|
/logs.txt
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
class DJango(Control):
|
from ..Control import Control
|
||||||
|
|
||||||
|
class Django(Control):
|
||||||
def start(self):
|
def start(self):
|
||||||
# run manage.py
|
# run manage.py
|
||||||
pass
|
pass
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
#!/usr/local/bin/python3.8
|
#!/usr/local/bin/python3.8
|
||||||
from Command import Command
|
|
||||||
import Text2Speech
|
|
||||||
import telebot
|
|
||||||
import config
|
|
||||||
import modules
|
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
import telebot
|
||||||
|
import config
|
||||||
|
from Features import Command
|
||||||
|
from General import Text2Speech
|
||||||
|
from Controls.Control import Control
|
||||||
|
|
||||||
class TelegramBot(Control):
|
class TelegramBot(Control):
|
||||||
threads = []
|
threads = []
|
||||||
@ -16,9 +17,9 @@ class TelegramBot(Control):
|
|||||||
bot = telebot.TeleBot(config.telebot)
|
bot = telebot.TeleBot(config.telebot)
|
||||||
|
|
||||||
# Singleton
|
# Singleton
|
||||||
def __new__(self, cls):
|
def __new__(cls):
|
||||||
if not hasattr(cls, 'instance'):
|
if not hasattr(cls, 'instance'):
|
||||||
cls.instance = super(VoiceAssistant, cls).__new__(cls)
|
cls.instance = super(TelegramBot, cls).__new__(cls)
|
||||||
return cls.instance
|
return cls.instance
|
||||||
|
|
||||||
def reply(self, id, response):
|
def reply(self, id, response):
|
||||||
@ -89,8 +90,8 @@ class TelegramBot(Control):
|
|||||||
print("Start polling...")
|
print("Start polling...")
|
||||||
bot.polling(callback = check_threads, args = (threads,) )
|
bot.polling(callback = check_threads, args = (threads,) )
|
||||||
except:
|
except:
|
||||||
time.sleep(10)
|
|
||||||
print("Polling failed")
|
print("Polling failed")
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#!/usr/local/bin/python3.8
|
#!/usr/local/bin/python3.8
|
||||||
import SpeechRecognition
|
|
||||||
import Text2Speech
|
|
||||||
from Command import Command
|
|
||||||
import config
|
|
||||||
import modules
|
|
||||||
import os
|
import os
|
||||||
|
from Controls.Control import Control
|
||||||
|
from General import SpeechRecognition, Text2Speech
|
||||||
|
from Features.Command import Command
|
||||||
|
import config
|
||||||
|
|
||||||
if config.double_clap_activation:
|
if config.double_clap_activation:
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
|
4
Controls/__init__.py
Normal file
4
Controls/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
from .Django.Django import Django
|
||||||
|
from .TelegramBot.TelegramBot import TelegramBot
|
||||||
|
from .VoiceAssistant.VoiceAssistant import VoiceAssistant
|
||||||
|
from .Control import Control
|
@ -31,7 +31,7 @@ from abc import ABC, abstractmethod
|
|||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from synonyms import synonyms
|
from .synonyms import synonyms
|
||||||
|
|
||||||
class RThread(Thread):
|
class RThread(Thread):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from Command import Command
|
from ..Command import Command
|
||||||
|
|
||||||
class Media(Command):
|
class Media(Command):
|
||||||
def start(this, string): # main method
|
def start(this, string): # main method
|
||||||
|
@ -2,7 +2,7 @@ from .Media import *
|
|||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup as BS
|
from bs4 import BeautifulSoup as BS
|
||||||
import os
|
import os
|
||||||
from Command import Callback, Response
|
from ..Command import Callback, Response
|
||||||
################################################################################
|
################################################################################
|
||||||
def findPage(name):
|
def findPage(name):
|
||||||
query = name + ' site:kinogo.by'
|
query = name + ' site:kinogo.by'
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
from bs4 import BeautifulSoup as BS
|
from bs4 import BeautifulSoup as BS
|
||||||
from Command import Command
|
from ..Command import Command
|
||||||
import wikipedia as wiki
|
import wikipedia as wiki
|
||||||
import requests
|
import requests
|
||||||
import random
|
import random
|
||||||
import apiai
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from Command import Command # import parent class
|
from ..Command import Command # import parent class
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class Raspi(Command):
|
class Raspi(Command):
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
from .gitpull import *
|
|
||||||
from .tv import *
|
|
@ -1,6 +1,6 @@
|
|||||||
from .Raspi import *
|
from .Raspi import *
|
||||||
import os
|
import os
|
||||||
from Command import Callback, Response
|
from ..Command import Callback, Response
|
||||||
import config
|
import config
|
||||||
################################################################################
|
################################################################################
|
||||||
def reboot(params):
|
def reboot(params):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from .Raspi import *
|
from .Raspi import *
|
||||||
from Command import Response
|
from ..Command import Response
|
||||||
################################################################################
|
################################################################################
|
||||||
def method(params):
|
def method(params):
|
||||||
Raspi.hdmi_cec('on 0')
|
Raspi.hdmi_cec('on 0')
|
||||||
@ -29,7 +29,7 @@ def method(params):
|
|||||||
return Response(text = text, voice = voice)
|
return Response(text = text, voice = voice)
|
||||||
|
|
||||||
keywords = {}
|
keywords = {}
|
||||||
patterns = ['* (выведи|вывести|покажи|открой|показать|открыть) * с (|провода|hdmi|кабеля|порта) * $num *']
|
patterns = ['* (выведи|вывести|покажи|открой|показать|открыть) * с (провода|hdmi|кабеля|порта) * $num *']
|
||||||
tv_hdmi = Raspi('tv hdmi source', keywords, patterns)
|
tv_hdmi = Raspi('tv hdmi source', keywords, patterns)
|
||||||
tv_hdmi.setStart(method)
|
tv_hdmi.setStart(method)
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -39,7 +39,7 @@ def method(params):
|
|||||||
return Response(text = text, voice = voice)
|
return Response(text = text, voice = voice)
|
||||||
|
|
||||||
keywords = {}
|
keywords = {}
|
||||||
patterns = ['* (выведи|вывести|покажи|открой|показать|открыть) * с (ноута|ноутбука|провода|hdmi)']
|
patterns = ['* (выведи|вывести|покажи|открой|показать|открыть) * с (ноута|ноутбука|планшета|провода|hdmi)']
|
||||||
tv_hdmi = Raspi('tv hdmi source', keywords, patterns)
|
tv_hdmi = Raspi('tv hdmi source', keywords, patterns)
|
||||||
tv_hdmi.setStart(method)
|
tv_hdmi.setStart(method)
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -49,6 +49,6 @@ def method(params):
|
|||||||
return Response(text = text, voice = voice)
|
return Response(text = text, voice = voice)
|
||||||
|
|
||||||
keywords = {}
|
keywords = {}
|
||||||
patterns = ['* (верни|вернуть|включи*|покажи|показать) [нормальн|стандартн|привычн]* (телевизор|экран|картинк|изображение) *']
|
patterns = ['* (верни|вернуть|включи*|покажи|показать) [основн|нормальн|стандартн|привычн]* (телевизор|экран|картинк|изображение) *']
|
||||||
tv_rpi = Raspi('tv rpi source', keywords, patterns)
|
tv_rpi = Raspi('tv rpi source', keywords, patterns)
|
||||||
tv_rpi.setStart(method)
|
tv_rpi.setStart(method)
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
# Module for speaking with voice assistent
|
# Module for speaking with voice assistent
|
||||||
# See class Command
|
# See class Command
|
||||||
|
|
||||||
|
from ..Command import Command # import parent class
|
||||||
|
|
||||||
from Command import Command # import parent class
|
|
||||||
|
|
||||||
class SmallTalk(Command):
|
class SmallTalk(Command):
|
||||||
def start(this, string): # main method
|
def start(this, string): # main method
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
# Initialisation SmallTalk
|
|
||||||
# Creating objects (add commands)
|
|
||||||
# setStart(method) is required
|
|
||||||
# setConfirm(method) is optional
|
|
||||||
#
|
|
||||||
# How to add new command:
|
|
||||||
# 1. def method() # return string
|
|
||||||
# 1.2 def confirm_method() # optional, not required
|
|
||||||
# 2. kw = {
|
|
||||||
# (int)weight : ['word1', 'word2', 'word3'],
|
|
||||||
# (int)weight1 : ['word3', 'word4'],
|
|
||||||
# (int)weight2 : ['word5', 'word6', 'word7', 'word8', 'word9'],
|
|
||||||
# }
|
|
||||||
# patterns = ['* который * час *', '* скольк* * (врем|час)* *']
|
|
||||||
# subpatterns = [...] #like patterns
|
|
||||||
# 3. new_command = SmallTalk(Name, kw, patterns, subpatterns)
|
|
||||||
# 4. new_command.setStart(method)
|
|
||||||
# 5. new_command.setConfirm(confirm_method) # optional, not required
|
|
||||||
#
|
|
||||||
# @background(voice_to_speak, text_for_print) for background methods
|
|
||||||
|
|
||||||
from .hello import *
|
|
||||||
from .ctime import *
|
|
||||||
from .test import *
|
|
@ -1,9 +1,9 @@
|
|||||||
from .SmallTalk import *
|
|
||||||
import datetime, time
|
import datetime, time
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup as BS
|
from bs4 import BeautifulSoup as BS
|
||||||
import math
|
import math
|
||||||
from Command import Response
|
from .SmallTalk import SmallTalk
|
||||||
|
from ..Command import Response
|
||||||
################################################################################
|
################################################################################
|
||||||
def method(params):
|
def method(params):
|
||||||
if city := params.get('text'):
|
if city := params.get('text'):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from .SmallTalk import *
|
from .SmallTalk import *
|
||||||
from Command import Response
|
from ..Command import Response
|
||||||
################################################################################
|
################################################################################
|
||||||
def method(params):
|
def method(params):
|
||||||
voice = text = 'Привет'
|
voice = text = 'Привет'
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
GPIO.setmode(GPIO.BCM)
|
|
||||||
from .lib_nrf24 import NRF24
|
from .lib_nrf24 import NRF24
|
||||||
import spidev
|
import spidev
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import json as JSON
|
import json as JSON
|
||||||
from Command import Command
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
from ..Command import Command
|
||||||
|
|
||||||
|
GPIO.setmode(GPIO.BCM)
|
||||||
|
|
||||||
pipe = [0xf0, 0xf0, 0xf0, 0xf0, 0xe1]
|
pipe = [0xf0, 0xf0, 0xf0, 0xf0, 0xe1]
|
||||||
|
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
from .main_light import *
|
|
||||||
from .window import *
|
|
||||||
from .alarmclock import *
|
|
||||||
from .light import *
|
|
@ -1,6 +1,5 @@
|
|||||||
from .SmartHome import *
|
from .SmartHome import *
|
||||||
from Command import Response
|
from ..Command import Response, Command
|
||||||
from Command import Command
|
|
||||||
import Text2Speech
|
import Text2Speech
|
||||||
import os
|
import os
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from .SmartHome import *
|
from .SmartHome import *
|
||||||
from Command import Response
|
from ..Command import Response
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
def method(params):
|
def method(params):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from .SmartHome import *
|
from .SmartHome import *
|
||||||
from Command import Response
|
from ..Command import Response
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
def method(params):
|
def method(params):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from Command import Command, Response # import parent class
|
from ..Command import Command, Response # import parent class
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import xlrd
|
import xlrd
|
||||||
import xlwt
|
import xlwt
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from .myshedule import *
|
|
12
Features/__init__.py
Normal file
12
Features/__init__.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
from .Command import Command
|
||||||
|
from .Command import Command
|
||||||
|
from .Command import Response
|
||||||
|
|
||||||
|
from .Media import Media
|
||||||
|
from .QA.QA import QA
|
||||||
|
from .SmallTalk import SmallTalk
|
||||||
|
from .Raspi import Raspi
|
||||||
|
from .Zieit import Zieit
|
||||||
|
|
||||||
|
try: from .SmartHome import SmartHome
|
||||||
|
except: print('cannot import module named "SmartHome" from Features/Smarthome\n')
|
5
start.py
5
start.py
@ -1,7 +1,12 @@
|
|||||||
#!/usr/local/bin/python3.8
|
#!/usr/local/bin/python3.8
|
||||||
# entry point
|
# entry point
|
||||||
|
|
||||||
|
import Controls
|
||||||
|
import Features
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# import subprocess
|
# import subprocess
|
||||||
# start oll controls in own thread or subprocess:
|
# start oll controls in own thread or subprocess:
|
||||||
# voice assistant, telegram bot, django(api and ui)
|
# voice assistant, telegram bot, django(api and ui)
|
||||||
|
|
||||||
|
Controls.TelegramBot().start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user