github.com/sharovik/devbot@v1.0.1-0.20240308094637-4a0387c40516/events/eventslist/insert-help-message.go (about)

     1  package eventslist
     2  
     3  import (
     4  	"github.com/sharovik/devbot/internal/container"
     5  )
     6  
     7  // InsertHelpMessageMigration the migration name
     8  type InsertHelpMessageMigration struct {
     9  }
    10  
    11  // GetName the name in the database
    12  func (m InsertHelpMessageMigration) GetName() string {
    13  	return "help-message-introducing.sql" //I leave this name to be backwards compatible with the old version of migrations flow
    14  }
    15  
    16  // Execute the body of the migration
    17  func (m InsertHelpMessageMigration) Execute() error {
    18  	eventID, err := container.C.Dictionary.FindEventByAlias(EventName)
    19  	if err != nil {
    20  		return err
    21  	}
    22  
    23  	scenarioID, err := container.C.Dictionary.InsertScenario("Scenario help", eventID)
    24  	if err != nil {
    25  		return err
    26  	}
    27  
    28  	_, err = container.C.Dictionary.InsertQuestion("Help", "If you want to see the list of my functions, please try ask me the following question `events list`. This will printout all possible phrases what currently I can understand.", scenarioID, "(?i)^(help)$", "", false)
    29  	if err != nil {
    30  		return err
    31  	}
    32  
    33  	return nil
    34  }