def initialize(self): if not self.senderCanPerm: self.dialog.msg( text=getError("userNotPerms").format(self.sender.ping())) return try: if self.canGetAimed: self.aimed = self.aimed(self.getAimed()) if self.aimed.getRankID() < self.sender.getRankID(): try: self.onCommand() except: self.dialog.msg(text=getError("commandRuneTimeError")) else: self.dialog.msg( text=getError("commandNoUseInAimed").format( self.aimed.getRank().getName(), self.aimed.ping())) return else: try: self.onCommand() except: self.dialog.msg(text=getError("commandRuneTimeError")) except: self.dialog.msg(text=self.errorType) return
def onCommand(self): # не забудь это настроить! getRank = int(self.args[0]) maxRank = 10 srModerRank = 1 srModerMaxRank = 3 if self.sender.getRankID( ) == srModerRank and getRank >= srModerMaxRank: self.dialog.msg( text=getError("manySetRank").format(self.sender.ping())) return if getRank > maxRank: self.dialog.msg(text=getError("maxRank").format(maxRank)) return if int(self.aimed.getRankID()) > getRank: self.dialog.msg(text=getInfo("rankEdit").format( self.sender.getRank().getName(), self.sender.ping(), "понизил", self.aimed.ping())) self.aimed.setRank(getRank) elif int(self.aimed.getRankID()) < getRank: self.dialog.msg(text=getInfo("rankEdit").format( self.sender.getRank().getName(), self.sender.ping(), "повысил", self.aimed.ping())) self.aimed.setRank(getRank) elif int(self.aimed.getRank()) == getRank: self.dialog.msg(text=getError("rankAlreadyInstalled"))
def onCommand(self): if len(self.args) == 0: self.dialog.msg(text=getError("modeError")) newMode = self.args[0].lower() if newMode == 'молчание': self.dialog.activateSilenceMode(text=getReason(self.args[1:])) self.dialog.msg(text=getInfo("editGroupMode").format( self.sender.getRank().getName(), self.sender.ping(), newMode)) self.dialog.msg(text=getInfo("activateSilenceMode")) elif newMode == 'разговор': self.dialog.activateSpeakMode() self.dialog.msg(text=getInfo("editGroupMode").format( self.sender.getRank().getName(), self.sender.ping(), newMode)) else: self.dialog.msg(text=getError("unknownParam"))
def onCommand(self): if not self.dialog.inBanUser(self.aimed): self.dialog.msg(text=getError("userNotBan").format(self.aimed.ping())) return self.dialog.unBanUser(self.aimed) self.dialog.msg(text=getInfraction("userUnBan").format(self.sender.getRank().getName(), self.sender.ping(), self.aimed.getRank().getName(), self.aimed.ping()))
def onCommand(self): if len(self.args) == 0: self.dialog.msg(text=getError("nickError")) if self.args[0].lower() == 'установить': newNick = self.args[1] self.sender.setNick(newNick) self.sender.refreshInfo() self.dialog.msg(text=getInfo("successfulNicknameChange").format( self.sender.getFirstName(), self.sender.getNick())) elif self.args[0].lower() == 'сбросить': newNick = self.sender.getFirstName() self.sender.setNick(newNick) self.dialog.msg(text=getInfo("successfulNicknameReset").format( self.sender.getFirstName())) else: self.dialog.msg(text=getError("unknownParam"))
def onCommand(self): if len(self.args) == 0: self.dialog.msg(text=getError("activateError")) return newStatus = self.args[0].lower() newType = self.args[1].lower() if newStatus == 'активировать': self.dialog.activate() self.dialog.editType(newType) if newType == 'staff' or newType == 'user' or newType == 'special': self.dialog.msg(text=getInfo("activateDialog").format(self.sender.getRank().getName(), self.sender.ping(), newType)) else: self.dialog.msg(text=getError("unknownParam")) elif newType == 'деактивировать': self.dialog.deactivate() else: self.dialog.msg(text=getError("unknownParam"))
def onCommand(self): time = getInfractionTime(self.args[0]) if not time: self.dialog.msg( text=getError("timeError").format(self.sender.ping())) return if self.dialog.inBanUser(self.aimed): self.dialog.msg( text=getError("userAlreadyBan").format(self.aimed.ping())) return if violationLimits(self.sender, time): self.dialog.msg(text=getError("rankLimit").format( self.sender.getRank().getName(), self.sender.ping(), self.sender.getRank().getInfractionLimit())) return self.dialog.banUser(self.aimed, time) DB().createLogs(self.aimed, self.sender, "ban", time, getReason(self.args[1:])) self.dialog.msg(text=getInfraction("userBan").format( self.sender.getRank().getName(), self.sender.ping(), self.aimed.getRank().getName(), self.aimed.ping(), self.args[0], getReason(self.args[1:]))) self.dialog.kickUser(self.aimed)
def firstLevel(self): if not self.dialog.inActivate(): self.dialog.msg(text=getError("dialogNotActivate")) return # Получем пользователя if 'action' in self.obj['message'].keys( ) and self.obj['message']['action']['type'] == 'chat_invite_user': inviteU = True userinvite = User(id=self.obj['message']['from_id']) user = User(id=self.obj['message']['action']['member_id']) else: inviteU = False userinvite = '' user = User(id=self.obj['message']['from_id']) userInviteInDialog = False if 'action' in self.obj['message'].keys(): if self.obj['message']['action'][ 'type'] == 'chat_invite_user' or self.obj['message'][ 'action']['type'] == 'chat_invite_user_by_link': userInviteInDialog = True #self.dialog.msg(text=getSpecial("inviteUser").format(user.ping())) pass elif self.obj['message']['action']['type'] == 'chat_kick_user': if self.dialog == 'staff': sType = 'leaveUserStaff' self.dialog.kickUser(user) else: sType = 'leaveUser' self.dialog.msg(text=getSpecial(sType).format(user.ping())) return # Проверяем пользовотеля на чс if user.inBlackList(): self.dialog.msg( text=getInfraction("userInBlackList").format(user.ping())) self.dialog.kickUser(user) if self.dialog.inSilenceMode(): self.dialog.msg(text=getInfo("silenceModeInDialogAlarm"). format(self.dialog.getTextSilenceMode())) return # Проверка на МУТ if self.dialog.inMuteUser(user): if inviteU: if Rank(userinvite).canRazMute(): self.dialog.msg( text=getInfraction("userUnMuteByInvite").format( user.ping(), userinvite.getRank().getName(), userinvite.ping())) self.dialog.unMuteUser(user) return self.dialog.msg( text=getInfraction("userViolatedMute").format(user.ping())) self.dialog.kickUser(user) if self.dialog.inSilenceMode(): self.dialog.msg(text=getInfo("silenceModeInDialogAlarm"). format(self.dialog.getTextSilenceMode())) return # Проверка на БАН if self.dialog.inBanUser(user): if inviteU: if Rank(userinvite).canRazBan(): self.dialog.msg( text=getInfraction("userUnBanByInvite").format( user.ping(), userinvite.getRank().getName(), userinvite.ping())) self.dialog.unBanUser(user) self.dialog.msg( text=getInfraction("userViolatedBan").format(user.ping())) self.dialog.kickUser(user) if self.dialog.inSilenceMode(): self.dialog.msg(text=getInfo("silenceModeInDialogAlarm"). format(self.dialog.getTextSilenceMode())) return # Проверка на режим молчания if self.dialog.inSilenceMode(): if not user.getRank().canIgnoreSilenceMode( ) and not userInviteInDialog: self.dialog.muteUser(user, 600) self.dialog.msg( text=getInfraction("userViolatedSilenceMode").format( user.getRank().getName(), user.ping())) self.dialog.msg( text=getInfo("mute").format(user.ping(), "5 минут")) self.dialog.msg(text=getInfo("silenceModeInDialogAlarm"). format(self.dialog.getTextSilenceMode())) return if userInviteInDialog: self.dialog.msg(text=getSpecial("inviteUser").format(user.ping())) if self.dialog.getType() == 'staff': return self.secondLevel(user) # Проверка на запрещённые слова text = self.obj['message']['text'].split() for i in text: if i.lower() in SettingsInType('mat'): if not user.getRank().canIgnoreMat(): self.dialog.muteUser(user, 900) self.dialog.msg(text=getInfraction("userMute").format( "Святой", "Ботя", user.getRank().getName(), user.ping(), "15м", "Использование запрещённых слов")) self.dialog.msg( text=getInfo("mute").format(user.ping(), "15м")) return return self.secondLevel(user)
def secondLevel(self, user): commandList = { "бан": BanCommand(sender=user, dialog=self.dialog, errorMsgType=getError("banError"), senderCanPerm=user.getRank().canBan(), obj=self.obj['message']), "чс": BlackListCommand(sender=user, dialog=self.dialog, errorMsgType=getError("blackListError"), senderCanPerm=user.getRank().canBlackList(), obj=self.obj['message']), "режим": EditModeCommand(sender=user, dialog=self.dialog, errorMsgType=getError("modeError"), senderCanPerm=user.getRank().canEditDialogMode(), obj=self.obj['message'], canGetAimed=False), "помощь": HelpCommand(sender=user, dialog=self.dialog, errorMsgType=getError("helpError"), senderCanPerm=user.getRank().canHelp(), obj=self.obj['message'], canGetAimed=False), "история": HistoryCommand(sender=user, dialog=self.dialog, errorMsgType=getError("historyError"), senderCanPerm=user.getRank().canHistory(), obj=self.obj['message']), "кик": KickCommand(sender=user, dialog=self.dialog, errorMsgType=getError("kickError"), senderCanPerm=user.getRank().canNick(), obj=self.obj['message']), "мут": MuteCommand(sender=user, dialog=self.dialog, errorMsgType=getError("muteError"), senderCanPerm=user.getRank().canMute(), obj=self.obj['message']), "ник": NickCommand(sender=user, dialog=self.dialog, errorMsgType=getError("nickError"), senderCanPerm=user.getRank().canNick(), obj=self.obj['message'], canGetAimed=False), "объявление": NoticeCommand(sender=user, dialog=self.dialog, errorMsgType=getError("noticeError"), senderCanPerm=user.getRank().canNotice(), obj=self.obj['message'], canGetAimed=False), "помиловать": PardonCommand(sender=user, dialog=self.dialog, errorMsgType=getError("pardonError"), senderCanPerm=user.getRank().canPardon(), obj=self.obj['message']), "ранг": RankCommand(sender=user, dialog=self.dialog, errorMsgType=getError("rankError"), senderCanPerm=user.getRank().canRank(), obj=self.obj['message']), "стафф-кик": StaffKickCommand(sender=user, dialog=self.dialog, errorMsgType=getError("staffKickError"), senderCanPerm=user.getRank().canStaffKick(), obj=self.obj['message']), "разбан": UnBanCommand(sender=user, dialog=self.dialog, errorMsgType=getError("unBanError"), senderCanPerm=user.getRank().canRazBan(), obj=self.obj['message']), "размут": UnMuteCommand(sender=user, dialog=self.dialog, errorMsgType=getError("unMuteError"), senderCanPerm=user.getRank().canRazMute(), obj=self.obj['message']), "!кто": WhoCommand(sender=user, dialog=self.dialog, errorMsgType=getError("whoError"), senderCanPerm=user.getRank().canWho(), obj=self.obj['message']), "!статус": EditDialogStatusCommand( sender=user, dialog=self.dialog, errorMsgType=getError("activateError"), senderCanPerm=user.getRank().canEditDialogStatus(), obj=self.obj['message'], canGetAimed=False), } try: commandList[self.obj['message']['text'].split() [0].lower()].initialize() except: pass
def initialize(self): try: self.aimed = self.aimed(id=self.getAimed()) self.onCommand() except: self.dialog.msg(text=getError("whoError"))