//func get uid or chat id func GetUid() (string, string) { p := make(map[string]string) p["count"] = "1" p["out"] = "0" m := api.Request("messages.get", p) //uid uid_regexp, _ := regexp.Compile("\"uid\":([0-9]+),\"read") uid := uid_regexp.FindStringSubmatch(m)[1] //uid //chat_id title := vkapi.GetResponse(m, "title") if title != " ... " { chat_id_regexp, _ := regexp.Compile("\"chat_id\":([0-9]+)") chat_id := chat_id_regexp.FindStringSubmatch(m)[1] return "chat_id", chat_id } else { return "user_id", uid } }
func main() { api.AccessToken = "token_here" prefixes := []string{"Afina ", "Афина ", "бот ", "Afina, ", "Афина, ", "бот, ", "!", "0", ""} p := make(map[string]string) p["count"] = "1" p["out"] = "0" last_msg := 0 is_pause := 0 for { m := api.Request("messages.get", p) body := "no" if len((vkapi.GetResponse(m, "body").(string))) != 0 { body = (vkapi.GetResponse(m, "body").(string)) } mid := int((vkapi.GetResponse(m, "mid")).(float64)) help_message := `=== Бот Афина === Доступные комманды: ` + "➡" + `Афина, помощь ` + "➡" + `Афина, привет ` + "➡" + `Афина, мику ` + "➡" + `Афина, 2Dняшку ` + "➡" + `Афина, 3Dняшку ` + "➡" + `Афина, мегумин ` + "➡" + `Афина, широ ` + "➡" + `Афина, создатель ` + "➡" + `Афина, кто ` + "➡" + `kappa, каппа, карра, KAPPA ` + "➡" + `0/, Hitler hitler ` + "➡" + `!сучкалинуса; !вайфулинуса Author: Meryborn(https://vk.com/meryborn), 2016` if mid > last_msg && body != "no" { if is_pause == 0 { for _, e := range prefixes { switch body { // //Commands // case e + "help", e + "помощь", e + "старт": send(help_message, "photo232317814_403576726") case e + "hi", e + "hello": send("Здравствуй, Семпай", "photo232317814_403576725") case e + "создатель": send("Meryborn(https://vk.com/meryborn)", "photo232317814_403576721") case e + "3Dняшку": random_photo("https://vk.com/album232317814_232070447", "Лови 3D няшку") case e + "2Dняшку", e + "няшку": random_photo("https://vk.com/album232317814_231917660", "Лови 2D няшку") case e + "мику", e + "хатсуне", e + "хатсуне мику": random_photo("https://vk.com/album232317814_231918384", "Лови Хатсуне Мику") case e + "мегумин", e + "megumin": random_photo("https://vk.com/album-54385020_174984625", "Лови Мегумин") case e + "shiro", e + "широ", e + "waifu", e + "вайфу": random_photo("vk.com/album232317814_229487221", "Лови Широ") case e + "Hitler", e + "hitler", e + "/": random_photo("vk.com/album232317814_232435013", "1488") case e + "kappa", e + "каппа", e + "карра", e + "KAPPA", e + "Kappa": random_photo("vk.com/album230766065_223378577", "SUPERKAPPA") case e + "вайфулинуса", e + "сучкалинуса", e + "СучкаЛинуса": random_photo("vk.com/album-90206250_213182965", "сучка подана, ссаный линус") case e + "кто": send("Рандомный юзер "+getRandUser(), "") // //Commands // } last_msg = mid } } } time.Sleep(1000 * time.Millisecond) } }