class Object

Monkey patching Object like it's the golden old days

Constants

ALLOWED_MESSAGES_LIST
COMMANDS_HELP
EEZEE_PREFIX
LOG_FILE

Public Instance Methods

NeuralNetwork() click to toggle source
# File managables/services/chat-bot-integrations/chatbot.rb, line 125
def NeuralNetwork()
  NeuralNetwork.new
end
error_catching_restart_loop() click to toggle source
# File managables/services/livestream-interactive/Twitch.Tv/twitch_zircon.rb, line 103
def error_catching_restart_loop
  start()
rescue => e
  error_catching_restart_loop()
  LOG_FILE.write(e.message)
end
optional_prefix(prefix, message) click to toggle source

class Object

def ===(method, *args, &block)

TODO: also alllow Module === object => true if Module::Class === object => true

end

end

# File managables/services/chat-bot-integrations/chatbot.rb, line 21
def optional_prefix(prefix, message)
  [prefix + message, message]
end
recursive_find(method_name, &find_condition_block) click to toggle source
# File managables/programs/game_aided_manufacturing/gam.rb, line 10
def recursive_find(method_name, &find_condition_block)
  if find_condition_block.call(self)
    return self
  end

  if self.respond_to?(method_name)
    enumerable = self.public_send(method_name)
  elsif self.respond_to?(:each)
    enumerable = self.each
  else
    return nil
  end

  enumerable.each do |item|
    result = item.recursive_find(method_name, &find_condition_block)

    if not result.nil?
      return result
    end
  end

  return nil
end
start() click to toggle source
# File managables/services/livestream-interactive/Twitch.Tv/twitch_zircon.rb, line 26
def start
  client = Zircon.new(
    server: 'irc.twitch.tv',
    port: '6667',
    channel: '#lemonandroid',
    username: 'lemonandroid',
    password: ENV["TWITCH_OAUTH_TOKEN"]
  )

  removed_colors = [:black, :white, :light_black, :light_white]
  colors = String.colors - removed_colors

  client.on_message do |message|
    puts ">>> #{message.from}: #{message.body}".colorize(colors.sample)
    LOG_FILE.write(message.body.to_s + "\n")


    if message.body.to_s =~ /!commands/
      client.privmsg("#lemonandroid", "https://twitter.com/LemonAndroid/status/1128262053880377345")
    end

    if message.body.to_s =~ /hack/
      `cliclick m:100,100`
    end

    if message.body.to_s =~ /open gam/
      `ruby /Users/lemonandroid/one/game/ruby/runnable.rb &`
    end

    if message.body.to_s =~ /bundle install/
      `cd /Users/lemonandroid/one/game/ruby && bundle install &`
    end

    if message.body.to_s =~ /move plane/
      `
        osascript -e 'tell application "System Events" to tell process "ruby"
          set frontmost to true

          key down "a"
          delay 1
          key up "a"
        end tell'
      `
    end

    if message.body.to_s =~ /([a-d])/
      client.privmsg("#lemonandroid", "Logged #{$1} in")

      `osascript -e 'tell application \"System Events\"  to tell process \"Google Chrome\"
        set frontmost to true
        keystroke \"#{$1}\"
      end tell'`
    end

    if message.body.to_s =~ /key press (\w)(?:\s*(\d+)x)?/
      if $2
        `osascript -e 'tell application \"System Events\"  to tell process "ruby"
          set frontmost to true

          repeat #{$2} times
            keystroke \"#{$1}\"
          end repeat
        end tell'`
      else
        `osascript -e 'tell application \"System Events\"  to tell process "ruby"
          set frontmost to true

          keystroke \"#{$1}\"
        end tell'`
      end
    end
  end

  client.run!
end