Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 5ac5f90099c09c1003719863c1c68d2f8a2a9872
  • master par défaut protégée
  • rust-playlist-sync
  • rust
  • fix-qt-deprecated-qvariant-type
  • fix-mpris-qtwindow-race-condition
  • rust-appimage-wayland
  • windows-build-rebased
  • v2.5 protégée
  • v2.4 protégée
  • v2.3-1 protégée
  • v2.3 protégée
  • v2.2 protégée
  • v2.1 protégée
  • v2.0 protégée
  • v1.8-3 protégée
  • v1.8-2 protégée
  • v1.8-1 protégée
  • v1.8 protégée
  • v1.7 protégée
  • v1.6 protégée
  • v1.5 protégée
  • v1.4 protégée
  • v1.3 protégée
  • v1.2 protégée
  • v1.1 protégée
  • v1.0 protégée
27 résultats

server.c

Blame
  • playbot.rb 1,68 Kio
    require 'rubygems'
    require 'net/yail/irc_bot'
    
    require 'site_plugin'
    
    #
    # Add plugins folder to LOAD_PATH and subsequently require all plugins.
    #
    dir = '../plugins'
    $LOAD_PATH << dir
    Dir[File.join(dir, '*.rb')].each {|file| require File.basename(file) }
    
    class PlayBot < IRCBot
    	BOTNAME = 'PlayBot'
    
    	public
    	# Start a new instance
    	#
    	# Options:
    	# * <tt>:address</tt>: irc server
    	# * <tt>:port</tt>: port number, default to 6667
    	# * <tt>:nicknames</tt>: array of nicknames to cycle through
    	# * <tt>:nick_passwd</tt>: password for the first nick of :nicknames
    	# 	if we are not connected with this nick, we will use ghost and take this nick
    	# * <tt>:channels</tt>: the channels we are going to connect to
    	# * <tt>:admin</tt>: the nick of the user who can command the bot
    	def initialize(options = {})
    		@admin = options.delete(:admin)
    		raise "You must provide an admin !" if !@admin
    
    		if options[:nick_passwd]
    			@nick = options[:nicknames].first
    			@nick_paswd = options.delete[:nick_passwd]
    		end
    
    		options[:username] = BOTNAME
    		options[:realname] = BOTNAME
    
            super(options)
    		self.connect_socket
    		self.start_listening
    	end
    
    	# This metod is called by IRCBot#connect_socket
    	def add_custom_handlers()
    		@irc.hearing_welcome   self.method(:_in_welcome)
    		@irc.on_msg       self.method(:_in_msg)
    	end
    
    	private
    	# Welcome event handler
    	#
    	# We use it to identify us against NickServ
    	def _in_welcome(event)
    		return if !@nick
    
    		if self.bot_name != @nick
    			msg('NickServ', "ghost #{nick} #{nick_passwd}")
    			sleep 30
    			nick @nick
    		end
    
    		msg('NickServ', "identify #{nick_passwd}")
    	end
    
        def _in_msg(event)
            # we don't care of private messages
            return if event.pm?
        end
    end