mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 18:46:44 +01:00
Less cancerous gender command
This commit is contained in:
parent
7030d6d595
commit
1edf6ef81a
@ -2,7 +2,7 @@
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 14:55:33
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 15:10:37
|
||||
* @Last Modified time: 2018-07-24 17:26:57
|
||||
*/
|
||||
|
||||
package commands
|
||||
@ -14,8 +14,12 @@ import (
|
||||
)
|
||||
|
||||
func SetGender(m *tb.Message) {
|
||||
split := strings.Split(m.Text, " ")
|
||||
data := strings.Join(split[1:], " ")
|
||||
split := cleanGender(strings.Split(m.Text, " ")[1:])
|
||||
if len(split) == 0 {
|
||||
shared.Bot.Send(m.Chat, "Désolé, mais je n'ai pas compris.")
|
||||
return
|
||||
}
|
||||
data := strings.Join(split, " ")
|
||||
shared.Users.Set(m.Sender.ID, "gender", data)
|
||||
shared.Bot.Send(m.Chat, "Votre genre est enregistré, je vous considère maintenant comme « "+data+" ».")
|
||||
}
|
||||
@ -28,3 +32,14 @@ func Gender(m *tb.Message) {
|
||||
shared.Bot.Send(m.Chat, data)
|
||||
}
|
||||
}
|
||||
|
||||
func cleanGender(slice []string) []string {
|
||||
for i, value := range slice {
|
||||
if strings.HasPrefix(value, "@") {
|
||||
slice[i] = strings.Replace(value, "@", "@ ", 1)
|
||||
} else if strings.HasPrefix(value, "/") {
|
||||
slice[i] = strings.Replace(value, "/", "/ ", 1)
|
||||
}
|
||||
}
|
||||
return slice
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user