Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
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
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Иван Кубота
  • tg-simple-bot
  • Repository

Switch branch/tag
  • tg-simple-bot
  • Model
  • Message.js
Find file
BlameHistoryPermalink
  • Иван Кубота's avatar
    Implemented Abstractions: · c2fe7f37
    Иван Кубота authored Aug 09, 2019
      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 readd 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)
            }),
    '''
    c2fe7f37
Message.js 1.38 KB
EditWeb IDE
×

Replace Message.js

Attach a file by drag & drop or click to upload


Cancel
A new branch will be created in your fork and a new merge request will be started.