コード例 #1
0
    def on_nick(self, old, new, uid):
        old_info = self.find_user_info(old)
        if old in self.room_users.keys():
            del self.room_users[old]
            # Update user info
            self.room_users[new] = old_info
        # Is it a new user joining?
        if str(old).startswith('guest-') and uid != self.client_id:
            bad_nicks = tinychat.fh.file_reader(BOT_OPTIONS['file_path'], BOT_OPTIONS['badnicks'])
            # Check if the user name is in the badnicks file.
            if bad_nicks is not None and new in bad_nicks:
                # User name is in the badnicks file, so we ban the user.
                self.send_ban_msg(new, uid)
            else:
                # Else greet the user. Should we have a command to enable/disable greetings?
                self.send_bot_msg('*Welcome to* ' + self.roomname + ' *' + new + '*', self.is_client_mod)
                # Get users profile info.
                self.send_userinfo_request_msg(new)
                # Is medie playing?
                if len(self.playlist) is not 0:
                    play_type = self.playlist[self.inowplay]['type']
                    video_id = self.playlist[self.inowplay]['video_id']
                    elapsed_time = str(self.elapsed_track_time)
                    # Play the media at the correct start time.
                    self.send_undercover_msg(new, '/mbs ' + play_type + ' ' + video_id + ' ' + elapsed_time)

        tinychat.console_write([tinychat.COLOR['cyan'], old + ':' + uid + ' changed nick to: ' + new, self.roomname])
コード例 #2
0
    def message_handler(self, msg_sender, msg):
        """
        Custom command handler.
        :param msg_sender: str the user sending a message
        :param msg: str the message
        """
        user_check = self.find_user_info(msg_sender)
        user_check.last_msg = msg
        if msg.startswith(BOT_OPTIONS['prefix']):
            parts = msg.split(' ')
            cmd = parts[0].lower().strip()
            cmd_param = ' '.join(parts[1:])

            # Mod and bot controller commands.
            if user_check.is_mod or user_check.has_power:
                if cmd == BOT_OPTIONS['prefix'] + 'reboot':
                    # Reboots the client. Only room owner can use this command.
                    if user_check.user_account == self.roomname:
                        self.reconnect()
                    else:
                        self.send_bot_msg('You must be the room owner to use this command.')

                elif cmd == BOT_OPTIONS['prefix'] + 'close':
                    # Closes a users broadcast.
                    if self.is_client_mod:
                        if len(cmd_param) is 0:
                            self.send_bot_msg('Missing username.')
                        else:
                            self.send_close_user_msg(cmd_param)

                elif cmd == BOT_OPTIONS['prefix'] + 'clear':
                    # Clears the chatbox.
                    if self.is_client_mod:
                        for x in range(0, 10):
                            self.send_owner_run_msg(' ')
                    else:
                        clear = '133,133,133,133,133,133,133,133,133,133,133,133,133,133,133'
                        self._sendCommand('privmsg', [clear, tinychat.random_color() + ',en'])

                elif cmd == BOT_OPTIONS['prefix'] + 'skip':
                    # Plays next tune in the playlist.
                    if len(self.playlist) is not 0:
                        self.play = False

                elif cmd == BOT_OPTIONS['prefix'] + 'up':
                    # Cams the client up.
                    self.send_bauth_msg()
                    self._sendCreateStream()
                    self._sendPublish()

                elif cmd == BOT_OPTIONS['prefix'] + 'down':
                    # Cams the client down.
                    self._sendCloseStream()

                elif cmd == BOT_OPTIONS['prefix'] + 'nick':
                    # Give the client a new nick name.
                    if len(cmd_param) is 0:
                        self.client_nick = tinychat.create_random_string(5, 25)
                        self.set_nick()
                    else:
                        if re.match('^[][\{\}a-zA-Z0-9_-]{1,25}$', cmd_param):
                            self.client_nick = cmd_param
                            self.set_nick()

                elif cmd == BOT_OPTIONS['prefix'] + 'topic':
                    # Sets the room topic.
                    if self.is_client_mod:
                        if len(cmd_param) is 0:
                            self.send_bot_msg('Missing topic.', self.is_client_mod)
                        else:
                            self.send_topic_msg(cmd_param)
                            self.send_bot_msg('The room topic was set to: ' + cmd_param, self.is_client_mod)
                    else:
                        self.send_bot_msg('Command not enabled.')

                elif cmd == BOT_OPTIONS['prefix'] + 'kick':
                    # Kicks a user from the room.
                    if self.is_client_mod:
                        if len(cmd_param) is 0:
                            self.send_bot_msg('Missing username.', self.is_client_mod)
                        else:
                            user = self.find_user_info(cmd_param)
                            if user is None:
                                self.send_bot_msg('No user named: *' + cmd_param + '*', self.is_client_mod)
                            else:
                                self.send_ban_msg(cmd_param, user.id)
                                self.send_forgive_msg(user.id)
                    else:
                        self.send_bot_msg('Command not enabled.')

                elif cmd == BOT_OPTIONS['prefix'] + 'ban':
                    # Bans a user from the room.
                    if self.is_client_mod:
                        if len(cmd_param) is 0:
                            self.send_bot_msg('Missing username.', self.is_client_mod)
                        else:
                            user = self.find_user_info(cmd_param)
                            if user is None:
                                self.send_bot_msg('No user named: *' + cmd_param + '*', self.is_client_mod)
                            else:
                                self.send_ban_msg(cmd_param, user.id)
                    else:
                        self.send_bot_msg('Command not enabled.')

                elif cmd == BOT_OPTIONS['prefix'] + 'bn':
                    # Adds a nick to the bad nick file.
                    if self.is_client_mod:
                        if len(cmd_param) is 0:
                            self.send_bot_msg('Missing username.', self.is_client_mod)
                        else:
                            if cmd_param in tinychat.fh.file_reader(BOT_OPTIONS['file_path'], BOT_OPTIONS['badnicks']):
                                self.send_bot_msg(cmd_param + ' is already in list.', self.is_client_mod)
                            else:
                                tinychat.fh.file_writer(BOT_OPTIONS['file_path'], BOT_OPTIONS['badnicks'], cmd_param)
                    else:
                        self.send_bot_msg('Command not enabled.')

                elif cmd == BOT_OPTIONS['prefix'] + 'rmbn':
                    # Removes a nick from the bad nick file.
                    if self.is_client_mod:
                        if len(cmd_param) is 0:
                            self.send_bot_msg('Missing username', self.is_client_mod)
                        else:
                            rem = tinychat.fh.remove_from_file(BOT_OPTIONS['file_path'], BOT_OPTIONS['badnicks'], cmd_param)
                            if rem:
                                self.send_bot_msg(cmd_param + ' was removed.')
                    else:
                        self.send_bot_msg('Command not enabled.')

                elif cmd == BOT_OPTIONS['prefix'] + 'clrbn':
                    # Clears the bad nick file.
                    tinychat.fh.delete_file_content(BOT_OPTIONS['file_path'], BOT_OPTIONS['badnicks'])

                elif cmd == BOT_OPTIONS['prefix'] + 'list':
                    # Shows info about different lists.
                    if self.is_client_mod:
                        if len(cmd_param) is 0:
                            self.send_bot_msg('Missing list type.', self.is_client_mod)
                        else:
                            if cmd_param.lower().strip() == 'bn':
                                bad_nicks = tinychat.fh.file_reader(BOT_OPTIONS['file_path'], BOT_OPTIONS['badnicks'])
                                if bad_nicks is None:
                                    self.send_bot_msg('No items in this list.', self.is_client_mod)
                                else:
                                    self.send_bot_msg(str(len(bad_nicks)) + ' items in list.', self.is_client_mod)
                            elif cmd_param.lower().strip() == 'pl':
                                if len(self.playlist) is not 0:
                                    counter = 0
                                    for i in range(self.inowplay, len(self.playlist)):
                                        v_time = self._milliseconds_to_HMS(self.playlist[i]['video_time'])
                                        v_title = self.playlist[i]['video_title']
                                        if counter <= 4:
                                            if counter == 0:
                                                self.send_owner_run_msg('*>>> %s* %s' % (v_title, v_time))
                                            else:
                                                self.send_owner_run_msg('(%s) *%s* %s' % (i, v_title, v_time))
                                            counter += 1

                elif cmd == BOT_OPTIONS['prefix'] + 'info':
                    # Gets user info for a user in the room.
                    if self.is_client_mod:
                        if len(cmd_param) is 0:
                            self.send_bot_msg('Missing username', self.is_client_mod)
                        else:
                            user = self.find_user_info(cmd_param)
                            if user is None:
                                self.send_bot_msg('No user named: ' + cmd_param, self.is_client_mod)
                            else:
                                self.send_owner_run_msg('*Userinfo for:* ' + cmd_param)
                                self.send_owner_run_msg('*ID:* ' + user.id)
                                self.send_owner_run_msg('*Mod:* ' + str(user.is_mod))
                                self.send_owner_run_msg('*Bot Control:* ' + str(user.has_power))
                                if user.tinychat_id is not None:
                                    self.send_owner_run_msg('*Account:* ' + str(user.user_account))
                                    self.send_owner_run_msg('*Tinychat ID:* ' + str(user.tinychat_id))
                                    self.send_owner_run_msg('*Last login:* ' + str(user.last_login))
                                self.send_owner_run_msg('*Last message:* ' + str(user.last_msg))
                    else:
                        self.send_bot_msg('Command not enabled')

                elif cmd == BOT_OPTIONS['prefix'] + 'search':
                    # Searches youtube for a list of candidates.
                    if self.is_client_mod:
                        if len(cmd_param) is 0:
                            self.send_bot_msg('Missing search term.', self.is_client_mod)
                        else:
                            self.search_list = tiny_media.youtube_search_list(cmd_param, results=5)
                            if len(self.search_list) is not 0:
                                for i in range(0, len(self.search_list)):
                                    v_time = self._milliseconds_to_HMS(self.search_list[i]['video_time'])
                                    v_title = self.search_list[i]['video_title']
                                    self.send_owner_run_msg('(%s) *%s* %s' % (i, v_title, v_time))
                            else:
                                self.send_bot_msg('Could not find: ' + cmd_param, self.is_client_mod)
                    else:
                        self.send_bot_msg('Command not enabled.')

                elif cmd == BOT_OPTIONS['prefix'] + 'plys':
                    # Plays from the search list.
                    if len(self.search_list) > 0:
                        try:
                            index_choice = int(cmd_param)
                            if 0 <= index_choice <= 4:
                                if len(self.playlist) <= 2:
                                    self.play_youtube(self.search_list[index_choice]['video_id'])
                                else:
                                    self.send_bot_msg('No can do, when playlist is playing.', self.is_client_mod)
                            else:
                                self.send_bot_msg('Please make a choice between 0-4', self.is_client_mod)
                        except ValueError:
                            self.send_bot_msg('Only numbers allowed.', self.is_client_mod)
                    else:
                        self.send_bot_msg('The search list is empty.', self.is_client_mod)

                elif cmd == BOT_OPTIONS['prefix'] + 'adls':
                    # Adds a youtube from the search list to the playlist.
                    if len(self.search_list) > 0:
                        try:
                            index_choice = int(cmd_param)
                            if 0 <= index_choice <= 4:
                                self.playlist.append(self.search_list[index_choice])
                                video_title = self.search_list[index_choice]['video_title']
                                self.send_bot_msg('*Added:* ' + video_title + ' *to playlist.*', self.is_client_mod)
                                if len(self.playlist) == 2:
                                    thread.start_new_thread(self.start_playlist, ())
                            else:
                                self.send_bot_msg('Please make a choice between 0-4', self.is_client_mod)
                        except ValueError:
                            self.send_bot_msg('Only numbers allowed.', self.is_client_mod)
                    else:
                        self.send_bot_msg('The search list is empty.', self.is_client_mod)

            # Start of public commands.
            if cmd == BOT_OPTIONS['prefix'] + 'pmme':
                # Makes the client private message a user.
                self.send_private_bot_msg('How can i help you *' + msg_sender + '*?', msg_sender)

            elif cmd == BOT_OPTIONS['prefix'] + 'uptime':
                # Shows the clients up time.
                self.send_bot_msg('*Uptime: ' + str(self.uptime) + '*', self.is_client_mod)

            elif cmd == BOT_OPTIONS['prefix'] + 'help':
                # Prints some of the commands on the screen. Maybe this should be a pastebin url instead?
                if self.is_client_mod:
                    if user_check.is_mod or user_check.has_power:
                        self.send_owner_run_msg('*!skip* - skips the currently playing media.')
                        self.send_owner_run_msg('*!close* username - closes a users broadcast.')
                        self.send_owner_run_msg('*!kick* username - kicks a user out of the room.')
                        self.send_owner_run_msg('*!ban* username - bans a user from the room.')
                        self.send_owner_run_msg('*!clear* - clears the screen.')
                    self.send_owner_run_msg('*!adl* youtube title or link - adds a youtube to the playlist.')
                    self.send_owner_run_msg('*!adlsc* soundcloud title or id - adds a soundcloud to the playlist.')
                    self.send_owner_run_msg('*!ply* youtube title or link - plays youtube.')
                    self.send_owner_run_msg('*!plysc* soundcloud title - plays soundcloud.')
                else:
                    self.send_bot_msg('Command not enabled.')

            # Media related commands.
            elif cmd == BOT_OPTIONS['prefix'] + 'plstat':
                # Prints info about the playlist.
                if len(self.playlist) == 0:
                    self.send_bot_msg('*The playlist is empty.*', self.is_client_mod)
                else:
                    inquee = len(self.playlist) - self.inowplay - 1
                    self.send_bot_msg(str(len(self.playlist)) + ' *items in the playlist.* ' + str(inquee) +
                                      ' *Still in queue.*', self.is_client_mod)

            elif cmd == BOT_OPTIONS['prefix'] + 'next?':
                # Tells us the next tune in the playlist.
                if len(self.playlist) == 0:
                    self.send_bot_msg('No tunes in the playlist.', self.is_client_mod)
                else:
                    if self.inowplay + 1 == len(self.playlist):
                        self.send_bot_msg('This is the last tune in the playlist.', self.is_client_mod)
                    else:
                        play_time = self._milliseconds_to_HMS(self.playlist[self.inowplay + 1]['video_time'])
                        play_title = self.playlist[self.inowplay + 1]['video_title']
                        self.send_bot_msg('*Next tune is:* ' + play_title + ' ' + play_time, self.is_client_mod)

            elif cmd == BOT_OPTIONS['prefix'] + 'adl':
                # Adds a youtube to the playlist.
                if len(cmd_param) is 0:
                    self.send_bot_msg('Please specify youtube title, id or link.', self.is_client_mod)
                else:
                    youtube = tiny_media.youtube_search(cmd_param)
                    if youtube is None:
                        self.send_bot_msg('Could not find video: ' + cmd_param, self.is_client_mod)
                    else:
                        play_time = self._milliseconds_to_HMS(youtube['video_time'])
                        video_title = youtube['video_title']
                        self.send_bot_msg('*Added:* ' + video_title + ' *to playlist.* ' + play_time, self.is_client_mod)
                        self.playlist.append(youtube)
                        if len(self.playlist) == 2:
                            thread.start_new_thread(self.start_playlist, ())

            elif cmd == BOT_OPTIONS['prefix'] + 'adlsc':
                # Adds a soundcloud to the playlist.
                if len(cmd_param) is 0:
                    self.send_bot_msg('Please specify soundcloud title or id.', self.is_client_mod)
                else:
                    soundcloud = tiny_media.soundcloud_search(cmd_param)
                    if soundcloud is None:
                        self.send_bot_msg('Could not find video: ' + cmd_param, self.is_client_mod)
                    else:
                        self.send_bot_msg('*Added:* ' + soundcloud['video_title'] + ' *to playlist.*', self.is_client_mod)
                        self.playlist.append(soundcloud)
                        if len(self.playlist) == 2:
                            thread.start_new_thread(self.start_playlist, ())

            elif cmd == BOT_OPTIONS['prefix'] + 'ply':
                # Plays a youtube video.
                if len(self.playlist) >= 2:
                    self.send_bot_msg('Cannot play youtube when playlist is playing. Use *!adl* instead.', self.is_client_mod)
                else:
                    if len(cmd_param) is 0:
                        self.send_bot_msg('Please specify youtube title, id or link.', self.is_client_mod)
                    else:
                        youtube = tiny_media.youtube_search(cmd_param)
                        if youtube is None:
                            self.send_bot_msg('Could not find video: ' + cmd_param, self.is_client_mod)
                        else:
                            self.play_youtube(youtube['video_id'])

            elif cmd == BOT_OPTIONS['prefix'] + 'sply':
                # Plays a private youtube video.
                if len(cmd_param) is 0:
                    self.send_undercover_msg(msg_sender, 'Please specify youtube title, id or link.')
                else:
                    youtube = tiny_media.youtube_search(cmd_param)
                    if youtube is None:
                        self.send_undercover_msg(msg_sender, 'Could not find video: ' + cmd_param)
                    else:
                        self.send_undercover_msg(msg_sender, '/mbs youTube ' + youtube['video_id'] + ' 0')

            elif cmd == BOT_OPTIONS['prefix'] + 'plysc':
                # Plays a soundcloud.
                if len(self.playlist) >= 2:
                    self.send_bot_msg('Cannot play soundcloud when playlist is playing. Use *!adlsc* instead.', self.is_client_mod)
                else:
                    if len(cmd_param) is 0:
                        self.send_bot_msg('Please specify soundcloud title or id.', self.is_client_mod)
                    else:
                        soundcloud = tiny_media.soundcloud_search(cmd_param)
                        if soundcloud is None:
                            self.send_bot_msg('Could not find soundcloud: ' + cmd_param, self.is_client_mod)
                        else:
                            self.play_soundcloud(soundcloud['video_id'])

            elif cmd == BOT_OPTIONS['prefix'] + 'splysc':
                # Plays a private soundcloud.
                if len(cmd_param) is 0:
                    self.send_undercover_msg(msg_sender, 'Please specify soundcloud title or id.')
                else:
                    soundcloud = tiny_media.soundcloud_search(cmd_param)
                    if soundcloud is None:
                        self.send_undercover_msg(msg_sender, 'Could not find video: ' + cmd_param)
                    else:
                        self.send_undercover_msg(msg_sender, '/mbs soundCloud ' + soundcloud['video_id'] + ' 0')

            # Tinychat API commands.
            elif cmd == BOT_OPTIONS['prefix'] + 'spy':
                # Finds information about a tinychat room.
                if len(cmd_param) is 0:
                    self.send_undercover_msg(msg_sender, 'Missing room name.')
                else:
                    spy_info = tinychat.tinychat_api.spy_info(cmd_param)
                    if spy_info is None:
                        self.send_undercover_msg(msg_sender, 'The room is empty.')
                    elif spy_info == 'PW':
                        self.send_undercover_msg(msg_sender, 'The room is password protected.')
                    else:
                        self.send_undercover_msg(msg_sender, '*mods:* ' + spy_info['mod_count'] +
                                                 ' *Broadcasters:* ' + spy_info['broadcaster_count'] +
                                                 ' *Users:* ' + spy_info['total_count'])
                        if user_check.is_mod or user_check.has_power:
                            self.send_undercover_msg(msg_sender, '*' + spy_info['users'] + '*')

            elif cmd.lower() == BOT_OPTIONS['prefix'] + 'usrspy':
                # Finds information for a tinychat account.
                if len(cmd_param) is 0:
                    self.send_undercover_msg(msg_sender, 'Missing username to search for.')
                else:
                    tc_usr = tinychat.tinychat_api.tinychat_user_info(cmd_param)
                    if tc_usr is None:
                        self.send_undercover_msg(msg_sender, 'Could not find tinychat info for: ' + cmd_param)
                    else:
                        self.send_undercover_msg(msg_sender, 'ID: ' + tc_usr['tinychat_id'] + ', Last login: '******'last_activ'])

            # Other API commands.
            elif cmd == BOT_OPTIONS['prefix'] + 'urb':
                # Searches urbandictionary.
                if len(cmd_param) is 0:
                    self.send_bot_msg('Please specify something to look up.', self.is_client_mod)
                else:
                    urban = tiny_media.urbandictionary_search(cmd_param)
                    if urban is None:
                        self.send_bot_msg('Could not find a definition for: ' + cmd_param, self.is_client_mod)
                    else:
                        if len(urban) > 70:
                            urb_parts = str(urban).split('.')
                            self.send_bot_msg(urb_parts[0].strip(), self.is_client_mod)
                            self.send_bot_msg(urb_parts[1].strip(), self.is_client_mod)
                        else:
                            self.send_bot_msg(urban, self.is_client_mod)

            elif cmd == BOT_OPTIONS['prefix'] + 'wea':
                # Searches worldweatheronline.
                if len(cmd_param) is 0:
                    self.send_bot_msg('Please specify a city to search for.', self.is_client_mod)
                else:
                    weather = tiny_media.weather_search(cmd_param)
                    if weather is None:
                        self.send_bot_msg('Could not find weather data for: ' + cmd_param, self.is_client_mod)
                    else:
                        self.send_bot_msg(weather, self.is_client_mod)

            elif cmd == BOT_OPTIONS['prefix'] + 'ip':
                # Finds info about a IP.
                if len(cmd_param) is 0:
                    self.send_bot_msg('Please provide an IP address.', self.is_client_mod)
                else:
                    whois = tiny_media.whois(cmd_param)
                    if whois is None:
                        self.send_bot_msg('No info found for: ' + cmd_param, self.is_client_mod)
                    else:
                        self.send_bot_msg(whois)

            elif cmd == BOT_OPTIONS['prefix'] + 'cn':
                # Finds a Chuck Norris joke/quote.
                self.send_bot_msg(tiny_media.chuck_norris(), self.is_client_mod)

            elif cmd == BOT_OPTIONS['prefix'] + '8ball':
                # Magic eight ball.
                if len(cmd_param) is 0:
                    self.send_bot_msg('Question.', self.is_client_mod)
                else:
                    self.send_bot_msg('*8Ball* ' + eightball(), self.is_client_mod)

            #  Print command to console.
            tinychat.console_write([tinychat.COLOR['yellow'], msg_sender + ':' + cmd + ' ' + cmd_param, self.roomname])
        else:
            #  Print chat message to console.
            tinychat.console_write([tinychat.COLOR['green'], msg_sender + ':' + msg, self.roomname])
コード例 #3
0
    def private_message_handler(self, msg_sender, private_msg):
        """
        Custom private message commands.
        :param msg_sender: str the user sending the private message.
        :param private_msg: str the private message.
        :return:
        """
        user_check = self.find_user_info(msg_sender)
        priv_msg_parts = private_msg.split(' ')
        pm_cmd = priv_msg_parts[0].lower()
        pm_cmd_params = ' '.join(priv_msg_parts[1:])

        if pm_cmd == BOT_OPTIONS['prefix'] + 'opme':
            # Enables the user to control the client.
            if pm_cmd_params == BOT_OPTIONS['opme_key']:
                user_check.has_power = True
                self.send_private_bot_msg('You are now a bot controller.', msg_sender)
            else:
                self.send_private_bot_msg('Wrong key.', msg_sender)

        elif pm_cmd == BOT_OPTIONS['prefix'] + BOT_OPTIONS['op_another']:
            # Enable another user to control the client.
            if user_check.has_power:
                if len(pm_cmd_params) is 0:
                    self.send_private_bot_msg('Missing user name.', msg_sender)
                else:
                    op_user = self.find_user_info(pm_cmd_params)
                    if op_user is not None:
                        op_user.has_power = True
                        self.send_private_bot_msg(pm_cmd_params + ' is now a bot controller.', msg_sender)
                        # Send a PM to the user, alerting them that they now are a bot controller.
                        self.send_private_bot_msg('You are now a bot controller.', pm_cmd_params)
                    else:
                        self.send_private_bot_msg('No user named: ' + pm_cmd_params, msg_sender)

        elif pm_cmd == BOT_OPTIONS['prefix'] + BOT_OPTIONS['deop_another']:
            # Disable a user from controlling the client.
            if user_check.has_power:
                if len(pm_cmd_params) is 0:
                    self.send_private_bot_msg('Missing user name.', msg_sender)
                else:
                    op_user = self.find_user_info(pm_cmd_params)
                    if op_user is not None:
                        op_user.has_power = False
                        self.send_private_bot_msg('Removed bot controls from: ' + pm_cmd_params, msg_sender)
                    else:
                        self.send_private_bot_msg('No user named: ' + pm_cmd_params, msg_sender)

        elif pm_cmd == BOT_OPTIONS['prefix'] + 'opuser':
            # A mod enables a user to control the client.
            if user_check.is_mod:
                up_user = self.find_user_info(pm_cmd_params)
                if up_user is not None:
                    up_user.has_power = True
                    self.send_private_bot_msg(pm_cmd_params + ' now has privileges', msg_sender)
                else:
                    self.send_private_bot_msg('No user named: ' + pm_cmd_params, msg_sender)

        elif pm_cmd == BOT_OPTIONS['prefix'] + 'deopuser':
            # A mod disables a user from controlling the client.
            if user_check.is_mod:
                up_user = self.find_user_info(pm_cmd_params)
                if up_user is not None:
                    up_user.has_power = False
                    self.send_private_bot_msg('Removed privileges from: ' + pm_cmd_params, msg_sender)
                else:
                    self.send_private_bot_msg('No user named: ' + pm_cmd_params, msg_sender)

        elif pm_cmd == BOT_OPTIONS['prefix'] + 'nocam':
            # Toggles no broadcasting on/off
            if user_check.is_mod or user_check.has_power:
                if self.no_cam:
                    self.no_cam = False
                    self.send_private_bot_msg('*Broadcasting is allowed.*', msg_sender)
                else:
                    self.no_cam = True
                    self.send_private_bot_msg('*Broadcasting is NOT allowed.*', msg_sender)

        elif pm_cmd == BOT_OPTIONS['prefix'] + 'banall':
            pass

        # Print to console.
        tinychat.console_write([tinychat.COLOR['white'], 'Private message from ' + msg_sender + ':' + private_msg, self.roomname])
コード例 #4
0
 def on_avon(self, uid, name):
     if self.no_cam:
         self.send_close_user_msg(name)
     else:
         tinychat.console_write([tinychat.COLOR['cyan'], name + ':' + uid + ' is broadcasting.', self.roomname])