Exemplo n.º 1
0
        public static void InviteBot(Messages command = null)
        {
            int botClass = Convert.ToInt32(command.Args);

            if (command == null)
            {
                command = Messages.Current;
            }
            List <Bots> BotClass = Bots.GetClassList(botClass);

            if (botClass == 1)
            {
                if (command.GroupId.BotsCatalog[botClass] == -1)
                {
                    int botNum = new Random().Next(0, BotClass.Count);
                    Console.WriteLine(botNum);
                    command.GroupId.BotsCatalog[botClass] = BotClass[botNum].Id;
                    int chat_id = command.PeerId;
                    if (chat_id > 2000000000)
                    {
                        chat_id -= 2000000000;
                    }
                    //string res = new HttpRequest(Program.Api).Post("messages.addChatUser?chat_id=" + chat_id + "&user_id=" + BotClass[botNum].Id + "&" + Bots.List[0].Token + Program.ApiVer).ToString();
                    BotClass[botNum].GroupsCount++;
                    BotClass[botNum].groupAssocs.Add(new GroupAssoc {
                        Id = command.GroupId.Id, Peer = 2000000000 + BotClass[botNum].GroupsCount
                    });
                    Bots.SaveBot(BotClass[botNum]);
                    Groups.SaveGroup(command.GroupId);
                    //Functions.SendReply("Я откликнулся на твой зов!", GroupAssoc.GetAssoc(command.GroupId.Id, BotClass[botNum]).Peer, BotClass[botNum].Token);
                }
            }
        }
Exemplo n.º 2
0
 public static void ReWriteAssoc(int group, int peer, Bots bot)
 {
     foreach (GroupAssoc groupAssoc in bot.groupAssocs)
     {
         if (groupAssoc.Id == group)
         {
             groupAssoc.Peer = peer;
             Bots.SaveBot(bot);
             return;
         }
     }
     bot.groupAssocs.Add(new GroupAssoc {
         Id = group, Peer = peer
     });
     Bots.SaveBot(bot);
     return;
 }