This object represents a Telegram user or bot.
Inheritance: IConversationSource
        private static void db_AddOpenWebId(UserInfo User, string openwebid, string openwebname = null)
        {
            var userId = User.Id.ToString ();
            openwebid = openwebid.ToUpper ();
            if (openwebname == null) {

            } else {
                var openwebSec = IniFile.Sections ["OPENWEBS"];
                openwebSec.Keys.Add (openwebid, openwebname);
            }

            if (IniFile.Sections.Contains (userId)) {
                var user = IniFile.Sections [userId];
                var owps = user.Keys ["OpenWebIds"].Value;
                if(!owps.Contains (openwebid))
                    owps = owps != "" ? owps + "," + openwebid : openwebid;
                user.Keys ["OpenWebIds"].Value = owps;
            } else {
                var user = IniFile.Sections.Add (userId);
                user.Keys.Add ("OpenWebIds", openwebid);
                user.Keys.Add ("FirstName", User.FirstName);
                user.Keys.Add ("LastName", User.LastName);
            }
            IniFile.Save (IniFilePath);
        }
 private static IEnumerable<OPENwebEntity> db_ListOpenWebs(UserInfo User)
 {
     if (!IniFile.Sections.Contains (User.Id.ToString ())) {
         return null;
     }
     var userOpenWeb = IniFile.Sections [User.Id.ToString ()].Keys ["OpenWebIds"].Value;
     var userOpenWebs = userOpenWeb.Split (",".ToCharArray (), StringSplitOptions.RemoveEmptyEntries);
     var list = new List<OPENwebEntity> ();
     foreach (var owp in userOpenWebs) {
         var name = IniFile.Sections ["OPENWEBS"].Keys [owp].Value;
         list.Add (new OPENwebEntity() {UUID = owp, Name = name});
     }
     return list;
 }
Esempio n. 3
0
 private void Parse(JObject jsonObject)
 {
     MessageId = jsonObject["message_id"].Value<int>();
     From = new UserInfo(jsonObject["from"].Value<JObject>());
     DateUnix = jsonObject["date"].Value<int>();
     Date = DateUnix.ToDateTime();
     Chat = ParseChat(jsonObject["chat"].Value<JObject>());
     if (jsonObject["forward_from"] != null)
         ForwardFrom = new UserInfo(jsonObject["forward_from"].Value<JObject>());
     if(jsonObject["forward_date"]!=null)
     {
         ForwardDateUnix = jsonObject["forward_date"].Value<int>();
         ForwardDate = ForwardDateUnix.ToDateTime();
     }
     if(jsonObject["reply_to_message"]!=null)
     {
         ReplyToMessage = new MessageInfo(jsonObject["reply_to_message"].Value<JObject>());
     }
     if (jsonObject["text"] != null)
         Text = jsonObject["text"].Value<string>();
     if (jsonObject["audio"] != null)
         Audio = new AudioInfo(jsonObject["audio"].Value<JObject>());
     if (jsonObject["document"] != null)
         Document = new DocumentInfo(jsonObject["document"].Value<JObject>());
     if (jsonObject["photo"] != null)
         Photo = PhotoSizeInfo.ParseArray(jsonObject["photo"].Value<JArray>());
     if (jsonObject["sticker"] != null)
         Sticker = new StickerInfo(jsonObject["sticker"].Value<JObject>());
     if (jsonObject["video"] != null)
         Video = new VideoInfo(jsonObject["video"].Value<JObject>());
     if (jsonObject["contact"] != null)
         Contact = new ContactInfo(jsonObject["contact"].Value<JObject>());
     if (jsonObject["location"] != null)
         Location = new LocationInfo(jsonObject["location"].Value<JObject>());
     if (jsonObject["new_chat_participant"] != null)
         NewChatParticipant = new UserInfo(jsonObject["new_chat_participant"].Value<JObject>());
     if (jsonObject["left_chat_participant"] != null)
         LeftChatParticipant = new UserInfo(jsonObject["left_chat_participant"].Value<JObject>());
     if (jsonObject["new_chat_title"] != null)
         NewChatTitle = jsonObject["new_chat_title"].Value<string>();
     if (jsonObject["new_chat_photo"] != null)
         NewChatPhoto = PhotoSizeInfo.ParseArray(jsonObject["new_chat_photo"].Value<JArray>());
     if (jsonObject["delete_chat_photo"] != null)
         DeleteChatPhoto = true;
     if (jsonObject["group_chat_created"] != null)
         GroupChatCreated = true;
 }