Ejemplo n.º 1
0
        public bool Authorization(ulong appId, string login, string pass)
        {
            this.appId = appId;
            this.login = login;
            this.pass  = pass;
            VkApi vkAcc = new VkApi();

            try
            {
                vkAcc.Authorize(new ApiAuthParams
                {
                    ApplicationId = appId,
                    Login         = login,
                    Password      = pass,
                    Settings      = Settings.All
                });
            }
            catch
            {
                return(false);
            }

            vkMessages = new VkMessages(vkAcc);
            vkBot      = new VkBot(vkAcc, vkMessages);
            return(true);
        }
Ejemplo n.º 2
0
        public bool Authorization()
        {
            VkApi vkAcc = new VkApi();

            try
            {
                DataBaseCenter dataBase  = DataBaseCenter.Create();
                DataTable      dataTable = dataBase.GetDataTable("SELECT значение FROM Настройки WHERE название='vk'");
                if (dataTable.Rows.Count == 0)
                {
                    return(false);
                }
                string[] str = dataTable.Rows[0].ItemArray[0].ToString().Split("|".ToCharArray());
                ulong.TryParse(str[0], out appId);
                login = str[1];
                pass  = str[2];
                vkAcc.Authorize(new ApiAuthParams
                {
                    ApplicationId = appId,
                    Login         = login,
                    Password      = pass,
                    AccessToken   = str[3],
                    Settings      = Settings.All
                });
            }
            catch
            {
                return(false);
            }

            vkMessages = new VkMessages(vkAcc);
            vkBot      = new VkBot(vkAcc, vkMessages);
            return(true);
        }
Ejemplo n.º 3
0
 public VkBot(VkApi vkAcc, VkMessages vkMessages)
 {
     this.vkAcc      = vkAcc;
     this.vkMessages = vkMessages;
 }