github.com/Azareal/Gosora@v0.0.0-20210729070923-553e66b59003/extend/plugin_heythere.go (about)

     1  package extend
     2  
     3  import c "github.com/Azareal/Gosora/common"
     4  
     5  func init() {
     6  	c.Plugins.Add(&c.Plugin{UName: "heythere", Name: "Hey There", Author: "Azareal", URL: "https://github.com/Azareal", Init: initHeythere, Deactivate: deactivateHeythere})
     7  }
     8  
     9  // initHeythere is separate from init() as we don't want the plugin to run if the plugin is disabled
    10  func initHeythere(plugin *c.Plugin) error {
    11  	plugin.AddHook("topic_reply_row_assign", heythereReply)
    12  	return nil
    13  }
    14  
    15  func deactivateHeythere(plugin *c.Plugin) {
    16  	plugin.RemoveHook("topic_reply_row_assign", heythereReply)
    17  }
    18  
    19  func heythereReply(data ...interface{}) interface{} {
    20  	currentUser := data[0].(*c.TopicPage).Header.CurrentUser
    21  	reply := data[1].(*c.ReplyUser)
    22  	reply.Content = "Hey there, " + currentUser.Name + "!"
    23  	reply.ContentHtml = "Hey there, " + currentUser.Name + "!"
    24  	reply.Tag = "Auto"
    25  	return nil
    26  }