Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tg-simple-bot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
tg-simple-bot
Commits
741439b9
Commit
741439b9
authored
Aug 09, 2019
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add readme
parent
c2fe7f37
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
README.md
README.md
+59
-0
No files found.
README.md
0 → 100644
View file @
741439b9
Implemented Abstractions:
### Chat
##### props
`id<int>`
### User
##### props
`id<int>`
`chat<Chat>`
`isAdmin<bool>`
— return true if user is admin of the group
##### methods
`send(text: string, [Choose])`
— send PM to user. Really it is not useful due to bot can not initiate chat with user
`ban(duration: string)`
— ban user in group
`unban()`
— unban user. this would not read user to the group (bot api does not support this action)
`capture(Event[]): <CaptureStop>`
— capture all next users messages in the messages group and begin to match them only against specified
`Event list`
### Message
##### props
`raw`
— original data from API
`raw.message_id<int>`
`user<User>`
`chat<Chat>`
`from<Message>`
— if message is a reply — it would contains previous message. TODO: rename it
##### methods
`send(text: string)`
— send new message to the messages channel
`reply(text: string)`
— send reply to the message
`remove()`
— remove message from channel
### Choose
> abstraction for generating custom in-chat-buttons
TODO: refactor code to standalone module.
Example of rules:
```
js
// Admin can ban user by replying to his\her massage with `\ban`. Works only if user is not admin.
Reply
(
'/ban'
)
.
then
(
async
function
(
message
){
if
(
(
await
message
.
user
.
isAdmin
())
&&
!
(
await
message
.
from
.
user
.
isAdmin
())){
message
.
from
.
reply
(
L
(
'ban'
,
{...
message
.
from
.
user
}));
message
.
from
.
user
.
ban
();
}
})
Answer
(
'/say {{$kokoko}}'
)
.
then
((
message
,
match
)
=>
{
message
.
send
(
match
.
kokoko
)
})
```
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