<commit_before># a pluginbot plugin

class Mpd < Plugin
    
    def init(init)
        @bot = init
        #init default template
        @template_if_comment_enabled = @bot[:mpd_template_comment_enabled]
        @template_if_comment_disabled = @bot[:mpd_template_comment_disabled]
        @template_if_comment_enabled = "<b>Artist: </b>%s<br /><b>Title: </b>%s<br /><b>Album: </b>%s<br /><br /><b>Write %shelp to me, to get a list of my commands!</b>" if @template_if_comment_enabled == nil
        @template_if_comment_disabled = "<b>Artist: </b>DISABLED<br /><b>Title: </b>DISABLED<br /><b>Album: </b>DISABLED<br /><br /><b>Write %shelp to me, to get a list of my commands!</b>" if @template_if_comment_disabled == nil

        if ( @bot[:messages] != nil ) && ( @bot[:mpd] == nil ) then
            @bot[:mpd] = MPD.new @bot[:mpd_host], @bot[:mpd_port].to_i

            @bot[:mpd].on :volume do |volume|
                @bot[:messages].sendmessage("Volume was set to: #{volume}%." , 0x01)
            end

            @bot[:mpd].on :error do |error|
                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "<span style='color:red;font-weight:bold;>An error occured: #{error}.</span>") 
            end

            @bot[:mpd].on :updating_db do |jobid|
                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "I am running a database update just now ... new songs :)<br />My job id is: #{jobid}.") if (@bot[:chan_notify] & 0x02) != 0
            end

            @bot[:mpd].on :random do |random|
                if random
                    random = "On"
                else
                    random = "Off"
                end
                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Random mode is now: #{random}.") if (@bot[:chan_notify] & 0x04) != 0
            end

            @bot[:mpd].on :state  do |state|
                if @bot[:chan_notify] & 0x80 != 0 then
                    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Music paused.") if  state == :pause 
                    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Music stopped.") if state == :stop  
                    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Music start playing.") if state == :play 
                end
            end

            @bot[:mpd].on :single do |single|
                if single
                    single = "On"
                else
                    single = "Off"
                end
                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Single mode is now: #{single}.") if (@bot[:chan_notify] & 0x08) != 0
            end

            @bot[:mpd].on :consume do |consume|
                if consume
                    consume = "On"
                else
                    consume = "Off"
                end

                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Consume mode is now: #{consume}.") if (@bot[:chan_notify] & 0x10) != 0
            end

            @bot[:mpd].on :xfade do |xfade|
                if xfade.to_i == 0
                    xfade = "Off"
                    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Crossfade is now: #{xfade}.") if (@bot[:chan_notify] & 0x20) != 0
                else
                    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Crossfade time (in seconds) is now: #{xfade}.") if (@bot[:chan_notify] & 0x20) != 0 
                end
            end

            @bot[:mpd].on :repeat do |repeat|
                if repeat
                    repeat = "On"
                else
                    repeat = "Off"
                end
                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Repeat mode is now: #{repeat}.") if (@bot[:chan_notify] & 0x40) != 0
            end

            @bot[:mpd].on :song do |current|
                if not current.nil? #Would crash if playlist was empty.
                    if @bot[:use_comment_for_status_display] == true && @bot[:set_comment_available] == true
                        begin
                            if File.exist?("../music/download/"+current.title.to_s+".jpg")
                                image = @bot[:cli].get_imgmsg("../music/download/"+current.title+".jpg")
                            else
                                image = @bot[:logo]
                            end
                            output = "<br />" + @template_if_comment_enabled % [current.artist, current.title, current.album,@bot[:controlstring]]
                            @bot[:cli].set_comment(image+output)
                        rescue NoMethodError
                            if @bot[:debug]
                                puts "#{$!}"
                            end
                        end
                    else
                        #if current.artist.nil? && current.title.nil? && current.album.nil?
                        #    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "#{current.file}") if @bot[:chan_notify] && 0x80
                        #else
                        #    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "#{current.artist} - #{current.title} (#{current.album})") if (@bot[:chan_notify] && 0x80) != 0
                        #end
                    end
                end
            end
<commit_msg>fix 'titlepicture not viewed'<commit_after># a pluginbot plugin

class Mpd < Plugin
    
    def init(init)
        @bot = init
        #init default template
        @template_if_comment_enabled = @bot[:mpd_template_comment_enabled]
        @template_if_comment_disabled = @bot[:mpd_template_comment_disabled]
        @template_if_comment_enabled = "<b>Artist: </b>%s<br /><b>Title: </b>%s<br /><b>Album: </b>%s<br /><br /><b>Write %shelp to me, to get a list of my commands!</b>" if @template_if_comment_enabled == nil
        @template_if_comment_disabled = "<b>Artist: </b>DISABLED<br /><b>Title: </b>DISABLED<br /><b>Album: </b>DISABLED<br /><br /><b>Write %shelp to me, to get a list of my commands!</b>" if @template_if_comment_disabled == nil

        if ( @bot[:messages] != nil ) && ( @bot[:mpd] == nil ) then
            @bot[:mpd] = MPD.new @bot[:mpd_host], @bot[:mpd_port].to_i

            @bot[:mpd].on :volume do |volume|
                @bot[:messages].sendmessage("Volume was set to: #{volume}%." , 0x01)
            end

            @bot[:mpd].on :error do |error|
                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "<span style='color:red;font-weight:bold;>An error occured: #{error}.</span>") 
            end

            @bot[:mpd].on :updating_db do |jobid|
                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "I am running a database update just now ... new songs :)<br />My job id is: #{jobid}.") if (@bot[:chan_notify] & 0x02) != 0
            end

            @bot[:mpd].on :random do |random|
                if random
                    random = "On"
                else
                    random = "Off"
                end
                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Random mode is now: #{random}.") if (@bot[:chan_notify] & 0x04) != 0
            end

            @bot[:mpd].on :state  do |state|
                if @bot[:chan_notify] & 0x80 != 0 then
                    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Music paused.") if  state == :pause 
                    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Music stopped.") if state == :stop  
                    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Music start playing.") if state == :play 
                end
            end

            @bot[:mpd].on :single do |single|
                if single
                    single = "On"
                else
                    single = "Off"
                end
                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Single mode is now: #{single}.") if (@bot[:chan_notify] & 0x08) != 0
            end

            @bot[:mpd].on :consume do |consume|
                if consume
                    consume = "On"
                else
                    consume = "Off"
                end

                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Consume mode is now: #{consume}.") if (@bot[:chan_notify] & 0x10) != 0
            end

            @bot[:mpd].on :xfade do |xfade|
                if xfade.to_i == 0
                    xfade = "Off"
                    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Crossfade is now: #{xfade}.") if (@bot[:chan_notify] & 0x20) != 0
                else
                    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Crossfade time (in seconds) is now: #{xfade}.") if (@bot[:chan_notify] & 0x20) != 0 
                end
            end

            @bot[:mpd].on :repeat do |repeat|
                if repeat
                    repeat = "On"
                else
                    repeat = "Off"
                end
                @bot[:cli].text_channel(@bot[:cli].me.current_channel, "Repeat mode is now: #{repeat}.") if (@bot[:chan_notify] & 0x40) != 0
            end

            @bot[:mpd].on :song do |current|
                if not current.nil? #Would crash if playlist was empty.
                    if @bot[:use_comment_for_status_display] == true && @bot[:set_comment_available] == true
                        begin
                            if ( @bot[:youtube_downloadsubdir] != nil ) && ( @bot[:mpd_musicfoler] != nil )
                                if File.exist?(@bot[:mpd_musicfoler]+@bot[:youtube_downloadsubdir]+current.title.to_s+".jpg")
                                    image = @bot[:cli].get_imgmsg(@bot[:mpd_musicfoler]+@bot[:youtube_downloadsubdir]+current.title+".jpg")
                                else
                                    image = @bot[:logo]
                                end
                            else
                                 image = @bot[:logo]
                            end
                            output = "<br />" + @template_if_comment_enabled % [current.artist, current.title, current.album,@bot[:controlstring]]
                            @bot[:cli].set_comment(image+output)
                        rescue NoMethodError
                            if @bot[:debug]
                                puts "#{$!}"
                            end
                        end
                    else
                        #if current.artist.nil? && current.title.nil? && current.album.nil?
                        #    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "#{current.file}") if @bot[:chan_notify] && 0x80
                        #else
                        #    @bot[:cli].text_channel(@bot[:cli].me.current_channel, "#{current.artist} - #{current.title} (#{current.album})") if (@bot[:chan_notify] && 0x80) != 0
                        #end
                    end
                end
            end

{'fraction_non_alphanumeric': 0.14460784313725492, 'fraction_numerical': 0.007806826434277415, 'mean_word_length': 1.5222069597069596, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3657092', 'n_tokens_mistral': 3317, 'n_tokens_neox': 3094, 'n_words': 690}