设计连接自然一号(ChatGaoshan)的Python程序
前些天不是制作了自然一号嘛现在要用Python搞个接口,要求:
1、GUI或非GUI都可以
2、至少保证输入输出、人称
3、接口数据:
APPID:
kqyU4h4uUDsSkwn
Token:
n1l6sJwy5MLw3SiQTtqDCMqV54XIev
Encoding AESKey:
tF6XFqWLAh6hXuICjGL3oAsT4S2yrMfU7GaZZGf9KVY
认证模式:POST
(以上接口喜欢的人也可以调用哦)
GPT回答也可以,就一个要求:请仔细核查后再进行!!!!!
自然一号体验连接:https://chatbot.weixin.qq.com/webapp/n1l6sJwy5MLw3SiQTtqDCMqV54XIev?robotName=%E8%87%AA%E7%84%B6%E4%B8%80%E5%8F%B7
这是微信对话开放平台提供的 一个简单的 GUI 界面:
import json
import requests
from tkinter import *
class ChatApp:
def __init__(self, master):
self.master = master
master.title("Chatbot GUI")
# Setting the window size
window_width = 500
window_height = 500
# Gets both half the screen width/height and window width/height
position_right = int(master.winfo_screenwidth()/2 - window_width/2)
position_down = int(master.winfo_screenheight()/2 - window_height/2)
# Positions the window in the center of the page.
master.geometry(f'{window_width}x{window_height}+{position_right}+{position_down}')
self.userid = 'alsjdasf12'# replace with your user id
self.signature_url = 'https://chatbot.weixin.qq.com/openapi/sign/n1l6sJwy5MLw3SiQTtqDCMqV54XIev'
self.chat_url = 'https://chatbot.weixin.qq.com/openapi/aibot/n1l6sJwy5MLw3SiQTtqDCMqV54XIev'
self.signature = self.get_signature()
self.chat_frame = Frame(master)
self.chat_frame.pack(fill=BOTH, expand=True)
self.scrollbar = Scrollbar(self.chat_frame)
self.chat_listbox = Listbox(self.chat_frame, yscrollcommand=self.scrollbar.set)
self.scrollbar.config(command=self.chat_listbox.yview)
self.chat_listbox.pack(side="left", fill="both", expand=True)
self.scrollbar.pack(side="right", fill="y")
self.entry_frame = Frame(master)
self.entry_frame.pack(fill=X, side=BOTTOM)
self.entry_text = StringVar()
self.entry_field = Entry(self.entry_frame, text=self.entry_text)
self.entry_field.bind("<Return>", self.send_message_event)
self.entry_field.pack(side="left", fill="x", expand=True)
self.send_button = Button(self.entry_frame, text="发送", command=self.send_message)
self.send_button.pack(side="right")
self.new_chat_button = Button(self.entry_frame, text="开始新的对话", command=self.start_new_chat)
self.new_chat_button.pack(side="right")
def send_message_event(self, event):
self.send_message()
def send_message(self):
message = self.entry_text.get()
self.chat_listbox.insert(END, "你: " + message)
self.entry_text.set("")
response = self.post_chat_message(message)
self.chat_listbox.insert(END, "机器人: " + response)
def get_signature(self):
data = {
"userid": self.userid
}
response = requests.post(self.signature_url, json=data)
response_data = response.json()
return response_data['signature']
def post_chat_message(self, query):
data = {
"signature": self.signature,
"query": query
}
response = requests.post(self.chat_url, json=data)
response_data = response.json()
return response_data['answer']
def start_new_chat(self):
self.chat_listbox.delete(0, END)
self.signature = self.get_signature()
root = Tk()
my_gui = ChatApp(root)
root.mainloop()
看不懂你在说啥{:10_277:} 歌者文明清理员 发表于 2023-6-27 10:51
看不懂你在说啥
GPT都能看懂,你看不懂(虽然他说的是错的 高山 发表于 2023-6-27 11:01
GPT都能看懂,你看不懂(虽然他说的是错的
我正在开发最佳脚本(不知道为什么之前的失效了,打开程序正常,可就是不肯回答问题) 就这么把你的token放出来了? isdkz 发表于 2023-6-27 12:10
就这么把你的token放出来了?
你别想干什么坏事,不然你就惨了 isdkz 发表于 2023-6-27 12:38
一个简单的 GUI 界面:
哇!!1不错!!!! 高山 发表于 2023-6-27 12:45
哇!!1不错!!!!
那个不会滚动到最新的对话,这个改进了一下下:
import json
import requests
from tkinter import *
class ChatApp:
def __init__(self, master):
self.master = master
master.title("Chatbot GUI")
# Setting the window size
window_width = 500
window_height = 500
# Gets both half the screen width/height and window width/height
position_right = int(master.winfo_screenwidth()/2 - window_width/2)
position_down = int(master.winfo_screenheight()/2 - window_height/2)
# Positions the window in the center of the page.
master.geometry(f'{window_width}x{window_height}+{position_right}+{position_down}')
self.userid = 'alsjdasf12'# replace with your user id
self.signature_url = 'https://chatbot.weixin.qq.com/openapi/sign/n1l6sJwy5MLw3SiQTtqDCMqV54XIev'
self.chat_url = 'https://chatbot.weixin.qq.com/openapi/aibot/n1l6sJwy5MLw3SiQTtqDCMqV54XIev'
self.signature = self.get_signature()
self.chat_frame = Frame(master)
self.chat_frame.pack(fill=BOTH, expand=True)
self.scrollbar = Scrollbar(self.chat_frame)
self.chat_listbox = Listbox(self.chat_frame, yscrollcommand=self.scrollbar.set)
self.scrollbar.config(command=self.chat_listbox.yview)
self.chat_listbox.pack(side="left", fill="both", expand=True)
self.scrollbar.pack(side="right", fill="y")
self.entry_frame = Frame(master)
self.entry_frame.pack(fill=X, side=BOTTOM)
self.entry_text = StringVar()
self.entry_field = Entry(self.entry_frame, text=self.entry_text)
self.entry_field.bind("<Return>", self.send_message_event)
self.entry_field.pack(side="left", fill="x", expand=True)
self.send_button = Button(self.entry_frame, text="发送", command=self.send_message)
self.send_button.pack(side="right")
self.new_chat_button = Button(self.entry_frame, text="开始新的对话", command=self.start_new_chat)
self.new_chat_button.pack(side="right")
def send_message_event(self, event):
self.send_message()
def send_message(self):
message = self.entry_text.get()
self.chat_listbox.insert(END, "你: " + message)
self.entry_text.set("")
response = self.post_chat_message(message)
self.chat_listbox.insert(END, "机器人: " + response)
self.chat_listbox.see(END)# This line makes sure the latest message is visible
def get_signature(self):
data = {
"userid": self.userid
}
response = requests.post(self.signature_url, json=data)
response_data = response.json()
return response_data['signature']
def post_chat_message(self, query):
data = {
"signature": self.signature,
"query": query
}
response = requests.post(self.chat_url, json=data)
response_data = response.json()
return response_data['answer']
def start_new_chat(self):
self.chat_listbox.delete(0, END)
self.signature = self.get_signature()
root = Tk()
my_gui = ChatApp(root)
root.mainloop()
高山 发表于 2023-6-27 12:26
你别想干什么坏事,不然你就惨了
其实就算你不把token放出来,访问你那个机器人然后抓包也能抓得到{:10_256:} isdkz 发表于 2023-6-27 12:52
其实就算你不把token放出来,访问你那个机器人然后抓包也能抓得到
你!想!干!啥!
页:
[1]