Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
I
init-things
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
init-things
Commits
423a0eb9
You need to sign in or sign up before continuing.
Commit
423a0eb9
authored
May 10, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove bot controller
parent
f38a5d8a
Pipeline
#3212
passed with stages
in 1 minute and 45 seconds
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
104 additions
and
57 deletions
+104
-57
things/nest-koishijs/README.md
things/nest-koishijs/README.md
+36
-0
things/nest-koishijs/src/app.module.ts
things/nest-koishijs/src/app.module.ts
+3
-1
things/nest-koishijs/src/app.service.ts
things/nest-koishijs/src/app.service.ts
+0
-1
things/nest-koishijs/src/bot/bot.controller.spec.ts
things/nest-koishijs/src/bot/bot.controller.spec.ts
+0
-18
things/nest-koishijs/src/bot/bot.controller.ts
things/nest-koishijs/src/bot/bot.controller.ts
+0
-37
things/nest-koishijs/src/bot/bot.service.ts
things/nest-koishijs/src/bot/bot.service.ts
+35
-0
things/nest-typeorm/README.md
things/nest-typeorm/README.md
+30
-0
No files found.
things/nest-koishijs/README.md
0 → 100644
View file @
423a0eb9
# App name
App description.
## Environment
*
`DB_HOST`
`DB_PORT`
`DB_USER`
`DB_PASS`
`DB_NAME`
Database configs.
*
`CQ_ID`
QQ account.
*
`CQ_SERVER`
OneBot server address.
*
`CQ_TOKEN`
OneBot server token.
## Installation
```
bash
$
npm
install
```
## Running the app
```
bash
# development
$
npm run start
# watch mode
$
npm run start:dev
# production mode
$
npm run start:prod
```
## License
AGPLv3
things/nest-koishijs/src/app.module.ts
View file @
423a0eb9
...
@@ -4,10 +4,12 @@ import { AppService } from './app.service';
...
@@ -4,10 +4,12 @@ import { AppService } from './app.service';
import
{
AppLogger
}
from
'
./app.logger
'
;
import
{
AppLogger
}
from
'
./app.logger
'
;
import
{
TypeOrmModule
}
from
'
@nestjs/typeorm
'
;
import
{
TypeOrmModule
}
from
'
@nestjs/typeorm
'
;
import
{
typeormConfig
}
from
'
./config
'
;
import
{
typeormConfig
}
from
'
./config
'
;
import
{
BotService
}
from
'
./bot/bot.service
'
;
import
{
BotLogger
}
from
'
./bot/bot.logger
'
;
@
Module
({
@
Module
({
imports
:
[
TypeOrmModule
.
forRoot
(
typeormConfig
())],
imports
:
[
TypeOrmModule
.
forRoot
(
typeormConfig
())],
controllers
:
[
AppController
],
controllers
:
[
AppController
],
providers
:
[
AppService
,
AppLogger
],
providers
:
[
AppService
,
AppLogger
,
BotService
,
BotLogger
],
})
})
export
class
AppModule
{}
export
class
AppModule
{}
things/nest-koishijs/src/app.service.ts
View file @
423a0eb9
...
@@ -10,7 +10,6 @@ export class AppService {
...
@@ -10,7 +10,6 @@ export class AppService {
@
InjectConnection
(
'
app
'
)
@
InjectConnection
(
'
app
'
)
private
db
:
Connection
,
private
db
:
Connection
,
private
log
:
AppLogger
,
private
log
:
AppLogger
,
private
botService
:
BotService
,
)
{
)
{
this
.
log
.
setContext
(
'
app
'
);
this
.
log
.
setContext
(
'
app
'
);
}
}
...
...
things/nest-koishijs/src/bot/bot.controller.spec.ts
deleted
100644 → 0
View file @
f38a5d8a
import
{
Test
,
TestingModule
}
from
'
@nestjs/testing
'
;
import
{
BotController
}
from
'
./bot.controller
'
;
describe
(
'
BotController
'
,
()
=>
{
let
controller
:
BotController
;
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
controllers
:
[
BotController
],
}).
compile
();
controller
=
module
.
get
<
BotController
>
(
BotController
);
});
it
(
'
should be defined
'
,
()
=>
{
expect
(
controller
).
toBeDefined
();
});
});
things/nest-koishijs/src/bot/bot.controller.ts
deleted
100644 → 0
View file @
f38a5d8a
import
{
Controller
}
from
'
@nestjs/common
'
;
import
{
AppService
}
from
'
../app.service
'
;
import
{
BotService
}
from
'
./bot.service
'
;
import
{
App
}
from
'
koishi
'
;
import
*
as
koishiCommonPlugin
from
'
koishi-plugin-common
'
;
import
*
as
adapter
from
'
koishi-adapter-onebot
'
;
const
__
=
typeof
adapter
;
// just for import
@
Controller
(
'
_bot
'
)
export
class
BotController
{
bot
:
App
;
constructor
(
private
readonly
appService
:
AppService
,
private
readonly
botService
:
BotService
,
)
{
this
.
initializeBot
();
}
async
initializeBot
()
{
this
.
bot
=
new
App
({
type
:
'
onebot:ws
'
,
selfId
:
process
.
env
.
CQ_ID
,
server
:
process
.
env
.
CQ_SERVER
,
token
:
process
.
env
.
CQ_TOKEN
,
prefix
:
process
.
env
.
CQ_PREFIX
||
'
.
'
,
});
this
.
bot
.
plugin
(
koishiCommonPlugin
);
this
.
loadBotRouters
();
await
this
.
bot
.
start
();
this
.
botService
.
log
.
log
(
`Bot started.`
);
}
loadBotRouters
()
{
// all middlewares should be here.
this
.
bot
.
command
(
'
echo <msg:text>
'
).
action
((
argv
,
msg
)
=>
{
return
msg
;
});
}
}
things/nest-koishijs/src/bot/bot.service.ts
View file @
423a0eb9
...
@@ -4,15 +4,47 @@ import { Connection } from 'typeorm';
...
@@ -4,15 +4,47 @@ import { Connection } from 'typeorm';
import
{
BotLogger
}
from
'
./bot.logger
'
;
import
{
BotLogger
}
from
'
./bot.logger
'
;
import
{
User
}
from
'
../entities/User
'
;
import
{
User
}
from
'
../entities/User
'
;
import
{
Group
}
from
'
../entities/Group
'
;
import
{
Group
}
from
'
../entities/Group
'
;
import
{
App
,
AppConfig
}
from
'
koishi
'
;
import
{
AppService
}
from
'
../app.service
'
;
import
*
as
koishiCommonPlugin
from
'
koishi-plugin-common
'
;
import
*
as
adapter
from
'
koishi-adapter-onebot
'
;
import
{
CQBot
}
from
'
koishi-adapter-onebot
'
;
const
__
=
typeof
adapter
;
// just for import
@
Injectable
()
@
Injectable
()
export
class
BotService
{
export
class
BotService
{
bot
:
App
;
botConfig
:
AppConfig
;
constructor
(
constructor
(
@
InjectConnection
(
'
app
'
)
@
InjectConnection
(
'
app
'
)
private
db
:
Connection
,
private
db
:
Connection
,
public
log
:
BotLogger
,
public
log
:
BotLogger
,
private
readonly
appService
:
AppService
,
)
{
)
{
this
.
log
.
setContext
(
'
bot
'
);
this
.
log
.
setContext
(
'
bot
'
);
this
.
initializeBot
();
}
async
initializeBot
()
{
this
.
botConfig
=
{
type
:
'
onebot:ws
'
,
selfId
:
process
.
env
.
CQ_ID
,
server
:
process
.
env
.
CQ_SERVER
,
token
:
process
.
env
.
CQ_TOKEN
,
prefix
:
process
.
env
.
CQ_PREFIX
||
'
.
'
,
};
this
.
bot
=
new
App
(
this
.
botConfig
);
this
.
bot
.
plugin
(
koishiCommonPlugin
,
{
onFriendRequest
:
true
,
});
this
.
loadBotRouters
();
await
this
.
bot
.
start
();
this
.
log
.
log
(
`Bot started.`
);
}
loadBotRouters
()
{
// all middlewares should be here.
this
.
bot
.
command
(
'
echo <msg:text>
'
).
action
((
argv
,
msg
)
=>
{
return
msg
;
});
}
}
async
findOrCreateUser
(
id
:
string
,
name
?:
string
)
{
async
findOrCreateUser
(
id
:
string
,
name
?:
string
)
{
...
@@ -53,4 +85,7 @@ export class BotService {
...
@@ -53,4 +85,7 @@ export class BotService {
}
}
return
ent
;
return
ent
;
}
}
getBot
()
{
return
(
this
.
bot
.
bots
[
0
]
as
unknown
)
as
CQBot
;
}
}
}
things/nest-typeorm/README.md
0 → 100644
View file @
423a0eb9
# App name
App description.
## Environment
*
`DB_HOST`
`DB_PORT`
`DB_USER`
`DB_PASS`
`DB_NAME`
Database configs.
## Installation
```
bash
$
npm
install
```
## Running the app
```
bash
# development
$
npm run start
# watch mode
$
npm run start:dev
# production mode
$
npm run start:prod
```
## License
AGPLv3
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