em-ruby-irc 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ require 'logger'
2
2
 
3
3
  module IRC
4
4
  class Connection < EventMachine::Connection
5
- attr_reader :realname, :username, :channels, :users, :name, :command_char
5
+ attr_reader :realname, :username, :channels, :users, :name, :command_char, :noidprefix
6
6
  attr_accessor :irc_handlers, :channels, :users, :setup, :nickname
7
7
 
8
8
  def initialize(args)
@@ -13,6 +13,7 @@ module IRC
13
13
  @realname = @setup.config["realname"]
14
14
  @username = @setup.config["username"]
15
15
  @command_char = @setup.config["command_char"]
16
+ @noidprefix = @setup.config["noidprefix"]
16
17
  @channels = Array.new
17
18
  @users = Array.new
18
19
  @irc_handlers = Hash.new()
@@ -40,6 +41,9 @@ module IRC
40
41
  logger.debug("Firing connection_completed")
41
42
  send_to_server "NICK #{@nickname}"
42
43
  send_to_server "USER #{@username} 8 * :#{@realname}"
44
+ if noidprefix
45
+ send_to_server "CAPAB IDENTIFY-MSG"
46
+ end
43
47
  end
44
48
 
45
49
  def receive_data(data)
@@ -13,10 +13,11 @@ end
13
13
  # This is a lookup class for IRC event name mapping
14
14
  module IRC
15
15
  class Event
16
- attr_reader :hostmask, :message, :event_type, :from, :channel, :target, :mode, :stats
17
- attr_accessor :connection
16
+ attr_reader :hostmask, :event_type, :from, :channel, :target, :mode, :stats
17
+ attr_accessor :connection, :message, :logged_in
18
18
  def initialize(data, connection)
19
19
  @connection = connection
20
+ @logged_in = false
20
21
  data.chomp!
21
22
  data.sub!(/^:/, '')
22
23
  mess_parts = data.split(':', 2);
@@ -1,8 +1,7 @@
1
1
  module IRC
2
2
  class User
3
3
  attr_reader :name
4
- attr_accessor :hostmask, :user_data
5
- attr_writer :logged_in
4
+ attr_accessor :hostmask, :user_data, :logged_in
6
5
 
7
6
  def initialize(name, hostmask=nil)
8
7
  @name = name
@@ -36,8 +36,11 @@ module IRC
36
36
  connection.channels.delete(channel) unless channel.nil?
37
37
  end
38
38
 
39
- #Creates the user in the channel userlist (IRC::Channel#users) and then returns the user
40
- def self.channel_user(connection, channel_name, user_name, hostmask=nil)
39
+ #Get or Create the user in the channel userlist from an event (IRC::Channel#users) and then returns the user
40
+ def self.get_channel_user_from_event(event, username=nil, hostmask=nil)
41
+ connection = event.connection
42
+ channel_name = event.channel
43
+ user_name = (username.nil? ? event.from : username)
41
44
  return false if channel_name.nil? or user_name.nil?
42
45
  user_name = sanitize_nickname(user_name)
43
46
  channel_name = channel_name.downcase.chomp
@@ -50,15 +53,6 @@ module IRC
50
53
  return user
51
54
  end
52
55
 
53
- #Returns a user from an event.
54
- def self.get_channel_user_from_event(event, user=nil)
55
- if user.nil?
56
- channel_user(event.connection, event.channel, event.from)
57
- else
58
- channel_user(event.connection, event.channel, user)
59
- end
60
- end
61
-
62
56
  #Creates the user in the global userlist (IRC::Connection#users) and then returns the user
63
57
  def self.global_user(connection, user_name, hostmask=nil)
64
58
  user_name = sanitize_nickname(user_name)
data/lib/em-ruby-irc.rb CHANGED
@@ -10,6 +10,6 @@ require File.dirname(__FILE__) + '/em-ruby-irc/IRC-Utils.rb'
10
10
  require File.dirname(__FILE__) + '/em-ruby-irc/default-handlers.rb'
11
11
 
12
12
  module EMIRC
13
- VERSION = '0.0.4'
13
+ VERSION = '0.0.5'
14
14
  end
15
15
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-ruby-irc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Stolz