代码拉取完成,页面将自动刷新
同步操作将从 onrange/wechat_chatgpt 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
# openai
from time import sleep
import openai
from wxpy import *
# Organization
openai.organization = "YOUR_organization"
# api_key
openai.api_key = "YOUR_api_key"
toxic_threshold = -0.355
openai.Model.list()
show_str = ""
def getChatRetrun(content_to_classify):
response = openai.Completion.create(
model="text-davinci-003",
# model="code-davinci-002",
prompt=content_to_classify,
temperature=0.9,
max_tokens=2048,
top_p=1,
frequency_penalty=0.0,
presence_penalty=0.6,
stream=False
)
# print("\n机器人:\n")
# for completion in response:
# print(completion["choices"][0]["text"],end="")
# # show_str+=completion["choices"][0]["text"]
return response["choices"][0]["text"]
'''
微信登录,回复操作函数
'''
# 要自动回复的群个数
groupNames = []
groups = []
print("请登录微信,扫码后稍等片刻")
bot = Bot() # 获取所有好友
sleep(1)
num = input('\n您要自动回复几个群(数字):')
if(int(num)==0):
exit(0)
for i in range(int(num)):
group_name = input('输入需自动回复的群{}名称:'.format(i+1))
if(i==0):
print("正在加载好友列表,过程较慢,请稍等!!!")
groupNames.append(group_name)
if(len(bot.groups().search(group_name))>0):
groups.append(bot.groups().search(group_name)[0])
print("[{}]设置成功".format(group_name))
else:
print("[{}]设置失败,未找到该名称的群".format(group_name))
# group_name2 = input('输入需自动回复的群名称2:')
my_msg_head = r'@{}'.format(bot.self.nick_name)
print("设置完成,可以开始使用了,以[{}]开头就会回复".format(my_msg_head))
# group2 = bot.groups().search(group_name2)[0]
def getReplayName(msg):
display_name = msg.member.display_name
if (msg.member.is_friend == False):
pass
elif (len(msg.member.display_name) == 0):
display_name = bot.search(msg.member.name)[0].nick_name
else:
pass
return display_name
#指定好友
# friend = bot.friends().search(\'好友名\')[0]
#按需求修改参数
@bot.register(groups,msg_types=TEXT,except_self=False)
def gourp1_reply(msg):
print("{}:{}".format(msg.member.name,msg.text))
if(msg.text.startswith(my_msg_head)):
send_str = getChatRetrun(msg.text.replace(my_msg_head,''))
send_final = "@{} {}".format(getReplayName(msg), send_str)
print('{}:{}'.format(getReplayName(msg),send_final))
return send_final
if __name__ == '__main__':
# while(1):
# text = input("\n我:")
# getChatRetrun('Shell 遍历文件怎么写')
bot.join()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。