Пример #1
0
        public async Task <ActionResult> Index(string Msg, HttpPostedFileBase attach)
        {
            string      attachFiledID = string.Empty;
            List <User> Users         = db.Users.ToList();

            foreach (User u in Users)
            {
                try {
                    await TbotController.SendMessageAsync(u.ChatID_bint, Msg.Replace("[نام]", u.Name_nvc));

                    if (attach != null)
                    {
                        byte[] file;
                        using (MemoryStream ms = new MemoryStream())
                        {
                            attach.InputStream.CopyTo(ms);
                            file = ms.ToArray();
                        }
                        if (string.IsNullOrEmpty(attachFiledID))
                        {
                            T.Message m = await TbotController.SendDocumentAsync(u.ChatID_bint, "", file, attach.FileName);

                            attachFiledID = m.Document.FileId;
                        }
                        else
                        {
                            await TbotController.SendDocumentAsync(u.ChatID_bint, "", attachFiledID);
                        }
                    }
                }
                catch { }
            }
            ViewBag.Message = "پیام ها ارسال شدند";
            return(View());
        }
Пример #2
0
        public async Task <ActionResult> Index()
        {
            if (IsLogin)
            {
                return(RedirectToAction("Index", new { controller = "Prices", Area = "Bot" }));
            }

            ViewBag.Title = "ورود";
            if (Session["Code"] == null)
            {
                string Code = Functions.GenerateName(5, Functions.GenerateType.Num);;
                Session["Code"] = Code;
                await TbotController.SendMessageAsync(Admin, "Panel Login Code is : " + Code);
            }
            return(View());
        }
Пример #3
0
        private async Task brodcast(byte[] File_vb, string Text)
        {
            List <User> users = db.Users.ToList();

            foreach (User u in users)
            {
                if (File_vb != null)
                {
                    try
                    {
                        await TbotController.SendPhotoAsync(u.ChatID_bint, Text, File_vb);
                    }
                    catch { }
                }
                else
                {
                    try {
                        await TbotController.SendMessageAsync(u.ChatID_bint, Text);
                    }
                    catch { }
                }
            }
        }