2022-06-15 08:47:39 +02:00
|
|
|
from apimock import *
|
2022-06-15 00:02:44 +02:00
|
|
|
import difflib as dl
|
2022-06-07 20:48:37 +02:00
|
|
|
import random
|
2022-06-15 00:02:44 +02:00
|
|
|
import sys
|
2022-04-20 09:14:16 +02:00
|
|
|
|
2022-06-15 00:02:44 +02:00
|
|
|
commands = [
|
|
|
|
'pomoc',
|
|
|
|
'powiedz co nowego na moim gicie',
|
|
|
|
'do widzenia',
|
|
|
|
'pokaz issue w',
|
|
|
|
'pokaz mi powiadomienia',
|
|
|
|
'jakie sa pull requesty',
|
|
|
|
'pokaz mi testy w'
|
|
|
|
]
|
|
|
|
|
|
|
|
welcome = [
|
|
|
|
'Witaj!',
|
2022-06-07 20:48:37 +02:00
|
|
|
"Cześć",
|
|
|
|
"Hello",
|
|
|
|
"Hej",
|
|
|
|
"Dzień dobry",
|
2022-06-15 00:02:44 +02:00
|
|
|
"Hey"
|
|
|
|
]
|
|
|
|
|
|
|
|
unknown = [
|
|
|
|
"Nie rozumiem.",
|
|
|
|
"Nie wiem co masz na myśli."
|
|
|
|
]
|
2022-06-07 20:48:37 +02:00
|
|
|
|
2022-06-15 00:02:44 +02:00
|
|
|
other = [
|
|
|
|
"Podobne komendy: ",
|
|
|
|
"Może chodziło Ci o te komendy: ",
|
|
|
|
"Spróbuj wybrać jedną z tych komend: "
|
|
|
|
]
|
2022-06-07 20:48:37 +02:00
|
|
|
|
2022-06-15 00:02:44 +02:00
|
|
|
bye = [
|
2022-06-15 09:21:42 +02:00
|
|
|
"Żegnaj!",
|
|
|
|
"Do zobaczenia",
|
2022-06-07 20:48:37 +02:00
|
|
|
"Do widzenia",
|
|
|
|
"Miłego dnia",
|
2022-06-15 08:47:39 +02:00
|
|
|
"Do widzenia i miłego dnia",
|
2022-06-15 00:02:44 +02:00
|
|
|
"Narazie"
|
|
|
|
]
|
2022-06-07 20:48:37 +02:00
|
|
|
|
|
|
|
help = ["Obsługuję przekazywanie informacji z systemu GitHub - repozytoria, pull requesty, issue, powiadomienia."]
|
|
|
|
time = ["Z jakiego czasu?", "Z jakiego okresu?", "Podaj z jakiego przedziału czasowego"]
|
2022-06-15 00:02:44 +02:00
|
|
|
|
|
|
|
repo = [
|
2022-06-15 09:21:42 +02:00
|
|
|
"Z jakiego repozytorium",
|
|
|
|
"Wskaż repozytorium",
|
|
|
|
"Podaj z jakiego repozytorium chciałbyć otrzymać informacje",
|
2022-06-15 00:02:44 +02:00
|
|
|
"Określ repozytorium"
|
|
|
|
]
|
|
|
|
|
2022-06-07 20:48:37 +02:00
|
|
|
howmany = ["Ile ostatnich elemntów chcesz zobaczyć?", "Ile ostatnich elmentów wyświetlić?", "Ile ostatnich elemnetów pokazać?"]
|
2022-06-15 00:02:44 +02:00
|
|
|
error_time = ["Podano nie prawidłowy czas, popraw ramy czasowe", "Czas jest nie prawidłowy, podaj ponownie", "Podaj przedział czasowy jeszcze raz"]
|
|
|
|
error_repo = ["Podano nieprawidłową nazwę repozytorium", "Podaj ponownie nazwę repozytorium, ponieważ podania nie prawidłową"]
|
2022-06-07 20:48:37 +02:00
|
|
|
|
2022-06-15 09:21:42 +02:00
|
|
|
def find(args, key):
|
2022-06-15 09:31:07 +02:00
|
|
|
print(args, key)
|
2022-06-15 09:21:42 +02:00
|
|
|
for item in args:
|
|
|
|
if item[0] == key:
|
|
|
|
return item
|
|
|
|
|
2022-06-15 00:02:44 +02:00
|
|
|
|
|
|
|
def generator_jezyka_nautalnego(frame, tactic, state, text):
|
|
|
|
if tactic == 'null':
|
|
|
|
beastMatch = dl.get_close_matches(text, commands)
|
|
|
|
print(random.choice(unknown))
|
|
|
|
if len(beastMatch) > 0:
|
|
|
|
print(random.choice(other) + ', '.join(beastMatch))
|
|
|
|
|
2022-06-15 09:21:42 +02:00
|
|
|
elif tactic[0] == False: #ASK
|
|
|
|
_, required_empty, act, req_args, opt_args = tactic
|
2022-06-15 09:31:07 +02:00
|
|
|
print('DEBUG: ', act, 'req', req_args, opt_args,sep = '\n')
|
2022-06-15 09:21:42 +02:00
|
|
|
print(f'Proszę podaj {required_empty[0]}')
|
2022-06-15 00:02:44 +02:00
|
|
|
print()
|
2022-06-15 08:47:39 +02:00
|
|
|
|
2022-06-15 09:21:42 +02:00
|
|
|
elif tactic[0] == True:
|
|
|
|
_, act, req_args, opt_args = tactic
|
2022-06-15 09:31:07 +02:00
|
|
|
print('DEBUG: ', act, 'req', req_args, opt_args,sep = '\n')
|
2022-06-15 09:21:42 +02:00
|
|
|
if act == 'help':
|
|
|
|
print(random.choice(help))
|
|
|
|
print("Dostępne komendy: \n - " + '\n - '.join(commands))
|
2022-06-15 08:47:39 +02:00
|
|
|
|
2022-06-15 09:21:42 +02:00
|
|
|
elif act == 'bye':
|
|
|
|
print(random.choice(bye))
|
|
|
|
print()
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
elif tactic == 'hello':
|
|
|
|
print(random.choice(welcome))
|
|
|
|
|
|
|
|
elif act == 'issues':
|
2022-06-15 09:31:07 +02:00
|
|
|
print("Lista issues w repozytorium " + find(req_args, 'repo')[0] + ":")
|
|
|
|
issues = listRepositoryIssues(find(req_args, 'repo'))
|
2022-06-15 09:21:42 +02:00
|
|
|
for issue in issues:
|
|
|
|
print(issue['name'])
|
|
|
|
print(issue['description'])
|
|
|
|
print(issue['status'])
|
|
|
|
print()
|
|
|
|
|
|
|
|
elif act == 'pullrequest':
|
2022-06-15 09:31:07 +02:00
|
|
|
print("Lista pull requestów w repozytorium " + find(req_args, 'repo')[0] + ":")
|
2022-06-15 09:21:42 +02:00
|
|
|
prs = listRepositoryPullRequests(find(req_args, repo))
|
|
|
|
for pr in prs:
|
|
|
|
print(pr['name'])
|
|
|
|
print(pr['description'])
|
|
|
|
print(pr['state'])
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# elif tactic[0] == 'QUESTION' and act[0] == 'repo':
|
|
|
|
# print("Dodaj nazwę repozytorium na końcu komendy")
|
|
|
|
# print("np. w nazwarepozytorium")
|
|
|
|
|
|
|
|
else:
|
|
|
|
print(tactic)
|
2022-06-15 08:47:39 +02:00
|
|
|
|
2022-05-25 12:52:02 +02:00
|
|
|
else:
|
2022-06-15 09:21:42 +02:00
|
|
|
print('ERROR')
|
2022-06-15 00:02:44 +02:00
|
|
|
print()
|