Connects the bot to a server.

 @param [Boolean] plugins Automatically register plugins from
   `@config.plugins.plugins`?
 @return [void]
558204
def start(plugins = true)
      @reconnects = 0
      @plugins.register_plugins(@config.plugins.plugins) if plugins

      begin
        @user_list.each do |user|
          user.in_whois = false
          user.unsync_all
        end # reset state of all users

        @channel_list.each do |channel|
          channel.unsync_all
        end # reset state of all channels

        @channels = [] # reset list of channels the bot is in

        @join_handler.unregister if @join_handler
        @join_timer.stop if @join_timer

        join_lambda = lambda { @config.channels.each { |channel| Channel(channel).join }}

        if @config.delay_joins.is_a?(Symbol)
          @join_handler = join_handler = on(@config.delay_joins) {
            join_handler.unregister
            join_lambda.call
          }
        else
          @join_timer = Timer.new(self, interval: @config.delay_joins, shots: 1) {
            join_lambda.call
          }
        end

        @modes = []

        @loggers.info "Connecting to #{@config.server}:#{@config.port}"
        @irc = IRC.new(self)
        @irc.start

        if @config.reconnect && !@quitting
          # double the delay for each unsuccesful reconnection attempt
          if @last_connection_was_successful
            @reconnects = 0
            @last_connection_was_successful = false
          else
            @reconnects += 1
          end

          # Throttle reconnect attempts
          wait = 2**@reconnects
          wait = @config.max_reconnect_delay if wait > @config.max_reconnect_delay
          @loggers.info "Waiting #{wait} seconds before reconnecting"
          start_time = Time.now
          while !@quitting && (Time.now - start_time) < wait
            sleep 1
          end
        end
      end while @config.reconnect and not @quitting
    end
1023193
def check_plugins(config)
      if config.key?("plugins") && config["plugins"].is_a?(String)
        Jekyll.logger.error "Configuration Error:", "You specified the" \
          " `plugins` config in your configuration file as a string, please" \
          " use an array instead. If you wanted to set the directory of your" \
          " plugins, use the config key `plugins_dir` instead."
        raise Jekyll::Errors::InvalidConfigurationError,
              "'plugins' should not be a string, but was: " \
              "#{config["plugins"].inspect}. Use 'plugins_dir' instead."
      end
    end
731492
def plugins_map(type)
      @plugins_map ||= {}
      type = type.to_s
      @plugins_map[type] ||= Hash[
        @plugins[type].map do |plugin|
          [class2name(plugin), plugin]
        end
      ]
    end
395156
def main():
    '''  '''
    conn = symphony.Config('/etc/es-bot/es-bot.cfg')
    # connect to pod
    try:
        agent, pod, symphony_sid = conn.connect()
        print ('connected: %s' % (symphony_sid))
    except Exception as err:
        print ('failed to connect!: %s' % (err))
    # main loop
    msgFormat = 'MESSAGEML'
    message = '<messageML> hello world. </messageML>'
    # send message
    try:
        status_code, retstring = agent.send_message(symphony_sid, msgFormat, message)
        print ("%s: %s" % (status_code, retstring))
    except Exception as err:
        print (retstring, err)
725462
def method_missing(method_name, *args, &block)
      config = Loquacious::Configuration.for method_name, &block
      raise Adhearsion::Configuration::ConfigurationError.new "Invalid plugin #{method_name}" if config.nil?
      config
    end
960831
function(plugins) {
    _.each(
      plugins,
      _.bind(function(plugin) {
        if (!this.plugins[plugin]) {
          this.plugins[plugin] = this.requirePlugin(plugin);
        }
      }, this)
    );
  }
786161
def register_plugin(name, &block)
      plugin = Plugin.new
      plugin.instance_eval(&block)
      @plugins[name] = plugin
    end
130525
def activate(name):
    
    if name in plugins:
        plugins[name].activate()
    else:
        raise Exception("plugin {} not found".format(name))
240110
def register_events eves
        @_events ||= []
        case eves
        when Array
          @_events.push(*eves)
        when Symbol
          @_events << eves
        else
          raise ArgumentError "register_events: Don't know how to handle #{eves.class}"
        end
      end
1197358
async def _configure_plugins(self) -> None:
        
        logger.debug('Configuring plugins')
        funcs = [
            info['plugin'].configure(
                config=info['config'],
                session=self._session,
                router=self.app.router
            )
            for info in self._plugins.values()
        ]

        if funcs:
            await asyncio.gather(*funcs, loop=self._loop)
        logger.debug('Plugins configured')
256295
def connection
      if ::Fog::const_defined? @account[:service]
        service_mod = ::Fog::const_get @account[:service]
        provider_class = service_mod.send(:const_get, @account[:provider])
        @fog_service ||= provider_class.new(@account[:credentials])
      else
        provider_mod = ::Fog::const_get @account[:provider]
        service_class = provider_mod.send(:const_get, @account[:service])
        @fog_service ||= service_class.new(@account[:credentials])
      end
    end
781609
def __setup_connection(self):
            
        if self.payload != None and type(self.payload) is dict and 'settings' in self.payload:
            config.plugin_client_settings = self.payload['settings']
        config.offline = self.args.offline
        config.connection = PluginConnection(
            client=self.args.client or 'SUBLIME_TEXT_3',
            ui=self.args.ui_switch,
            args=self.args,
            params=self.payload,
            operation=self.operation,
            verbose=self.args.verbose)
        config.project = MavensMateProject(params=self.payload,ui=self.args.ui_switch)
        config.sfdc_client = config.project.sfdc_client
38877
def connect!
      # Keep existing connections
      return unless @backend.nil?
      @backend = train_connection.connection
      @backend.wait_until_ready

      # When the testing function `mock_instance` is used, it will set
      # this instance variable to false and handle this function call
      # after the platform data is mocked; this will allow binding
      # of mixin functions based on the mocked platform.
      mix_in_target_platform! unless @mocked_connection
    rescue Train::UserError => e
      raise ConnectionFailure.new(e, config)
    rescue Train::Error => e
      # These are typically wrapper errors for other problems,
      # so we'll prefer to use e.cause over e if available.
      raise ConnectionFailure.new(e.cause || e, config)
    end
234906
def start

      # prepare config
      config = {}
      begin
        config = YAML::load_file(CONFIG_FILE)
      rescue Exception => e
        load 'lib/cogbot/setup.rb'
        config['main'] = Cogbot::Setup.init
      end

      # prepare daemon
      Daemons.daemonize(
        :app_name => 'cogbot',
        :dir_mode => :normal,
        :log_dir => LOG_DIR,
        :log_output => true,
        :dir => CONFIG_DIR
      )

      # checkout plugins
      plugins = []
      config['main']['plugins'].each do |p|
        if File.exists?(File.join(ROOT_DIR, 'plugins', "#{p}.rb"))
          require File.join(ROOT_DIR, 'plugins', p)
          plugins.push Cinch::Plugins.const_get(p.camelize)
        end
      end

      # create bot
      bot = Cinch::Bot.new do
        configure do |c|
          c.server = config['main']['server']
          c.ssl.use = ( config['main']['ssl'] == 'true' )
          c.nick = config['main']['nick']
          c.user = config['main']['nick']
          c.realname = config['main']['nick']
          c.channels = config['main']['channels']
          c.sasl.username = config['main']['sasl_user']
          c.sasl.password = config['main']['sasl_pass']
          c.options = { 'cogconf' => config }
          c.plugins.prefix = config['main']['prefix']
          c.plugins.plugins = plugins
        end
        on :message, 'hi' do |m|
          m.reply "Hello, #{m.user.nick}"
        end
      end
      bot.loggers.debug(plugins.inspect)

      Signal.trap('TERM') { EM.stop }

      EM.run do
        EM.defer { bot.start }
        if config['server']
          EM.add_timer(3) do
            EM.start_server(
              config['server']['ip'],
              config['server']['port'],
              Server,
              bot
            )
          end
        end
      end

      bot.quit
    end
566545
def plugin_after_dispatch(env, response)
      new_response = response

      self.plugins.each do |plugin|
        if plugin.respond_to? :after_dispatch
          new_response = plugin.send(:after_dispatch, self, env, response)
        end
      end

      new_response
    end
211298
def register(*args, &block)
      h = Unobservable.handler_for(*args, &block)
      @handlers << h
      return h
    end
457148
function plugin(plugins) {
      var z, method, conf;
      for(z in plugins) {
        if(typeof plugins[z] === 'function') {
          method = plugins[z];
        }else{
          method = plugins[z].plugin;
          conf = plugins[z].conf;
        }
        if(opts.field && typeof method[opts.field] === 'function') {
          method = method[opts.field];
        }
        method.call(proto, conf);
      }
      return main;
    }