示例#1
0
    def always(self, m):
        if str(m.conversation.id) == str(
                self.bot.config.alerts_conversation_id) or str(
                    m.conversation.id) == str(
                        self.bot.config.admin_conversation_id):
            return

        spam_types = ['spam', 'arab', 'russian']

        for spam_type in spam_types:
            if has_tag(self.bot, m.sender.id, spam_type):
                if not is_admin(self.bot, m.sender.id, m):
                    self.kick_spammer(m, spam_type, 'tag')
                elif is_trusted(self.bot, m.sender.id, m):
                    del_tag(self.bot, m.sender.id, spam_type)
                    name = get_full_name(self.bot, m.sender.id)
                    gid = str(m.conversation.id)
                    self.bot.send_admin_alert(
                        'Unmarking %s: %s [%s] from group %s [%s]' %
                        (spam_type, name, m.sender.id,
                         self.bot.groups[gid].title, gid))

            if m.conversation.id < 0 and has_tag(
                    self.bot, m.conversation.id, spam_type) and not has_tag(
                        self.bot, m.conversation.id, 'safe') and not has_tag(
                            self.bot, m.conversation.id,
                            'resend:?') and not has_tag(
                                self.bot, m.conversation.id, 'fwd:?'):
                self.kick_myself(m)

        if m.extra:
            if 'urls' in m.extra:
                for url in m.extra['urls']:
                    self.check_trusted_telegram_link(m, fix_telegram_link(url))
            if 'caption' in m.extra and m.extra['caption']:
                if self.detect_arab(m.extra['caption']):
                    self.kick_spammer(m, 'arab', 'caption')
                if self.detect_russian(m.extra['caption']):
                    self.kick_spammer(m, 'russian', 'caption')

                try:
                    self.check_trusted_telegram_link(m, m.extra['caption'])
                except:
                    logging.error(m.extra['caption'])

        if not has_tag(self.bot, m.conversation.id, 'safe') and not has_tag(
                self.bot, m.conversation.id, 'resend:?') and not has_tag(
                    self.bot, m.conversation.id, 'fwd:?'):
            if m.type == 'text':
                if self.detect_arab(m.content):
                    self.kick_spammer(m, 'arab', 'content')

                if self.detect_russian(m.content):
                    self.kick_spammer(m, 'russian', 'content')

            if self.detect_arab(m.sender.first_name):
                self.kick_spammer(m, 'arab', 'name')

            if self.detect_russian(m.sender.first_name):
                self.kick_spammer(m, 'russian', 'name')
示例#2
0
    def run(self, m):
        uid = m.sender.id
        gid = m.conversation.id

        if gid > 0:
            return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

        bullets = None
        roulette = has_tag(self.bot, gid, 'roulette:?', return_match = True)
        
        if roulette:
            bullets = int(roulette[0].split(':')[1])

        if not bullets:
            set_tag(self.bot, gid, 'roulette:6')
            bullets = 6
        
        if randint(1, bullets) == 1:
            del_tag(self.bot, gid, 'roulette:?')
            set_tag(self.bot, gid, 'roulette:6')

            res = self.bot.kick_user(m, uid)

            if not res:
                self.bot.send_message(m, self.bot.trans.plugins.russian_roulette.strings.cant_bang % m.sender.first_name, extra={'format': 'HTML'})
            else:
                self.bot.send_message(m, self.bot.trans.plugins.russian_roulette.strings.bang % m.sender.first_name, extra={'format': 'HTML'})

        else:
            del_tag(self.bot, gid, 'roulette:%s' % bullets)
            bullets -= 1
            set_tag(self.bot, gid, 'roulette:%s' % bullets)
            text = self.bot.trans.plugins.russian_roulette.strings.empty % (m.sender.first_name, bullets)

            self.bot.send_message(m, text, extra={'format': 'HTML'})
示例#3
0
    def run(self, m):
        input = get_input(m)

        if not is_trusted(self.bot, m.sender.id):
            return self.bot.send_message(
                m,
                self.bot.trans.errors.permission_required,
                extra={'format': 'HTML'})

        if not input:
            return self.bot.send_message(
                m,
                self.bot.trans.errors.missing_parameter,
                extra={'format': 'HTML'})

        if m.reply:
            target = str(m.reply.sender.id)
            name = m.reply.sender.first_name

        elif first_word(input) == '-g':
            target = str(m.conversation.id)
            name = m.conversation.title
            input = all_but_first_word(input)

        elif first_word(input).isdigit():
            target = first_word(input)
            name = target
            input = all_but_first_word(input)

        else:
            target = str(m.sender.id)
            name = m.sender.first_name

        tags = input.split()

        # Adds a tag to user or group. #
        if is_command(self, 1, m.content):
            for tag in tags:
                if not has_tag(self.bot, target, tag):
                    set_tag(self.bot, target, tag)
            return self.bot.send_message(
                m,
                self.bot.trans.plugins.tags.strings.tagged % (name, tags),
                extra={'format': 'HTML'})

        # Removes a tag from user or group. #
        elif is_command(self, 2, m.content):
            for tag in tags:
                if has_tag(self.bot, target, tag):
                    del_tag(self.bot, target, tag)
            return self.bot.send_message(
                m,
                self.bot.trans.plugins.tags.strings.untagged % (name, tags),
                extra={'format': 'HTML'})
示例#4
0
    def run(self, m):
        if m.conversation.id > 0:
            return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

        input = get_input(m, ignore_reply=False)
        parameter = first_word(input)
        enabled = ['reactions', 'roulette',
                   'replies', 'pole', 'fiesta', 'nsfw']
        disabled = ['antispam', 'antiarab', 'antirussian', 'polereset']
        config = {}

        for param in enabled:
            config[param] = not has_tag(
                self.bot, m.conversation.id, 'no' + param)

        for param in disabled:
            config[param] = has_tag(self.bot, m.conversation.id, param)

        text = ''
        if not input:
            text = self.bot.trans.plugins.config.strings.explanation % "', '".join(
                config)
            for param in config:
                text += '\n' + ('✔️' if config[param] else '❌') + \
                    ' ' + self.bot.trans.plugins.config.strings[param]

        elif parameter in enabled or parameter in disabled:
            if not is_admin(self.bot, m.sender.id, m) and not is_trusted(self.bot, m.sender.id, m):
                return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

            if config[parameter]:
                if parameter in enabled:
                    set_tag(self.bot, m.conversation.id, 'no' + parameter)
                elif parameter in disabled:
                    del_tag(self.bot, m.conversation.id, parameter)
            else:
                if parameter in enabled:
                    del_tag(self.bot, m.conversation.id, 'no' + parameter)
                elif parameter in disabled:
                    set_tag(self.bot, m.conversation.id, parameter)

            text = ('❌' if config[parameter] else '✔️') + \
                ' ' + self.bot.trans.plugins.config.strings[parameter]

        return self.bot.send_message(m, text, extra={'format': 'HTML'})
示例#5
0
    def run(self, m):
        input = get_input(m)

        if not is_owner(self.bot, m.sender.id) and not is_trusted(self.bot, m.sender.id):
            return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

        if not input:
            return self.bot.send_message(m, generate_command_help(self, m.content), extra={'format': 'HTML'})
            # return self.bot.send_message(m, self.bot.trans.errors.missing_parameter, extra={'format': 'HTML'})

        if not m.reply:
            input = all_but_first_word(input)

        target = get_target(self.bot, m, get_input(m))
        if target:
            name = get_username(self.bot, target, False)

        elif first_word(input) == '-g':
            target = str(m.conversation.id)
            name = get_username(self.bot, target, False)

        else:
            target = str(m.sender.id)
            name = get_username(self.bot, target, False)

        tags = input.split()

        if not target:
            return self.bot.send_message(m, self.bot.trans.errors.no_results, extra={'format': 'HTML'})

        # Adds a tag to user or group. #
        if is_command(self, 1, m.content):
            for tag in tags:
                if not has_tag(self.bot, target, tag):
                    set_tag(self.bot, target, tag)
            return self.bot.send_message(m, self.bot.trans.plugins.tags.strings.tagged % (name, tags), extra={'format': 'HTML'})

        # Removes a tag from user or group. #
        elif is_command(self, 2, m.content):
            for tag in tags:
                if has_tag(self.bot, target, tag):
                    del_tag(self.bot, target, tag)
            return self.bot.send_message(m, self.bot.trans.plugins.tags.strings.untagged % (name, tags), extra={'format': 'HTML'})
示例#6
0
    def run(self, m):
        if not is_trusted(self.bot, m.sender.id):
            return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

        if not input:
            return self.bot.send_message(m, self.bot.trans.errors.missing_parameter, extra={'format': 'HTML'})

        input = get_input(m)
        if m.reply:
            target = str(m.reply.sender.id)
            name = m.reply.sender.first_name

        elif first_word(input) == '-g':
            target = str(m.conversation.id)
            name = m.conversation.title
            input = all_but_first_word(input)

        elif first_word(input).isdigit():
            target = first_word(input)
            name = target
            input = all_but_first_word(input)

        else:
            target = str(m.sender.id)
            name = m.sender.first_name

        tags = input.split()

        # Adds a tag to user or group. #
        if is_command(self, 1, m.content):
            for tag in tags:
                if not has_tag(self.bot, target, tag):
                    set_tag(self.bot, target, tag)
            return self.bot.send_message(m, self.bot.trans.plugins.tags.strings.tagged % (name, tags), extra={'format': 'HTML'})

        # Removes a tag from user or group. #
        elif is_command(self, 2, m.content):
            for tag in tags:
                if has_tag(self.bot, target, tag):
                    del_tag(self.bot, target, tag)
            return self.bot.send_message(m, self.bot.trans.plugins.tags.strings.untagged % (name, tags), extra={'format': 'HTML'})
示例#7
0
    def run(self, m):
        if is_command(self, 1, m.content):
            username = get_input(m)

            if not username:
                #username = get_setting(self.bot, m.sender.id, 'lastfm.username')
                tags = has_tag(self.bot, m.sender.id,
                               'lastfm:?', return_match=True)
                if tags and len(tags) > 0:
                    username = tags[0].split(':')[1]
                if not username and m.sender.username:
                    username = m.sender.username
                if not username:
                    return self.bot.send_message(m, self.bot.trans.errors.missing_parameter, extra={'format': 'HTML'})

            url = 'http://ws.audioscrobbler.com/2.0/'
            params = {
                'method': 'user.getrecenttracks',
                'format': 'json',
                'limit': '1',
                'api_key': self.bot.config.api_keys.lastfm,
                'user': username
            }

            lastfm = send_request(url, params=params, bot=self.bot)

            # If the user didn't have any tracks or doesn't exist return No Results error. #
            try:
                last = lastfm.recenttracks.track[0]
            except:
                return self.bot.send_message(m, self.bot.trans.errors.no_results, extra={'format': 'HTML'})

            artist = last.artist['#text'].title()
            track = last.name.title()
            album = last.album['#text'].title()
            track_url = last.url

            try:
                nowplaying = last['@attr'].nowplaying
                if nowplaying == 'true':
                    nowplaying = True
                else:
                    nowplaying == False
            except:
                date = last.date['#text']
                nowplaying = False

            if nowplaying:
                text = self.bot.trans.plugins.lastfm.strings.now_playing % username
            else:
                text = self.bot.trans.plugins.lastfm.strings.last_played % username

            text += '\n🎵 <i>%s</i>\n💽 %s' % (track, artist)
            if album:
                text += ' - %s' % album

            # Gets the link of a Youtube video of the track. #
            url = 'https://www.googleapis.com/youtube/v3/search'
            params = {
                'type': 'video',
                'part': 'snippet',
                'maxResults': '1',
                'q': '%s %s' % (track, artist),
                'key': self.bot.config.api_keys.google_developer_console
            }

            youtube = send_request(url, params=params, bot=self.bot)

            if not 'error' in youtube and len(youtube['items']) > 0:
                text += '\n\n🌐 %s\n%s\nhttps://youtu.be/%s' % (
                    self.bot.trans.plugins.lastfm.strings.might_be, youtube['items'][0].snippet.title, youtube['items'][0].id.videoId)

            self.bot.send_message(
                m, text, extra={'format': 'HTML', 'preview': False})

        elif is_command(self, 2, m.content):
            input = get_input(m)
            if not input:
                return self.bot.send_message(m, generate_command_help(self, m.content), extra={'format': 'HTML'})
                # return self.bot.send_message(m, self.bot.trans.errors.missing_parameter, extra={'format': 'HTML'})

            # set_setting(self.bot, m.sender.id, 'lastfm.username', input)
            del_tag(self.bot, m.sender.id, 'lastfm:?')
            set_tag(self.bot, m.sender.id, 'lastfm:%s' % input)
            self.bot.send_message(m, self.bot.trans.plugins.lastfm.strings.username_set, extra={
                                  'format': 'HTML', 'preview': False})
    def run(self, m):
        # List #
        if is_command(self, 1, m.content):
            resends = []
            forwards = []
            text = ''
            for gid in self.bot.tags:
                for tag in self.bot.tags[gid]:
                    if 'resend:' in tag:
                        resends.append('{}:{}'.format(gid, tag.split(':')[1]))

                    if 'fwd:' in tag:
                        resends.append('{}:{}'.format(gid, tag.split(':')[1]))

            if len(resends) > 0:
                text += '<b>Resends:</b>'
                text += self.generate_text(resends)

            if len(forwards) > 0:
                text += '\n<b>Forwards:</b>'
                text += self.generate_text(forwards)

            return self.bot.send_message(m, text, extra={'format': 'HTML'})

        # Add resend #
        elif is_command(self, 2, m.content):
            input = get_input(m)
            if not input:
                return self.bot.send_message(m,
                                             generate_command_help(
                                                 self, m.content),
                                             extra={'format': 'HTML'})

            origin = first_word(input)
            destination = first_word(input, 2)

            if not origin or not destination:
                return self.bot.send_message(m,
                                             generate_command_help(
                                                 self, m.content),
                                             extra={'format': 'HTML'})

        # Remove all resends #
        elif is_command(self, 3, m.content):
            input = get_input(m)
            if not input:
                return self.bot.send_message(m,
                                             generate_command_help(
                                                 self, m.content),
                                             extra={'format': 'HTML'})

            origin = first_word(input)

            if not is_int(origin):
                return self.bot.send_message(m,
                                             generate_command_help(
                                                 self, m.content),
                                             extra={'format': 'HTML'})

            del_tag(self.bot, origin, 'resend:?')
            del_tag(self.bot, origin, 'fwd:?')
            return self.bot.send_message(m, '✅', extra={'format': 'HTML'})
示例#9
0
    def run(self, m):
        input = get_input(m)
        uid = str(m.sender.id)
        gid = str(m.conversation.id)

        # List all administration commands. #
        if is_command(self, 1, m.content):
            text = self.bot.trans.plugins.administration.strings.commands
            for command in self.commands:
                # Adds the command and parameters#
                if command.command == '^new_chat_member$':
                    text += '\n • ' + \
                        self.bot.trans.plugins.administration.strings.new_chat_member
                else:
                    text += '\n • ' + \
                        command.command.replace('/', self.bot.config.prefix)

                if 'parameters' in command and command.parameters:
                    for parameter in command.parameters:
                        name, required = list(parameter.items())[0]
                        # Bold for required parameters, and italic for optional #
                        if required:
                            text += ' <b>&lt;%s&gt;</b>' % name
                        else:
                            text += ' [%s]' % name

                if 'description' in command:
                    text += '\n   <i>%s</i>' % command.description
                else:
                    text += '\n   <i>?¿</i>'

            return self.bot.send_message(m, text, extra={'format': 'HTML'})

        # List all groups. #
        if is_command(self, 2, m.content):
            text = self.bot.trans.plugins.administration.strings.groups
            if len(self.bot.administration) > 0:
                for gid, attr in self.bot.administration.items():
                    if 'public' in self.bot.administration[gid] and self.bot.administration[gid].public:
                        if 'link' in self.bot.administration[gid] and self.bot.config.bindings != 'telegram-cli':
                            text += '\n • <a href="%s">%s</a>' % (
                                self.bot.administration[gid].link, self.bot.groups[gid].title)
                        else:
                            text += '\n • %s' % self.bot.groups[gid].title

                        if self.bot.administration[gid].alias:
                            text += ' /<b>%s</b>/' % attr.alias

            else:
                text = self.bot.trans.plugins.administration.strings.no_groups

            return self.bot.send_message(m, text, extra={'format': 'HTML', 'preview': False})

        # Join a group. #
        elif is_command(self, 3, m.content):
            if not input:
                return self.bot.send_message(m, self.bot.trans.errors.missing_parameter, extra={'format': 'HTML'})

            gid_to_join = None
            for id in self.bot.administration:
                if (input in self.bot.administration
                    or compile('^' + input.lower() + '$').search(self.bot.administration[id].alias.lower())
                        or compile('^' + input.lower() + '$').search(self.bot.groups[id].title.lower())):
                    gid_to_join = id
                    break

            if gid_to_join:
                if not gid_to_join in self.bot.administration:
                    return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.not_added % m.conversation.title, extra={'format': 'HTML'})

                added = self.bot.bindings.invite_conversation_member(
                    gid_to_join, uid)

                if not added:
                    text = '<b>%s</b>' % self.bot.groups[gid_to_join].title
                    if self.bot.administration[gid_to_join].motd:
                        text += '\n<i>%s</i>' % self.bot.administration[gid_to_join].motd

                    text += '\n\n%s' % self.bot.trans.plugins.administration.strings.rules
                    i = 1
                    if 'rules' in self.bot.administration[gid_to_join]:
                        for rule in self.bot.administration[gid_to_join].rules:
                            text += '\n %s. <i>%s</i>' % (i, rule)
                            i += 1
                    else:
                        text += '\n%s' % self.bot.trans.plugins.administration.strings.norules

                    if not self.bot.administration[gid_to_join].link:
                        text += '\n\n%s' % self.bot.trans.plugins.administration.strings.nolink
                    else:
                        text += '\n\n<a href="%s">%s</a>' % (
                            self.bot.administration[gid_to_join].link, self.bot.trans.plugins.administration.strings.join)
                    return self.bot.send_message(m, text, extra={'format': 'HTML', 'preview': False})

        # Information about a group. #
        elif is_command(self, 4, m.content) or is_command(self, 16, m.content):
            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})
            if not gid in self.bot.administration:
                if is_command(self, 4, m.content):
                    return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.not_added % m.conversation.title, extra={'format': 'HTML'})
                elif is_command(self, 16, m.content):
                    return

            text = '<b>%s</b>' % self.bot.groups[gid].title
            if 'motd' in self.bot.administration[gid]:
                text += '\n<i>%s</i>' % self.bot.administration[gid].motd

            text += '\n\n%s' % self.bot.trans.plugins.administration.strings.rules
            i = 1

            if not 'rules' in self.bot.administration[gid]:
                text += '\n%s' % self.bot.trans.plugins.administration.strings.norules
            else:
                for rule in self.bot.administration[gid].rules:
                    text += '\n %s. <i>%s</i>' % (i, rule)
                    i += 1

            if is_command(self, 4, m.content):
                if not self.bot.administration[gid].link:
                    text += '\n\n%s' % self.bot.trans.plugins.administration.strings.nolink
                else:
                    text += '\n\n<a href="%s">%s</a>' % (
                        self.bot.trans.plugins.administration.strings.join, self.bot.administration[gid].link)
            return self.bot.send_message(m, text, extra={'format': 'HTML', 'preview': False})

        # Rules of a group. #
        elif is_command(self, 5, m.content):
            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})
            if not gid in self.bot.administration:
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.not_added % m.conversation.title, extra={'format': 'HTML'})

            if input and is_int(input):
                try:
                    i = int(input)
                    text = '%s. <i>%s</i>' % (i,
                                              self.bot.administration[gid].rules[i - 1])
                except:
                    text = self.bot.trans.plugins.administration.strings.notfound

            else:
                text = self.bot.trans.plugins.administration.strings.rules
                i = 1
                for rule in self.bot.administration[gid].rules:
                    text += '\n %s. <i>%s</i>' % (i, rule)
                    i += 1

            if not self.bot.administration[gid].rules:
                text += '\n%s' % self.bot.trans.plugins.administration.strings.norules
            return self.bot.send_message(m, text, extra={'format': 'HTML', 'preview': False})

        # Set rules #
        elif is_command(self, 6, m.content):
            if not input:
                return self.bot.send_message(m, self.bot.trans.errors.missing_parameter, extra={'format': 'HTML'})

            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

            if not is_admin(self.bot, uid, m) and not is_mod(self.bot, uid, gid):
                return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

            if gid in self.bot.administration:
                self.bot.administration[gid].rules = input.split('\n')
                set_data('administration/%s/%s/rules' %
                         (self.bot.name, gid), self.bot.administration[gid].rules)
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.set % m.conversation.title, extra={'format': 'HTML'})
            else:
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.not_added % m.conversation.title, extra={'format': 'HTML'})

        # Set rule #
        elif is_command(self, 7, m.content):
            if not input:
                return self.bot.send_message(m, self.bot.trans.errors.missing_parameter, extra={'format': 'HTML'})

            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

            if not is_admin(self.bot, uid, m) and not is_mod(self.bot, uid, gid):
                return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

            if gid in self.bot.administration:
                try:
                    i = int(first_word(input))-1
                    if i > len(self.bot.administration[gid].rules):
                        i = len(self.bot.administration[gid].rules)
                    elif i < 1:
                        i = 0
                except:
                    return self.bot.send_message(m, self.bot.trans.errors.invalid_syntax, extra={'format': 'HTML'})

                self.bot.administration[gid].rules.insert(
                    i, all_but_first_word(input))
                set_data('administration/%s/%s/rules' %
                         (self.bot.name, gid), self.bot.administration[gid].rules)
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.set % m.conversation.title, extra={'format': 'HTML'})

        # Remove rule #
        elif is_command(self, 8, m.content):
            if not input:
                return self.bot.send_message(m, self.bot.trans.errors.missing_parameter, extra={'format': 'HTML'})

            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

            if not is_admin(self.bot, uid, m) and not is_mod(self.bot, uid, gid):
                return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

            if gid in self.bot.administration:
                try:
                    i = int(first_word(input))-1
                    if i > len(self.bot.administration[gid].rules):
                        i = len(self.bot.administration[gid].rules)
                    elif i < 1:
                        i = 0
                except:
                    return self.bot.send_message(m, self.bot.trans.errors.invalid_syntax, extra={'format': 'HTML'})

                del self.bot.administration[gid].rules[i]
                set_data('administration/%s/%s/rules' %
                         (self.bot.name, gid), self.bot.administration[gid].rules)
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.set % m.conversation.title, extra={'format': 'HTML'})

        # Add mod #
        elif is_command(self, 9, m.content):
            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

            if not is_admin(self.bot, uid, m):
                return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

            set_tag(self.bot, m.sender.id, 'mod:%s' % gid)

        # Remove mod #
        elif is_command(self, 10, m.content):
            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

            if not is_admin(self.bot, uid, gid):
                return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

            del_tag(self.bot, m.sender.id, 'mod:%s' % gid)

        # Add group #
        elif is_command(self, 11, m.content):
            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

            if not is_admin(self.bot, uid, m):
                return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

            if not gid in self.bot.administration:
                self.bot.administration[gid] = {
                    'alias': None,
                    'description': None,
                    'link': None,
                    'rules': [],
                    'public': False
                }
                set_data('administration/%s/%s' %
                         (self.bot.name, gid), self.bot.administration[gid])
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.added % m.conversation.title, extra={'format': 'HTML'})
            else:
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.already_added % m.conversation.title, extra={'format': 'HTML'})

        # Remove group #
        elif is_command(self, 12, m.content):
            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

            if not is_admin(self.bot, uid, m):
                return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

            if gid in self.bot.administration:
                del self.bot.administration[gid]
                delete_data('administration/%s/%s' % (self.bot.name, gid))
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.removed % m.conversation.title, extra={'format': 'HTML'})
            else:
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.not_added % m.conversation.title, extra={'format': 'HTML'})

        # Set alias #
        elif is_command(self, 13, m.content):
            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

            if not is_admin(self.bot, uid, m):
                return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

            if gid in self.bot.administration:
                self.bot.administration[gid].alias = input.lower()
                set_data('administration/%s/%s/alias' %
                         (self.bot.name, gid), self.bot.administration[gid].alias)
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.set % m.conversation.title, extra={'format': 'HTML'})
            else:
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.not_added % m.conversation.title, extra={'format': 'HTML'})

        # Set link #
        elif is_command(self, 14, m.content):
            if m.conversation.id > 0:
                return self.bot.send_message(m, self.bot.trans.errors.group_only, extra={'format': 'HTML'})

            if not is_admin(self.bot, uid, m):
                return self.bot.send_message(m, self.bot.trans.errors.permission_required, extra={'format': 'HTML'})

            if gid in self.bot.administration:
                self.bot.administration[gid].link = input.lower()
                set_data('administration/%s/%s/link' %
                         (self.bot.name, gid), self.bot.administration[gid].link)
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.set % m.conversation.title, extra={'format': 'HTML'})
            else:
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.not_added % m.conversation.title, extra={'format': 'HTML'})

        # Make public #
        elif is_command(self, 15, m.content):
            if not input:
                return self.bot.send_message(m, self.bot.trans.errors.missing_parameter, extra={'format': 'HTML'})

            if gid in self.bot.administration:
                if input and 'true' in input.lower():
                    self.bot.administration[gid].public = True
                else:
                    self.bot.administration[gid].public = False
                set_data('administration/%s/%s/public' %
                         (self.bot.name, gid), self.bot.administration[gid].public)
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.set % m.conversation.title, extra={'format': 'HTML'})
            else:
                return self.bot.send_message(m, self.bot.trans.plugins.administration.strings.not_added % m.conversation.title, extra={'format': 'HTML'})