SignalR
میشه این رو برای website معمولی visual studio استفاده کرد؟ یعنی غیر از وب اپلیکشن
ممنون
ASP.NET MVC #3
درود
حداقل سیستم مورد نیاز برای نصب visual studio 2010 service pack 1 چقدر میباشد ؟
چندی پیش موسسان تلگرام با معرفی APIهای کاربردی، به توسعه کنندگان اجازه دادند که با بهره گیری از بستر این شبکه، اقدام به تولید اینترفیسی به اسم بات کنند که با دریافت دستورات سفارشی، عملیات خاصی را انجام دهد.
در واقع تلگرام و متدهای ارائه شده، یک راه ارتباطی بین کاربران و برنامههای تولید شده را ایجاد کردند که با قدری ذوق و سلیقه، شاهد باتهای جالب و کاربردی هستیم.
در این مقاله سعی شده طرز تهیه یک بات با زبان #C توضیح داده شود.
در ابتدا شما باید توسط یکی از باتهای اصلی تلگرام اقدام به ثبت نام کاربری و تنظیمات بات مورد نظر خودتان نمایید. بات مورد نظر @BotFather میباشد که با شروع مکالمه میتوان با فرستادن دستورات مختلف تنظیمات مختلفی را انجام داد. با شروع مکالمه با بات مورد نظر با دستور /start دستورات زیر قابل انجام میباشد:
You can control me by sending these commands : / newbot - create a new bot / token - generate authorization token / revoke - revoke bot access token / setname - change a bot's name / setdescription - change bot description / setabouttext - change bot about info / setuserpic - change bot profile photo / setcommands - change bot commands list / setjoingroups - can your bot be added to groups ? / setprivacy - what messages does your bot see in groups ? / deletebot - delete a bot / cancel - cancel the current operation
بعد از تایید نام و یوزر نیم، به شما یک توکن اختصاص داده میشود که توسط آن شما شناسایی میشوید.
در اینجا شما میتوانید تنظیمات اضافهتری مانند عکس برای پروفایل و غیره را نیز تنظیم کنید.
در مرحلهی بعد میتوانید در همین قسمت دستورات مورد نظر را جهت بات خود تنظیم کنید. برای این کار باید دستور /setcommands را وارد کنید و دستور مورد نظر خود را به فرمت command1 – Description وارد کنید.
مرحلهی بعد، تنظیمات برنامهی شما جهت دریافت دستورات وارد شده و انجام عملیات مورد نظر و تولید و ارسال خروجی مورد نظر است.
دریافت دستورات به دو طریق انجام میشود:
1. توسط دستور getUpdates میتوان تمامی کامندهای دریافتی را از سرور تلگرام دریافت کرد و با انجام پروسسهای لازم، خروجی را به کاربر مورد نظر ارسال کرد.
2. توسط تابع webhook از تلگرام درخواست کرد در صورت دریافت دستور جدید به بات، این دستور را به یک آدرس خاص ارسال کرد.
قابل توجه است که میتوان فقط از یکی از دو روش فوق استفاده کرد. همچنین در روش دوم حتما سرور مورد نظر باید گواهی ssl تایید شده داشته باشد.
کد زیر دریافت کامندهای یک بات به روش اول میباشد :
public class mydata { public result[] result; } public class result { public int update_id { get; set; } public message message { get; set; } } public class message { public int message_id { get; set; } public message_from from { get; set; } public message_chat chat { get; set; } public int date { get; set; } public string text { get; set; } } public class message_from { public int ind { get; set; } public string first_name { get; set; } public string username { get; set; } } public class message_chat { public int id { get; set; } public string first_name { get; set; } public string username { get; set; } } public Void GetUpdates() { WebRequest req = WebRequest.Create("https://api.telegram.org/bot" + yourToken + "/getUpdates"); req.UseDefaultCredentials = true; WebResponse resp = req.GetResponse(); Stream stream = resp.GetResponseStream(); StreamReader sr = new StreamReader(stream); string s = sr.ReadToEnd(); sr.Close(); var jobject = Newtonsoft.Json.Linq.JObject.Parse(s); mydata gg = JsonConvert.DeserializeObject<mydata>(jobject.ToString()); List<result> results = new List<result>(); foreach (result rs in gg.result) { results.Add(rs); SendMessage(rs.message.chat.id.ToString(), "hello"+" "+"Dear"+rs.message.chat.first_name); } }
public static void SendMessage(string chat_id, string message) { WebRequest req = WebRequest.Create("https://api.telegram.org/bot" + youToken + "/sendMessage?chat_id=" + chat_id + "&text=" + message); req.UseDefaultCredentials = true; var result = req.GetResponse(); req.Abort(); }
لازم به ذکر است خروجی توابع باتهای تلگرام با فرمت JSON میباشد که با نصب پکیج NewTonsoft میتوان آن را به لیست تبدیل کرد.
rs.message.chat.id، آی دی فردی است که به بات تلگرامی ما مسیج ارسال کرده است.
rs.message.chat.first_name نام فردی است که به بات تلگرام مسیج ارسال کرده است.
همچنین میتوان در جواب کامند بات، علاوه بر متن، صدا و تصویر را نیز ارسال نمود .
در این لینک و این لینک میتوان توضیحات بیشتری را در این زمینه مطالعه کرد.
در انتها خوشحال میشوم ذوقها و ایدههای شما را در ساخت باتها با آیدی @iekhtiari مشاهده کنم.
گپ و گفتی با مهندسان طراح دات نت در مورد آینده این فریم ورک
Json.NET 10.0 Release 1 منتشر شد
At the Build 2016 conference, Microsoft announced the Microsoft Bot Framework, a package of tools for building intelligent bots that could be integrated with a variety of communication platforms. With Microsoft Bot Framework Succinctly, you can jump right into building your own bots with the framework, whether you want to make bots for personal use only, or customer-facing bots for your business. Author Ed Freitas provides clear guidance from setting up a bot project in Visual Studio and writing your first bare-bones bot, to publishing one capable of searching for current flight prices.
- Introduction
- Bot Framework Overview
- Our First Bot
- Publishing Our Bot
- The QPX Express API
- Airfare Alert Bot
<div id="s4-ribbonrow">
<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="AddDelPrivateWebParts">
و تگ پایانی آن :
نکته مهم در استفاده از این تگ ، ویژگی Permissions آن است که باید با دقت و بسته به نیاز شما تعریف شود :
برخی از این موارد عبارتند از :
EmptyMask – Has no permissions on the Web site. Not available through the user interface.
ViewListItems – View items in lists, documents in document libraries, and view Web discussion comments.
AddListItems – Add items to lists, add documents to document libraries, and add Web discussion comments.
EditListItems – Edit items in lists, edit documents in document libraries, edit Web discussion comments in documents, and customize Web Part Pages in document libraries.
DeleteListItems – Delete items from a list, documents from a document library, and Web discussion comments in documents.
ApproveItems – Approve a minor version of a list item or document.
OpenItems – View the source of documents with server-side file handlers.
ViewVersions – View past versions of a list item or document.
DeleteVersions – Delete past versions of a list item or document.
CancelCheckout – Discard or check in a document which is checked out to another user.
ManagePersonalViews – Create, change, and delete personal views of lists.
ManageLists – Create and delete lists, add or remove columns in a list, and add or remove public views of a list.
ViewFormPages – View forms, views, and application pages, and enumerate lists.
Open – Allow users to open a Web site, list, or folder to access items inside that container.
ViewPages – View pages in a Web site.
AddAndCustomizePages – Add, change, or delete HTML pages or Web Part Pages, and edit the Web site using a SharePoint Foundation–compatible editor.
ApplyThemeAndBorder – Apply a theme or borders to the entire Web site.
ApplyStyleSheets – Apply a style sheet (.css file) to the Web site.
ViewUsageData – View reports on Web site usage.
CreateSSCSite – Create a Web site using Self-Service Site Creation.
ManageSubwebs – Create subsites such as team sites, Meeting Workspace sites, and Document Workspace sites.
CreateGroups – Create a group of users that can be used anywhere within the site collection.
ManagePermissions – Create and change permission levels on the Web site and assign permissions to users and groups.
BrowseDirectories – Enumerate files and folders in a Web site using Microsoft Office SharePoint Designer 2007 and WebDAV interfaces.
BrowseUserInfo – View information about users of the Web site.
AddDelPrivateWebParts – Add or remove personal Web Parts on a Web Part Page.
UpdatePersonalWebParts – Update Web Parts to display personalized information.
ManageWeb – Grant the ability to perform all administration tasks for the Web site as well as manage content. Activate, deactivate, or edit properties of Web site scoped Features through the object model or through the user interface (UI). When granted on the root Web site of a site collection, activate, deactivate, or edit properties of site collection scoped Features through the object model. To browse to the Site Collection Features page and activate or deactivate site collection scoped Features through the UI, you must be a site collection administrator.
UseClientIntegration – Use features that launch client applications; otherwise, users must work on documents locally and upload changes.
UseRemoteAPIs – Use SOAP, WebDAV, or Microsoft Office SharePoint Designer 2007 interfaces to access the Web site.
ManageAlerts – Manage alerts for all users of the Web site.
CreateAlerts – Create e-mail alerts.
EditMyUserInfo – Allows a user to change his or her user information, such as adding a picture.
EnumeratePermissions – Enumerate permissions on the Web site, list, folder, document, or list item.
FullMask – Has all permissions on the Web site. Not available through the user interface.
حال خارج از تگهای SPSecurityTrimmedControl در ابتدا یا انتها ، باید تگ login را مانند زیر به آن اضافه کرد .
و تمام :