Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
srvpro
Commits
f905e865
Commit
f905e865
authored
Aug 13, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chatgpt
parent
92fd82f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
18 deletions
+40
-18
data/default_config.json
data/default_config.json
+6
-3
ygopro-server.coffee
ygopro-server.coffee
+13
-7
ygopro-server.js
ygopro-server.js
+21
-8
No files found.
data/default_config.json
View file @
f905e865
...
@@ -242,9 +242,12 @@
...
@@ -242,9 +242,12 @@
},
},
"chatgpt"
:
{
"chatgpt"
:
{
"enabled"
:
false
,
"enabled"
:
false
,
"endpoint"
:
"https://chatgpt.hanatan.net"
,
"endpoint"
:
"https://api.openai.com"
,
"token"
:
"hanatan"
,
"token"
:
"sk-xxxx"
,
"session"
:
"srvpro"
"model"
:
"gpt-4o-mini"
,
"system_prompt"
:
""
,
"comment"
:
"{{player}} and {{opponent}} will be replaced in the prompt"
,
"extra_opts"
:
{}
},
},
"test_mode"
:
{
"test_mode"
:
{
"watch_public_hand"
:
false
,
"watch_public_hand"
:
false
,
...
...
ygopro-server.coffee
View file @
f905e865
...
@@ -3674,17 +3674,23 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
...
@@ -3674,17 +3674,23 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
ygopro
.
stoc_send_chat
(
client
,
"${chat_warn_level0}"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_send_chat
(
client
,
"${chat_warn_level0}"
,
ygopro
.
constants
.
COLORS
.
RED
)
cancel
=
true
cancel
=
true
if
not
cancel
and
settings
.
modules
.
chatgpt
.
enabled
and
room
.
windbot
and
not
client
.
is_post_watcher
and
client
.
pos
<
2
and
not
client
.
is_local
if
not
cancel
and
settings
.
modules
.
chatgpt
.
enabled
and
room
.
windbot
and
not
client
.
is_post_watcher
and
client
.
pos
<
2
and
not
client
.
is_local
session_key
=
"
#{
settings
.
modules
.
chatgpt
.
session
}
:
#{
settings
.
port
}
:
#{
CLIENT_get_authorize_key
(
client
)
}
"
# session_key = "#{settings.modules.chatgpt.session}:#{settings.port}:#{CLIENT_get_authorize_key(client)}"
axios
.
post
(
"
#{
settings
.
modules
.
chatgpt
.
endpoint
}
/api/chat"
,
{
openai_req_body
=
{
session
:
session_key
,
messages
:
[
text
:
msg
{
role
:
"user"
,
content
:
msg
}
},
{
],
model
:
settings
.
modules
.
chatgpt
.
model
}
if
settings
.
modules
.
chatgpt
.
system_prompt
openai_req_body
.
messages
.
unshift
{
role
:
"system"
,
content
:
settings
.
modules
.
chatgpt
.
system_prompt
.
replace
}
Object
.
assign
(
openai_req_body
,
settings
.
modules
.
chatgpt
.
extra_opts
)
axios
.
post
(
"
#{
settings
.
modules
.
chatgpt
.
endpoint
}
/v1/chat/completions"
,
openai_req_body
,
{
timeout
:
300000
,
timeout
:
300000
,
headers
:
{
headers
:
{
Authorization
:
"Bearer
#{
settings
.
modules
.
chatgpt
.
token
}
"
Authorization
:
"Bearer
#{
settings
.
modules
.
chatgpt
.
token
}
"
}
}
}).
then
((
res
)
->
}).
then
((
res
)
->
text
=
res
.
data
.
data
.
tex
t
text
=
res
.
data
.
choices
[
0
].
message
.
conten
t
lines
=
text
.
split
(
"
\n
"
)
lines
=
text
.
split
(
"
\n
"
)
for
line
in
lines
for
line
in
lines
if
line
if
line
...
@@ -3694,7 +3700,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
...
@@ -3694,7 +3700,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
else
else
ygopro
.
stoc_send_chat_to_room
(
room
,
' '
,
1
-
client
.
pos
)
ygopro
.
stoc_send_chat_to_room
(
room
,
' '
,
1
-
client
.
pos
)
).
catch
((
err
)
->
).
catch
((
err
)
->
log
.
error
"CHATGPT ERROR"
,
session_key
,
err
log
.
error
"CHATGPT ERROR"
,
err
)
)
return
false
return
false
if
!
(
room
and
(
room
.
random_type
or
room
.
arena
))
and
not
settings
.
modules
.
mycard
.
enabled
if
!
(
room
and
(
room
.
random_type
or
room
.
arena
))
and
not
settings
.
modules
.
mycard
.
enabled
...
...
ygopro-server.js
View file @
f905e865
...
@@ -4652,7 +4652,7 @@
...
@@ -4652,7 +4652,7 @@
//else
//else
//log.info 'BIG BROTHER OK', response.statusCode, roomname, body
//log.info 'BIG BROTHER OK', response.statusCode, roomname, body
ygopro
.
ctos_follow
(
'
CHAT
'
,
true
,
async
function
(
buffer
,
info
,
client
,
server
,
datas
)
{
ygopro
.
ctos_follow
(
'
CHAT
'
,
true
,
async
function
(
buffer
,
info
,
client
,
server
,
datas
)
{
var
buy_result
,
cancel
,
ccolor
,
cip
,
cmd
,
cmsg
,
cname
,
code
,
color
,
cvalue
,
isVip
,
j
,
key
,
len
,
msg
,
name
,
oldmsg
,
player
,
ref
,
ref1
,
room
,
session_key
,
struct
,
sur_player
,
uname
,
windbot
,
word
;
var
buy_result
,
cancel
,
ccolor
,
cip
,
cmd
,
cmsg
,
cname
,
code
,
color
,
cvalue
,
isVip
,
j
,
key
,
len
,
msg
,
name
,
oldmsg
,
openai_req_body
,
player
,
ref
,
ref1
,
room
,
struct
,
sur_player
,
uname
,
windbot
,
word
;
room
=
ROOM_all
[
client
.
rid
];
room
=
ROOM_all
[
client
.
rid
];
if
(
!
room
)
{
if
(
!
room
)
{
return
;
return
;
...
@@ -4907,18 +4907,31 @@
...
@@ -4907,18 +4907,31 @@
cancel
=
true
;
cancel
=
true
;
}
}
if
(
!
cancel
&&
settings
.
modules
.
chatgpt
.
enabled
&&
room
.
windbot
&&
!
client
.
is_post_watcher
&&
client
.
pos
<
2
&&
!
client
.
is_local
)
{
if
(
!
cancel
&&
settings
.
modules
.
chatgpt
.
enabled
&&
room
.
windbot
&&
!
client
.
is_post_watcher
&&
client
.
pos
<
2
&&
!
client
.
is_local
)
{
session_key
=
`
${
settings
.
modules
.
chatgpt
.
session
}
:
${
settings
.
port
}
:
${
CLIENT_get_authorize_key
(
client
)}
`
;
// session_key = "#{settings.modules.chatgpt.session}:#{settings.port}:#{CLIENT_get_authorize_key(client)}"
axios
.
post
(
`
${
settings
.
modules
.
chatgpt
.
endpoint
}
/api/chat`
,
{
openai_req_body
=
{
session
:
session_key
,
messages
:
[
text
:
msg
{
},
{
role
:
"
user
"
,
content
:
msg
}
],
model
:
settings
.
modules
.
chatgpt
.
model
};
if
(
settings
.
modules
.
chatgpt
.
system_prompt
)
{
openai_req_body
.
messages
.
unshift
({
role
:
"
system
"
,
content
:
settings
.
modules
.
chatgpt
.
system_prompt
.
replace
});
}
Object
.
assign
(
openai_req_body
,
settings
.
modules
.
chatgpt
.
extra_opts
);
axios
.
post
(
`
${
settings
.
modules
.
chatgpt
.
endpoint
}
/v1/chat/completions`
,
openai_req_body
,
{
timeout
:
300000
,
timeout
:
300000
,
headers
:
{
headers
:
{
Authorization
:
`Bearer
${
settings
.
modules
.
chatgpt
.
token
}
`
Authorization
:
`Bearer
${
settings
.
modules
.
chatgpt
.
token
}
`
}
}
}).
then
(
function
(
res
)
{
}).
then
(
function
(
res
)
{
var
chunk
,
chunks
,
l
,
len1
,
line
,
lines
,
results
,
text
;
var
chunk
,
chunks
,
l
,
len1
,
line
,
lines
,
results
,
text
;
text
=
res
.
data
.
data
.
tex
t
;
text
=
res
.
data
.
choices
[
0
].
message
.
conten
t
;
lines
=
text
.
split
(
"
\n
"
);
lines
=
text
.
split
(
"
\n
"
);
results
=
[];
results
=
[];
for
(
l
=
0
,
len1
=
lines
.
length
;
l
<
len1
;
l
++
)
{
for
(
l
=
0
,
len1
=
lines
.
length
;
l
<
len1
;
l
++
)
{
...
@@ -4940,7 +4953,7 @@
...
@@ -4940,7 +4953,7 @@
}
}
return
results
;
return
results
;
}).
catch
(
function
(
err
)
{
}).
catch
(
function
(
err
)
{
return
log
.
error
(
"
CHATGPT ERROR
"
,
session_key
,
err
);
return
log
.
error
(
"
CHATGPT ERROR
"
,
err
);
});
});
return
false
;
return
false
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment