support markdown and html format.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
		
							
								
								
									
										7
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								main.go
									
									
									
									
									
								
							@@ -37,6 +37,12 @@ func main() {
 | 
				
			|||||||
			Usage:  "enable debug message",
 | 
								Usage:  "enable debug message",
 | 
				
			||||||
			EnvVar: "PLUGIN_DEBUG",
 | 
								EnvVar: "PLUGIN_DEBUG",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							cli.StringFlag{
 | 
				
			||||||
 | 
								Name:   "format",
 | 
				
			||||||
 | 
								Value:  "markdown",
 | 
				
			||||||
 | 
								Usage:  "telegram message format",
 | 
				
			||||||
 | 
								EnvVar: "PLUGIN_FORMAT",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		cli.StringFlag{
 | 
							cli.StringFlag{
 | 
				
			||||||
			Name:   "repo.owner",
 | 
								Name:   "repo.owner",
 | 
				
			||||||
			Usage:  "repository owner",
 | 
								Usage:  "repository owner",
 | 
				
			||||||
@@ -115,6 +121,7 @@ func run(c *cli.Context) error {
 | 
				
			|||||||
			Debug:   c.Bool("debug"),
 | 
								Debug:   c.Bool("debug"),
 | 
				
			||||||
			To:      c.StringSlice("to"),
 | 
								To:      c.StringSlice("to"),
 | 
				
			||||||
			Message: c.StringSlice("message"),
 | 
								Message: c.StringSlice("message"),
 | 
				
			||||||
 | 
								Format:  c.String("format"),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,6 +35,7 @@ type (
 | 
				
			|||||||
		Debug   bool
 | 
							Debug   bool
 | 
				
			||||||
		To      []string
 | 
							To      []string
 | 
				
			||||||
		Message []string
 | 
							Message []string
 | 
				
			||||||
 | 
							Format  string
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Plugin values.
 | 
						// Plugin values.
 | 
				
			||||||
@@ -107,8 +108,9 @@ func (p Plugin) Exec() error {
 | 
				
			|||||||
	// send message.
 | 
						// send message.
 | 
				
			||||||
	for _, user := range ids {
 | 
						for _, user := range ids {
 | 
				
			||||||
		for _, value := range trimElement(message) {
 | 
							for _, value := range trimElement(message) {
 | 
				
			||||||
 | 
								log.Println(user)
 | 
				
			||||||
			msg := tgbotapi.NewMessage(user, value)
 | 
								msg := tgbotapi.NewMessage(user, value)
 | 
				
			||||||
			msg.ParseMode = "markdown"
 | 
								msg.ParseMode = p.Config.Format
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			_, err := bot.Send(msg)
 | 
								_, err := bot.Send(msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user