Beispiel #1
0
        public bool UnbanUser(
            int AdminID,
            int UserID,
            string Reason     = null,
            UserInfo userinfo = null
            )
        {
            int ChannelReasonID = 0;

            if (Temp.MainChannelID != 0)
            {
                string banmsg = "";
                if (userinfo == null)
                {
                    UserInfoRequest userinforeq = TgApi.getDefaultApiConnection().getChat(UserID);
                    if (userinforeq.ok)
                    {
                        userinfo = userinforeq.result;
                        banmsg   = userinfo.GetUserTextInfo();
                    }
                    else
                    {
                        banmsg = "User ID : " + UserID;
                    }
                }
                else
                {
                    banmsg = userinfo.GetUserTextInfo();
                }

                banmsg += "\n\n已被解除封鎖";

                if (Reason != null)
                {
                    banmsg += ",原因 : \n" + Reason;
                }

                banmsg += "\n原封鎖原因 : \n" + Temp.GetDatabaseManager().GetUserBanStatus(UserID).Reason + "\n";

                banmsg += "\nOID : " + AdminID + "\n";

                BanUser ban = Temp.GetDatabaseManager().GetUserBanStatus(UserID);
                if (ban.Ban == 1)
                {
                    return(false);
                }

                ChannelReasonID = TgApi.getDefaultApiConnection().sendMessage(Temp.MainChannelID, banmsg).result
                                  .message_id;
            }

            ChangeDbUnban(AdminID, UserID, Reason, ChannelReasonID);
            CNBlacklistApi.PostToAPI(UserID, false, 1, 0, Reason);
            return(true);
        }
        public bool UnbanUser(
            int AdminID,
            int UserID,
            string Reason     = null,
            UserInfo userinfo = null
            )
        {
            bool finalResult     = true;
            int  ChannelReasonID = 0;

            if (Temp.MainChannelID != 0)
            {
                string banmsg = "";
                if (userinfo == null)
                {
                    UserInfoRequest userinforeq = TgApi.getDefaultApiConnection().getChat(UserID);
                    if (userinforeq.ok)
                    {
                        userinfo = userinforeq.result;
                        banmsg   = userinfo.GetUserTextInfo();
                    }
                    else
                    {
                        finalResult = false;
                        banmsg      = "User ID: " + UserID;
                    }
                }
                else
                {
                    banmsg = userinfo.GetUserTextInfo();
                }
                banmsg += "\n\n已被解封";
                if (Reason != null)
                {
                    banmsg += ",原因是:\n" + Reason;
                }
                ChannelReasonID = TgApi.getDefaultApiConnection().sendMessage(
                    Temp.MainChannelID,
                    banmsg
                    ).result.message_id;
            }
            ChangeDbUnban(AdminID, UserID, Reason, ChannelReasonID);
            CNBlacklistApi.PostToAPI(UserID, false, 1, 0, Reason);
            return(finalResult);
        }
Beispiel #3
0
        public bool BanUser(
            int AdminID,
            int UserID,
            int Level,
            long Expires,
            string Reason,
            long ChatID       = 0,
            int MessageID     = 0,
            UserInfo userinfo = null
            )
        {
            if (RAPI.getIsInWhitelist(UserID))
            {
                return(false);
            }
            bool              finalResult = true;
            string            banmsg      = "";
            SendMessageResult result      = null;
            int ReasonID        = 0;
            int ChannelReasonID = 0;

            if (Temp.ReasonChannelID != 0 && ChatID != 0 && MessageID != 0)
            {
                ReasonID = TgApi.getDefaultApiConnection().forwardMessage(Temp.ReasonChannelID, ChatID, MessageID)
                           .result.message_id;
            }
            if (Temp.MainChannelID != 0)
            {
                if (userinfo == null)
                {
                    UserInfoRequest userinforeq = TgApi.getDefaultApiConnection().getChat(UserID);
                    if (userinforeq.ok)
                    {
                        userinfo = userinforeq.result;
                        banmsg   = userinfo.GetUserTextInfo();
                    }
                    else
                    {
                        finalResult = false;
                        banmsg      = "User ID : " + UserID;
                    }
                }
                else
                {
                    banmsg = userinfo.GetUserTextInfo();
                }

                string textlevel;
                if (Level == 0)
                {
                    textlevel = "封鎖";
                }
                else if (Level == 1)
                {
                    textlevel = "警告";
                }
                else
                {
                    textlevel = Level + " (未知)";
                }
                banmsg += "\n處分 : " + textlevel;
                string ExpTime = GetTime.GetExpiresTime(Expires);
                if (ExpTime != "永久封鎖")
                {
                    banmsg += "\n時效至 : " + GetTime.GetExpiresTime(Expires);
                }
                else
                {
                    banmsg += "\n時效 : 永久";
                }
                banmsg += "\n原因 : " + Reason;
                if (AdminID == 0)
                {
                    banmsg += "\nOID : Bot\n";
                }
                else if (AdminID == 1 || ChatID == Temp.InternGroupID)
                {
                    banmsg += "\nOID : Auditors\n";
                }
                else
                {
                    banmsg += "\nOID : " + AdminID + "\n";
                }
                if (Temp.ReasonChannelID != 0 && ReasonID != 0 && Temp.ReasonChannelName != null)
                {
                    banmsg += "\n參考 : \nhttps://t.me/" + Temp.ReasonChannelName + "/" + ReasonID;
                }
                else if (Temp.ReasonChannelID != 0 && ChatID != 0 && MessageID != 0)
                {
                    finalResult = false;
                }
                banmsg += "\n";
                try
                {
                    if (ChatID != Temp.InternGroupID)
                    {
                        banmsg += "\n" + TgApi.getDefaultApiConnection().getChatInfo(ChatID).result.GetChatTextInfo();
                    }
                }
                catch
                {
                }

                ChannelReasonID = TgApi.getDefaultApiConnection().sendMessage(Temp.MainChannelID, banmsg).result
                                  .message_id;
            }

            ChangeDbBan(AdminID, UserID, Level, Expires, Reason, ChannelReasonID, ReasonID);
            CNBlacklistApi.PostToAPI(UserID, true, Level, Expires, Reason);
            return(finalResult);
        }
        public bool BanUser(
            int AdminID,
            int UserID,
            int Level,
            long Expires,
            string Reason,
            long ChatID       = 0,
            int MessageID     = 0,
            UserInfo userinfo = null
            )
        {
            bool              finalResult = true;
            string            banmsg      = "";
            SendMessageResult result      = null;
            int ReasonID = 0;

            if (Temp.ReasonChannelID != 0 && ChatID != 0 && MessageID != 0)
            {
                result = TgApi.getDefaultApiConnection().forwardMessage(Temp.ReasonChannelID, ChatID, MessageID);
                if (result.ok)
                {
                    ReasonID = result.result.message_id;
                    result   = null;
                }
            }
            int ChannelReasonID = 0;

            if (Temp.MainChannelID != 0)
            {
                if (userinfo == null)
                {
                    UserInfoRequest userinforeq = TgApi.getDefaultApiConnection().getChat(UserID);
                    if (userinforeq.ok)
                    {
                        userinfo = userinforeq.result;
                        banmsg   = userinfo.GetUserTextInfo();
                    }
                    else
                    {
                        finalResult = false;
                        banmsg      = "User ID: " + UserID;
                    }
                }
                else
                {
                    banmsg = userinfo.GetUserTextInfo();
                }
                string textlevel;
                if (Level == 0)
                {
                    textlevel = "0 (严重)";
                }
                else if (Level == 1)
                {
                    textlevel = "1 (警告)";
                }
                else
                {
                    textlevel = Level + " (未知)";
                }
                banmsg += "\n\n已被封禁,封禁等级为: " + textlevel + ",该记录将于 " + GetTime.GetExpiresTime(Expires) + " 之后失效";
                banmsg += "\n\n原因是:\n" + Reason;
                if (Temp.ReasonChannelID != 0 && ReasonID != 0)
                {
                    banmsg += "\n\n参见:\nhttps://t.me/" + Temp.ReasonChannelName + "/" + ReasonID;
                }
                else if (Temp.ReasonChannelID != 0 && ChatID != 0 && MessageID != 0)
                {
                    finalResult = false;
                }
                ChannelReasonID = TgApi.getDefaultApiConnection().sendMessage(Temp.MainChannelID, banmsg).result.message_id;
                ChangeDbBan(AdminID, UserID, Level, Expires, Reason, ChannelReasonID, ReasonID);
            }
            CNBlacklistApi.PostToAPI(UserID, true, Level, Expires, Reason);
            return(finalResult);
        }
        public bool BanUser(
            int AdminID,
            int UserID,
            int Level,
            long Expires,
            string Reason,
            long ChatID       = 0,
            int MessageID     = 0,
            UserInfo userinfo = null
            )
        {
            if (Config.GetIsInWhiteList(UserID))
            {
                return(false);
            }
            bool   finalResult     = true;
            string banmsg          = "";
            int    ReasonID        = 0;
            int    ChannelReasonID = 0;

            if (Config.ReasonChannelID != 0 && ChatID != 0 && MessageID != 0)
            {
                ReasonID = TgApi.getDefaultApiConnection().forwardMessage(Config.ReasonChannelID, ChatID, MessageID)
                           .result.message_id;
            }
            if (Config.MainChannelID != 0)
            {
                if (userinfo == null)
                {
                    UserInfoRequest userinforeq = TgApi.getDefaultApiConnection().getChat(UserID);
                    if (userinforeq.ok)
                    {
                        userinfo = userinforeq.result;
                        banmsg   = userinfo.GetUserTextInfoMarkdown();
                    }
                    else
                    {
                        finalResult = false;
                        banmsg      = "User ID : `" + UserID + "`";
                    }
                }
                else
                {
                    banmsg = userinfo.GetUserTextInfoMarkdown();
                }

                string textlevel;
                if (Level == 0)
                {
                    textlevel = "封鎖";
                }
                else if (Level == 1)
                {
                    textlevel = "警告";
                }
                else
                {
                    textlevel = Level + " (未知)";
                }
                banmsg += "\n處分 : " + textlevel;
                string ExpTime = GetTime.GetExpiresTime(Expires);
                if (ExpTime != "永久封鎖")
                {
                    banmsg += "\n時效至 : `" + GetTime.GetExpiresTime(Expires) + "`";
                }
                else
                {
                    banmsg += "\n時效 : `永久`";
                }
                if (Reason.Substring(0, 1) == "`")
                {
                    banmsg += "\n原因 : " + Reason;
                }
                else
                {
                    banmsg += "\n原因 : " + RAPI.escapeMarkdown(Reason);
                }
                if (AdminID == 0)
                {
                    banmsg += "\nOID : `Bot`\n";
                }
                else if (AdminID == 1 || ChatID == Config.InternGroupID)
                {
                    banmsg += "\nOID : `Auditors`\n";
                }
                else
                {
                    banmsg += "\nOID : `" + AdminID + "`\n";
                }
                if (Config.ReasonChannelID != 0 && ReasonID != 0 && Config.ReasonChannelName != null)
                {
                    banmsg += "\n參考 : \nhttps://t.me/" + RAPI.escapeMarkdown(Config.ReasonChannelName) + "/" + ReasonID;
                }
                else if (Config.ReasonChannelID != 0 && ChatID != 0 && MessageID != 0)
                {
                    finalResult = false;
                }
                banmsg += "\n";
                try
                {
                    if (ChatID != Config.InternGroupID)
                    {
                        banmsg += "\n" + TgApi.getDefaultApiConnection().getChatInfo(ChatID).result.GetChatTextInfoMarkdown();
                    }
                }
                catch
                {
                }

                ChannelReasonID = TgApi.getDefaultApiConnection().sendMessage(Config.MainChannelID, banmsg,
                                                                              ParseMode: TgApi.PARSEMODE_MARKDOWN).result.message_id;
            }

            ChangeDbBan(AdminID, UserID, Level, Expires, Reason, ChannelReasonID, ReasonID);
            CNBlacklistApi.PostToAPI(UserID, true, Level, Expires, Reason);
            return(finalResult);
        }