Commit 1c50b2ad authored by Jyrki's avatar Jyrki 🐾

fixed mumble-ruby's muted? and deafened? methods

parent bacfadfe
require_relative './mumble-ruby/client'
\ No newline at end of file
require_relative './mumble-ruby/client'
require_relative './mumble-ruby/user'
\ No newline at end of file
......@@ -12,7 +12,7 @@ module Mumble
# @param default_channel [String] The channel to join if there are no other users on the Mumble server.
def join_channel_with_most_users(default_channel = APP_CONFIG['mumble']['channel'])
# this is probably the best one-liner I've ever written in Ruby so far; and it even works! --nilsding
chans_with_users = users.values.map{ |x| channels[x.channel_id] unless x == me || x.self_mute || x.self_deaf }.compact.inject(Hash.new(0)){ |h, c| h[c] += 1; h }.sort_by{ |_k, v| v }.reverse
chans_with_users = users.values.map{ |x| channels[x.channel_id] unless x == me || x.muted? || x.deafened? }.compact.inject(Hash.new(0)){ |h, c| h[c] += 1; h }.sort_by{ |_k, v| v }.reverse
if chans_with_users.empty?
writeln! "[Mumble] Looks like we're alone, joining channel \033[1m#{default_channel}\033[0m."
join_channel default_channel
......
module Mumble
class User < Model
# ./lib/mumble-ruby/user.rb:35
def muted?
!!data['suppress'] || !!data['mute'] || !!self_mute
end
# ./lib/mumble-ruby/user.rb:39
def deafened?
!!data['deaf'] || !!self_deaf
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment