forked from git.klmp200.net/ALFRED
Merge branch 'features' of ALFRED/ALFRED into master
This commit is contained in:
commit
62188a005d
@ -2,7 +2,7 @@
|
|||||||
* @Author: Bartuccio Antoine
|
* @Author: Bartuccio Antoine
|
||||||
* @Date: 2018-07-24 14:55:33
|
* @Date: 2018-07-24 14:55:33
|
||||||
* @Last Modified by: klmp200
|
* @Last Modified by: klmp200
|
||||||
* @Last Modified time: 2018-07-24 15:10:37
|
* @Last Modified time: 2018-07-24 17:26:57
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package commands
|
package commands
|
||||||
@ -14,8 +14,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func SetGender(m *tb.Message) {
|
func SetGender(m *tb.Message) {
|
||||||
split := strings.Split(m.Text, " ")
|
split := cleanGender(strings.Split(m.Text, " ")[1:])
|
||||||
data := strings.Join(split[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.Users.Set(m.Sender.ID, "gender", data)
|
||||||
shared.Bot.Send(m.Chat, "Votre genre est enregistré, je vous considère maintenant comme « "+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)
|
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