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
6d9e2332
Commit
6d9e2332
authored
Feb 11, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add chatgpt
parent
656f7254
Pipeline
#20084
passed with stages
in 8 minutes and 26 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
1 deletion
+70
-1
data/default_config.json
data/default_config.json
+5
-0
ygopro-server.coffee
ygopro-server.coffee
+24
-0
ygopro-server.js
ygopro-server.js
+41
-1
No files found.
data/default_config.json
View file @
6d9e2332
...
...
@@ -228,6 +228,11 @@
],
"ip_header"
:
"x-forwarded-for"
},
"chatgpt"
:
{
"enabled"
:
false
,
"endpoint"
:
"https://chatgpt.hanatan.net"
,
"token"
:
"hanatan"
},
"test_mode"
:
{
"watch_public_hand"
:
false
,
"no_connect_count_limit"
:
false
,
...
...
ygopro-server.coffee
View file @
6d9e2332
...
...
@@ -3462,6 +3462,30 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
client
.
abuse_count
=
client
.
abuse_count
+
2
if
client
.
abuse_count
ygopro
.
stoc_send_chat
(
client
,
"${chat_warn_level0}"
,
ygopro
.
constants
.
COLORS
.
RED
)
cancel
=
true
if
not
cancel
and
settings
.
modules
.
chatgpt
.
enabled
and
room
.
windbot
and
not
client
.
is_post_watcher
and
client
.
pos
==
0
#< 2 and not client.is_local
session_key
=
"
#{
settings
.
modules
.
chatgpt
.
session
}
:
#{
settings
.
port
}
:
#{
CLIENT_get_authorize_key
(
client
)
}
"
axios
.
post
(
"
#{
settings
.
modules
.
chatgpt
.
endpoint
}
/api/chat"
,
{
session
:
session_key
,
text
:
msg
},
{
timeout
:
300000
,
headers
:
{
Authorization
:
"Bearer
#{
settings
.
modules
.
chatgpt
.
token
}
"
}
}).
then
((
res
)
->
text
=
res
.
data
.
data
.
text
lines
=
text
.
split
(
"
\n
"
)
for
line
in
lines
if
line
chunks
=
_
.
chunk
(
line
,
100
)
for
chunk
in
chunks
ygopro
.
stoc_send_chat_to_room
(
room
,
chunk
.
join
(
''
),
1
-
client
.
pos
)
else
ygopro
.
stoc_send_chat_to_room
(
room
,
' '
,
1
-
client
.
pos
)
).
catch
((
err
)
->
log
.
error
"CHATGPT ERROR"
,
session_key
,
err
)
return
false
if
!
(
room
and
(
room
.
random_type
or
room
.
arena
))
and
not
settings
.
modules
.
mycard
.
enabled
if
!
cancel
and
settings
.
modules
.
display_watchers
and
(
client
.
is_post_watcher
or
client
.
pos
>
3
)
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
client
.
name
}
:
#{
msg
}
"
,
9
)
...
...
ygopro-server.js
View file @
6d9e2332
...
...
@@ -4391,7 +4391,7 @@
//else
//log.info 'BIG BROTHER OK', response.statusCode, roomname, body
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
,
key
,
msg
,
name
,
oldmsg
,
ref
,
room
,
struct
,
sur_player
,
uname
,
windbot
,
word
;
var
buy_result
,
cancel
,
ccolor
,
cip
,
cmd
,
cmsg
,
cname
,
code
,
color
,
cvalue
,
isVip
,
key
,
msg
,
name
,
oldmsg
,
ref
,
room
,
s
ession_key
,
s
truct
,
sur_player
,
uname
,
windbot
,
word
;
room
=
ROOM_all
[
client
.
rid
];
if
(
!
room
)
{
return
;
...
...
@@ -4640,6 +4640,46 @@
ygopro
.
stoc_send_chat
(
client
,
"
${chat_warn_level0}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
cancel
=
true
;
}
if
(
!
cancel
&&
settings
.
modules
.
chatgpt
.
enabled
&&
room
.
windbot
&&
!
client
.
is_post_watcher
&&
client
.
pos
===
0
)
{
//< 2 and not client.is_local
session_key
=
`
${
settings
.
modules
.
chatgpt
.
session
}
:
${
settings
.
port
}
:
${
CLIENT_get_authorize_key
(
client
)}
`
;
log
.
info
(
"
chatgpt
"
,
session_key
,
msg
);
axios
.
post
(
`
${
settings
.
modules
.
chatgpt
.
endpoint
}
/api/chat`
,
{
session
:
session_key
,
text
:
msg
},
{
timeout
:
300000
,
headers
:
{
Authorization
:
`Bearer
${
settings
.
modules
.
chatgpt
.
token
}
`
}
}).
then
(
function
(
res
)
{
var
chunk
,
chunks
,
j
,
len
,
line
,
lines
,
results
,
text
;
log
.
info
(
"
chatgpt result
"
,
res
.
data
.
text
);
text
=
res
.
data
.
data
.
text
;
lines
=
text
.
split
(
"
\n
"
);
results
=
[];
for
(
j
=
0
,
len
=
lines
.
length
;
j
<
len
;
j
++
)
{
line
=
lines
[
j
];
if
(
line
)
{
chunks
=
_
.
chunk
(
line
,
100
);
results
.
push
((
function
()
{
var
l
,
len1
,
results1
;
results1
=
[];
for
(
l
=
0
,
len1
=
chunks
.
length
;
l
<
len1
;
l
++
)
{
chunk
=
chunks
[
l
];
results1
.
push
(
ygopro
.
stoc_send_chat_to_room
(
room
,
chunk
.
join
(
''
),
1
-
client
.
pos
));
}
return
results1
;
})());
}
else
{
results
.
push
(
ygopro
.
stoc_send_chat_to_room
(
room
,
'
'
,
1
-
client
.
pos
));
}
}
return
results
;
}).
catch
(
function
(
err
)
{
return
log
.
error
(
"
CHATGPT ERROR
"
,
session_key
,
err
);
});
return
false
;
}
if
(
!
(
room
&&
(
room
.
random_type
||
room
.
arena
))
&&
!
settings
.
modules
.
mycard
.
enabled
)
{
if
(
!
cancel
&&
settings
.
modules
.
display_watchers
&&
(
client
.
is_post_watcher
||
client
.
pos
>
3
))
{
ygopro
.
stoc_send_chat_to_room
(
room
,
`
${
client
.
name
}
:
${
msg
}
`
,
9
);
...
...
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