روبوت إكزير
import os # for first layer
# for first layer only
from google.oauth2 import service_account
# for both first and second layer
import time
import colorama # Import the colorama library
from colorama import Fore, Style # Import the colorama styles
# Initialize the colorama library
colorama.init()
# Define the color styles
USER_INPUT_STYLE = Style.BRIGHT + Fore.WHITE
RESPONSE_STYLE = Style.BRIGHT + Fore.CYAN
# end of colorama line
import regex
from YkzirRobot_Database_GoogleSheet_V2 import service, SPREADSHEET_ID_old
from def_my_convs_log import simpen_conversation_log, a, ADD_FALN, filter_user_input
# Replace the values below with the actual values for your project
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
# the id of the spead sheet. find it from the url
# example
# docs.google.com/spreadsheets/d/1eEUd8Bv7siQd3mOVAYjfkZbfsWpnL2XAYQPJvFivfBw/edit#gid=0
# the id is between the d/ and /edit
# varriable = 'name of the sheet!column:column'
RANGE_NAME = 'RESPONSE_DATA_BASE!A3:B1000'
# the actual JSON content of ykzir robot service account file
import YkzirRobot_Database_GoogleSheet_V2
S_ID = YkzirRobot_Database_GoogleSheet_V2.SPREADSHEET_ID_old
JSON = YkzirRobot_Database_GoogleSheet_V2.YKZIR_ROBOT_JSON
# Authenticate using the service account key
creds = service_account.Credentials.from_service_account_info(JSON, scopes=SCOPES)
# Build the Sheets API client
# Retrieve the values in the specified range
result = service.spreadsheets().values().get(
spreadsheetId=S_ID, range=RANGE_NAME).execute()
values = result.get('values', [])
# end of google sheet authentication
###############################################
# this function records the activities of robot ykzir customers and attackers
# *24th1989#+Upgrading2018PC!E15
def update_login_successes(service, SPREADSHEET_ID, username, password):
# Get the data from the spreadsheet
result = service.spreadsheets().values().get(
spreadsheetId=SPREADSHEET_ID,
range='ykzir_data!A2:D',
valueRenderOption='UNFORMATTED_VALUE'
).execute()
for row in result.get('values', []):
if len(row) >= 2 and row[0] == username and row[1] == password:
login_successes = int(row[2]) + 1 if len(row) > 2 else 1
login_failures = int(row[3]) if len(row) > 3 else 0
# Update the login success count
result = service.spreadsheets().values().update(
spreadsheetId=SPREADSHEET_ID,
range=f'ykzir_data!C{result["values"].index(row) + 2}:D{result["values"].index(row) + 2}',
valueInputOption='RAW',
body={'values': [[login_successes, login_failures]]}
).execute()
return True
# If no matching username and password found, add a new row with login failure
login_successes = 0
login_failures = 1
result = service.spreadsheets().values().append(
spreadsheetId=SPREADSHEET_ID,
range='ykzir_client_database_record!A:D',
valueInputOption='RAW',
insertDataOption='INSERT_ROWS',
body={'values': [[username, password, login_successes, login_failures]]}
).execute()
return False
# end of login activities record function
# linux input style
def parrot_input(prompt):
# Format the prompt to look like the Parrot OS terminal prompt
formatted_prompt = f"\033[0;32m┌─[\033[0;33m{prompt}\033[0;32m]─[\033[0;36m~\033[0;32m]\n└──╼ \033[0m"
# Print the prompt one character at a time with a small delay
for char in formatted_prompt:
print(char, end='', flush=True)
time.sleep(0.02)
# Wait for user input and return the input
return input()
# Example usage:
# prompt = parrot_input("user@parrot")
# print(f"User input: {user_input}")
enter_mlebu = """
▀▀█▀▀ █▀▀ █░█ █▀▀█ █▀▀▄
░▒█░░ █▀▀ █▀▄ █▄▄█ █░░█
░▒█░░ ▀▀▀ ▀░▀ ▀░░▀ ▀░░▀
▒█▀▀▀ █▀▀▄ ▀▀█▀▀ █▀▀ █▀▀█
▒█▀▀▀ █░░█ ░░█░░ █▀▀ █▄▄▀
▒█▄▄▄ ▀░░▀ ░░▀░░ ▀▀▀ ▀░▀▀
"""
access_granted = False
while not access_granted:
# clearing the screen if the login page failed
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
clear_screen()
from def_pesan import pesan_welcome
username, password = pesan_welcome()
# Call the Sheets API to retrieve data from the spreadsheet
result = service.spreadsheets().values().get(spreadsheetId=S_ID, range='ykzir_data!A2:B300').execute()
# Check if the provided username and password match the ones stored in the spreadsheet
for row in result.get('values', []):
if len(row) == 2 and row[0] == username and row[1] == password:
access_granted = True
break
# Grant access if the username and password match
if access_granted:
update_login_successes(service, S_ID, username, password)
os.system('cls')
access_granted = """𝔸𝕔𝕔𝕖𝕤𝕤 𝔾𝕣𝕒𝕟𝕥𝕖𝕕 \n
𝕋𝔼ℝℍ𝕌𝔹𝕌ℕ𝔾 \n 𝔻𝔼ℕ𝔾𝔸ℕ\n ℝ𝕆𝔹𝕆𝕋
"""
print(access_granted)
time.sleep(2)
input(enter_mlebu)
###################################################
# head of second layer(jantung program ykzir robot)#
###################################################
# input("akhir dari program login test" + ",program berhasil pites enter nutup terminal")
###################################################
# head of second layer(jantung program ykzir robot)#
###################################################
# head of second layer
def type_out_response(response_text):
# Function to simulate typing animation
for char in response_text:
time.sleep(0.02) # Change the delay time as desired
print(char, end="", flush=True)
print()
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
clear_screen()
# place for robot ykzir 1-the hearth.py
import argparse
import re
import time
import os
import colorama # Import the colorama library
import httplib2
from colorama import Fore, Style # Import the colorama styles
from def_pesan import type_out_response
from def_pesan import play_audio
import googleapiclient.errors
import openai
# Initialize the colorama library
colorama.init()
# Define the color styles
USER_INPUT_STYLE = Style.BRIGHT + Fore.WHITE
RESPONSE_STYLE = Style.BRIGHT + Fore.CYAN
# end of colorama line
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
clear_screen()
from def_pesan import pesan1
pesan1()
# """Argparse The argparse module allows developers to write user-friendly command-line interfaces for their scripts.
# In this script, the argparse.ArgumentParser() method is used to create a new ArgumentParser object.
# Then, add_argument() method is called on the parser object to define six command-line arguments:"""
def main():
global mrw_menjawab, mrwmemberitahukan, response_ai_source, result, url, response
parser = argparse.ArgumentParser()
parser.add_argument("--model", type=str, default="text-davinci-003", help="OpenAI GPT-3 model engine")
parser.add_argument("--max-tokens", type=int, default=3500,
help="Maximum number of tokens to generate in the response")
parser.add_argument("--temperature", type=float, default=0.3,
help="Controls the 'creativity' of the generated response")
parser.add_argument("--top-p", type=float, default=1.0,
help="Controls the diversity of the generated response")
parser.add_argument("--frequency-penalty", type=float, default=0.0,
help="Adjusts the frequency of words used in the generated response")
parser.add_argument("--presence-penalty", type=float, default=0.0,
help="Adjusts the presence of words used in the generated response")
args = parser.parse_args()
openai.api_key = "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"
model_engine = args.model
max_tokens = args.max_tokens
temperature = args.temperature
top_p = args.top_p
frequency_penalty = args.frequency_penalty
presence_penalty = args.presence_penalty
# the main program of robot ykzir
# loop this block, until the user type "exit"
while True:
import random
# The function takes two arguments: input_str,
# which is the user input, and sheet_values, which is the result of result.get('values', []).
def find_matching_phrase(input_str, sheet_values):
Indonesian_Knowledges = None
for i, row in enumerate(sheet_values):
if len(row) == 2:
Indonesian_cell_phrases = row[0].split("~ ")
for phrase in Indonesian_cell_phrases:
if phrase == input_str:
Indonesian_Knowledges_options = row[1].split("~ ")
Indonesian_Knowledges = random.choice(Indonesian_Knowledges_options)
Indonesian_Knowledges_options.remove(Indonesian_Knowledges)
break
if Indonesian_Knowledges is not None:
return Indonesian_Knowledges
'''else:
return "No answer found." - '''
try:
# (clear and exit) command, file handling commnad. question to the AI, are taken from this block
# using one user input that's called prompt
from def_pesan import parrot_input
prompt = parrot_input("User Bertanya" + USER_INPUT_STYLE + ":" + Style.RESET_ALL)
# the re.sub() method to remove any occurrence of ? or ! characters at the end of the input.
prompt = re.sub(r'[ <>/,?!]+$', '', prompt)
while True:
line = input()
if line == '' and prompt[-1] == '\\':
prompt = prompt[:-1] + '\n'
elif line == '':
break
else:
prompt += line + '\n'
except KeyboardInterrupt:
from def_pesan import pesan_ctrl_c
pesan_ctrl_c()
continue
import sys
sys.path.append('wildzanybayanat.py')
import wildzanybayanat
import webbrowser
from googleapiclient.discovery import build
# Enter your API key and CX value here
api_key = "AIzaSyB21CPp4vXscQ3oQeKYG-ejrd8-uOf-JPs"
cx = "e66d3331cd75849ea"
def google_search(query):
service = build("customsearch", "v1", developerKey=api_key)
res = service.cse().list(q=query, cx=cx).execute()
return res['items']
data_A = wildzanybayanat.awaamir
data_B = wildzanybayanat.asmaa2
data_C = wildzanybayanat.jar_majruur
suffixes = wildzanybayanat.i09aafah
data_D = []
for b in data_B:
for s in suffixes:
data_D.append(b + s)
data_D = list(set(data_C))
data_D.sort()
# print(data_C)
sart_wa_jawabu_sart_data2 = wildzanybayanat.sart_wa_jawabu_sart_data2
prompt2 = prompt
question_keys = prompt2.split()
matches_A = [key for key in question_keys if key in data_A]
matches_B = [key for key in question_keys if key in data_B]
matches_C = [key for key in question_keys if key in data_C]
##########
# explaination
# checking condition, what kind of typing the user does
# 1. basic command (clear and exit) 2. office command (to handle / to deal with office file)
# 3. if none of the above are True, the user input is transfered to openAI
# here M RIZKY WILDZANY used "google sheet" to store the dictionary data"
try:
from YkzirRobot_Database_GoogleSheet_V2 import res_old_values
Indonesian_list_cell = res_old_values
Indonesian_Knowledges = find_matching_phrase(prompt, Indonesian_list_cell)
if Indonesian_Knowledges:
from def_pesan import response1
response1(Indonesian_Knowledges)
elif len(matches_A) > 0 and len(matches_C) > 0:
query_list = question_keys
query = ''
words_to_remove = set(matches_A + matches_C)
while any(word in query_list for word in words_to_remove):
for word_to_remove in words_to_remove:
if word_to_remove in query_list:
query_list.remove(word_to_remove)
query = ' '.join(query_list)
url = f"https://www.bing.com/search?q={query}" # https://www.bing.com/images/search?q=
# results = google_search(query)
if url:
# print(query_list)
# print(matches_B)
webbrowser.open_new(url)
from def_pesan import pesan_web
pesan_web(query)
else:
from def_pesan import pesan_else_web
pesan_else_web(query)
elif len(matches_A) > 0 and len(matches_B) > 0:
# lek userinput subset e valuene var matches_A_B lakonono iki,
# lek guduk subset e, lalekno perintah ndik isor iki
# find key that contains 'matches_B'
matches_A_B = set(matches_A + matches_B)
if set(question_keys).issubset(matches_A_B):
for match in matches_B:
for key, value in sart_wa_jawabu_sart_data2.items():
if match in value:
from def_pesan import pesan_open_folder
pesan_open_folder()
webbrowser.open_new_tab(key)
break # stop searching once the key is found
elif prompt.lower() in ['ykzir crawler']:
crawler_memberitahukan = "M Rizky Wildzany Memberitahukan"
print(
f"\n\033[0;32m┌─[\033[0;34m{crawler_memberitahukan}\033[0;32m]─[\033[0;36m~\033[0;32m]\n└──╼ \033[0m")
type_out_response("Ykzir-Robot-Crawler dimunculkan !!")
time.sleep(1)
from def_crawler import search_and_display
search_and_display()
print(
f"\n\033[0;32m┌─[\033[0;34m{crawler_memberitahukan}\033[0;32m]─[\033[0;36m~\033[0;32m]\n└──╼ \033[0m")
type_out_response("Ykzir-Robot-Crawler ditutup !!")
elif prompt.lower() in ['exit']:
# close the program
break
elif prompt.lower() == 'clear':
clear_screen()
continue
elif prompt.lower() in ["simpenen dadi file docx"]:
from def_pesan import pesan_docx
from def_docx import create_docx_file_with_dialog
create_docx_file_with_dialog(response.choices[0].text.strip())
elif sum(word in a for word in prompt.split()) >= 2:
x = filter_user_input(a, prompt)
xs = regex.findall(r'"[^"]*"|[^"\s]+', x)
ADD_FALN(service, SPREADSHEET_ID_old, username, password, prompt,
response.choices[0].text.strip(), xs[0],
xs[1], xs[2],
xs[3])
from def_pesan import pesan_log_saved
pesan_log_saved()
elif prompt.lower() in ["ib7ath 3an sha59"]:
from tracking import data_parser
data_parser()
elif prompt == "almusaa3adaat":
from def_pesan import kalimat_almurur
kalimat_almurur()
x = input("::::")
if x == "show me the commands":
from def_pesan import show_commands
show_commands()
else:
pass
else:
# the main openai program
response = openai.Completion.create(
model=model_engine,
prompt=prompt,
temperature=temperature,
max_tokens=max_tokens,
top_p=top_p,
frequency_penalty=frequency_penalty,
presence_penalty=presence_penalty
)
from def_pesan import response_ai
response_ai_source = response_ai(response)
simpen_conversation_log(service, SPREADSHEET_ID_old, username, password, prompt,
response.choices[0].text.strip())
# Error communicating with OpenAI. Retrying in 3 seconds
except openai.error.APIConnectionError:
mrwmemberitahukan = r"M Rizky Wildzany - Memberitahukan"
mrw_warning = "maaf system sibuk, menyambungkan kembali dalam 3 detik"
mrw_warning_display = type_out_response(mrw_warning)
play_audio("ykzir_robotic_glitch2.wav")
print(
f"\n\033[0;32m┌─[\033[0;34m{mrwmemberitahukan}\033[0;32m]─[\033[0;36m~\033[0;32m]\n└──╼ \033[0m{mrw_warning_display}")
time.sleep(3)
continue
except httplib2.error.ServerNotFoundError:
from def_pesan import pesan_no_internet
pesan_no_internet()
break
except KeyboardInterrupt:
from def_pesan import pesan_ctrl_c
pesan_ctrl_c()
continue
except NameError:
from def_pesan import pesan_NameError
NameError()
continue
except googleapiclient.errors.HttpError as error:
if error.resp.status == 429:
from def_pesan import ex_google_limit
ex_google_limit()
else:
print(f"An error occurred: {error}")
# End of robot ykzir program
if __name__ == "__main__":
# argparse fucntion
main()
# Here#
# end of the login page layer
else:
logosalah = """
─█▀▀█ ░█─▄▀ ░█─░█ ░█▄─░█ ░█▀▀▀
░█▄▄█ ░█▀▄─ ░█─░█ ░█░█░█ ░█▀▀▀
░█─░█ ░█─░█ ─▀▄▄▀ ░█──▀█ ░█▄▄▄
░█▀▀▀█ ─█▀▀█ ░█─── ─█▀▀█ ░█─░█ █
─▀▀▀▄▄ ░█▄▄█ ░█─── ░█▄▄█ ░█▀▀█ ▀
░█▄▄▄█ ░█─░█ ░█▄▄█ ░█─░█ ░█─░█ ▄
"""
print(logosalah)
time.sleep(1)
# record the failed login
update_login_successes(service, S_ID, username, password)
# Clear the terminal
if os.name == 'nt': # check if Windows
os.system('cls')
else: # any other OS (Linux, macOS, etc.)
os.system('clear')