1
0
mirror of https://github.com/MarkParker5/STARK.git synced 2024-11-24 08:12:13 +02:00

updated namespace with imports for new layout

This commit is contained in:
MarkParker5 2021-08-22 17:24:30 +03:00
parent 9a08765f70
commit 4ebb687d34
27 changed files with 61 additions and 75 deletions

9
.gitignore vendored
View File

@ -8,10 +8,7 @@ __pycache__
*.save
*.xls
/audio
/tts-gc-key.json
/test.py
/sandbox.py
/logs.txt
/config.py
/status.json
/tts-gc-key.json
/logs.txt

View File

@ -1,4 +1,6 @@
class DJango(Control):
from ..Control import Control
class Django(Control):
def start(self):
# run manage.py
pass

View File

@ -1,11 +1,12 @@
#!/usr/local/bin/python3.8
from Command import Command
import Text2Speech
import telebot
import config
import modules
import time
import os
import telebot
import config
from Features import Command
from General import Text2Speech
from Controls.Control import Control
class TelegramBot(Control):
threads = []
@ -16,9 +17,9 @@ class TelegramBot(Control):
bot = telebot.TeleBot(config.telebot)
# Singleton
def __new__(self, cls):
def __new__(cls):
if not hasattr(cls, 'instance'):
cls.instance = super(VoiceAssistant, cls).__new__(cls)
cls.instance = super(TelegramBot, cls).__new__(cls)
return cls.instance
def reply(self, id, response):
@ -89,8 +90,8 @@ class TelegramBot(Control):
print("Start polling...")
bot.polling(callback = check_threads, args = (threads,) )
except:
time.sleep(10)
print("Polling failed")
time.sleep(10)
if __name__ == '__main__':

View File

@ -1,10 +1,9 @@
#!/usr/local/bin/python3.8
import SpeechRecognition
import Text2Speech
from Command import Command
import config
import modules
import os
from Controls.Control import Control
from General import SpeechRecognition, Text2Speech
from Features.Command import Command
import config
if config.double_clap_activation:
import RPi.GPIO as GPIO

4
Controls/__init__.py Normal file
View File

@ -0,0 +1,4 @@
from .Django.Django import Django
from .TelegramBot.TelegramBot import TelegramBot
from .VoiceAssistant.VoiceAssistant import VoiceAssistant
from .Control import Control

View File

@ -31,7 +31,7 @@ from abc import ABC, abstractmethod
from threading import Thread, Event
import re
from synonyms import synonyms
from .synonyms import synonyms
class RThread(Thread):
def __init__(self, *args, **kwargs):

View File

@ -1,4 +1,4 @@
from Command import Command
from ..Command import Command
class Media(Command):
def start(this, string): # main method

View File

@ -2,7 +2,7 @@ from .Media import *
import requests
from bs4 import BeautifulSoup as BS
import os
from Command import Callback, Response
from ..Command import Callback, Response
################################################################################
def findPage(name):
query = name + ' site:kinogo.by'

View File

@ -1,9 +1,8 @@
from bs4 import BeautifulSoup as BS
from Command import Command
from ..Command import Command
import wikipedia as wiki
import requests
import random
import apiai
import json
import re

View File

@ -1,4 +1,4 @@
from Command import Command # import parent class
from ..Command import Command # import parent class
import os
class Raspi(Command):

View File

@ -1,2 +0,0 @@
from .gitpull import *
from .tv import *

View File

@ -1,6 +1,6 @@
from .Raspi import *
import os
from Command import Callback, Response
from ..Command import Callback, Response
import config
################################################################################
def reboot(params):

View File

@ -1,5 +1,5 @@
from .Raspi import *
from Command import Response
from ..Command import Response
################################################################################
def method(params):
Raspi.hdmi_cec('on 0')
@ -29,7 +29,7 @@ def method(params):
return Response(text = text, voice = voice)
keywords = {}
patterns = ['* (выведи|вывести|покажи|открой|показать|открыть) * с (|провода|hdmi|кабеля|порта) * $num *']
patterns = ['* (выведи|вывести|покажи|открой|показать|открыть) * с (провода|hdmi|кабеля|порта) * $num *']
tv_hdmi = Raspi('tv hdmi source', keywords, patterns)
tv_hdmi.setStart(method)
################################################################################
@ -39,7 +39,7 @@ def method(params):
return Response(text = text, voice = voice)
keywords = {}
patterns = ['* (выведи|вывести|покажи|открой|показать|открыть) * с (ноута|ноутбука|провода|hdmi)']
patterns = ['* (выведи|вывести|покажи|открой|показать|открыть) * с (ноута|ноутбука|планшета|провода|hdmi)']
tv_hdmi = Raspi('tv hdmi source', keywords, patterns)
tv_hdmi.setStart(method)
################################################################################
@ -49,6 +49,6 @@ def method(params):
return Response(text = text, voice = voice)
keywords = {}
patterns = ['* (верни|вернуть|включи*|покажи|показать) [нормальн|стандартн|привычн]* (телевизор|экран|картинк|изображение) *']
patterns = ['* (верни|вернуть|включи*|покажи|показать) [основн|нормальн|стандартн|привычн]* (телевизор|экран|картинк|изображение) *']
tv_rpi = Raspi('tv rpi source', keywords, patterns)
tv_rpi.setStart(method)

View File

@ -3,9 +3,7 @@
# Module for speaking with voice assistent
# See class Command
from Command import Command # import parent class
from ..Command import Command # import parent class
class SmallTalk(Command):
def start(this, string): # main method

View File

@ -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 *

View File

@ -1,9 +1,9 @@
from .SmallTalk import *
import datetime, time
import requests
from bs4 import BeautifulSoup as BS
import math
from Command import Response
from .SmallTalk import SmallTalk
from ..Command import Response
################################################################################
def method(params):
if city := params.get('text'):

View File

@ -1,5 +1,5 @@
from .SmallTalk import *
from Command import Response
from ..Command import Response
################################################################################
def method(params):
voice = text = 'Привет'

View File

@ -1,12 +1,13 @@
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
from .lib_nrf24 import NRF24
import spidev
import time
import json as JSON
from Command import Command
from threading import Thread
from ..Command import Command
GPIO.setmode(GPIO.BCM)
pipe = [0xf0, 0xf0, 0xf0, 0xf0, 0xe1]

View File

@ -1,4 +0,0 @@
from .main_light import *
from .window import *
from .alarmclock import *
from .light import *

View File

@ -1,6 +1,5 @@
from .SmartHome import *
from Command import Response
from Command import Command
from ..Command import Response, Command
import Text2Speech
import os
################################################################################

View File

@ -1,5 +1,5 @@
from .SmartHome import *
from Command import Response
from ..Command import Response
################################################################################
def method(params):

View File

@ -1,5 +1,5 @@
from .SmartHome import *
from Command import Response
from ..Command import Response
################################################################################
def method(params):

View File

@ -1,4 +1,4 @@
from Command import Command, Response # import parent class
from ..Command import Command, Response # import parent class
import urllib.request
import xlrd
import xlwt

View File

@ -1 +0,0 @@
from .myshedule import *

12
Features/__init__.py Normal file
View 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')

View File

@ -1,7 +1,12 @@
#!/usr/local/bin/python3.8
# entry point
import Controls
import Features
# TODO:
# import subprocess
# start oll controls in own thread or subprocess:
# voice assistant, telegram bot, django(api and ui)
Controls.TelegramBot().start()