Esempio n. 1
0
        public static bool restrictChatMember(TGChat chat, TGUser who, int secondsDuration, bool canSendmessages, bool canSendMedia, bool canSendMisc, bool generateLinkPreviews)
        {
            if (secondsDuration < 30 && secondsDuration != 0)
            {
                secondsDuration = 35;  // Prevent accidental permaban.
            }

            var b = new NameValueCollection();

            b["chat_id"]                   = chat.id.ToString();
            b["user_id"]                   = who.id.ToString();
            b["until_date"]                = (Helpers.getUnixTime() + secondsDuration).ToString();
            b["can_send_messages"]         = canSendmessages.ToString();
            b["can_send_media_messages"]   = canSendMedia.ToString();
            b["can_send_other_messages"]   = canSendMisc.ToString();
            b["can_add_web_page_previews"] = generateLinkPreviews.ToString();
            TGResponse resp = apiGetRequest("restrictChatMember", b);

            if (resp.ok == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public static int getNumProfilePhotos(TGUser user)
        {
            var b = new NameValueCollection();

            b["user_id"] = user.id.ToString();

            TGResponse resp = apiGetRequest("getUserProfilePhotos", b);

            if (resp.ok == true)
            {
                var rede = resp.result.CreateReader();
                var ret  = serializer.Deserialize <TGProfilePhotos>(rede);
                rede.Close();
                return(ret.total_count);
            }
            return(-1);
        }
Esempio n. 3
0
        public static TGChatMember getChatMember(TGChat chat, TGUser user)
        {
            var b = new NameValueCollection();

            b["chat_id"] = chat.id.ToString();
            b["user_id"] = user.id.ToString();

            TGResponse resp = apiGetRequest("getChatMember", b);

            if (resp.ok == true)
            {
                var rede = resp.result.CreateReader();
                var ret  = serializer.Deserialize <TGChatMember>(rede);
                rede.Close();
                return(ret);
            }
            return(null);
        }
Esempio n. 4
0
        public static bool unbanChatMember(TGChat chat, TGUser who, int secondsDuration)
        {
            if (secondsDuration < 30 && secondsDuration != 0)
            {
                secondsDuration = 35;  // Prevent accidental permaban.
            }

            var b = new NameValueCollection();

            b["chat_id"] = chat.id.ToString();
            b["user_id"] = who.id.ToString();

            TGResponse resp = apiGetRequest("unbanChatMember", b);

            if (resp.ok == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }