Exemple #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);
            }
        }
Exemple #2
0
        public static TGMessage sendMessage(TGChat chat, string message)
        {
            Console.WriteLine("SENDING MESSAGE");
            var b = new NameValueCollection();

            b["chat_id"] = chat.id.ToString();
            b["text"]    = message;

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

            if (resp.ok == true)
            {
                return(serializer.Deserialize <TGMessage>(resp.result.CreateReader()));
            }

            return(null);
        }
Exemple #3
0
        public static bool deleteMessage(TGChat chat, TGMessage message)
        {
            Console.WriteLine("DELETE MSG 2");
            var b = new NameValueCollection();

            b["chat_id"]    = chat.id.ToString();
            b["message_id"] = message.message_id.ToString();

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

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

            return(false);
        }
Exemple #4
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);
        }
Exemple #5
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);
            }
        }