ratchet 0.3.0
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.
- data/gem_bin/ratchet +23 -0
- data/lib/ratchet.rb +613 -0
- data/lib/ratchet/aliases.rb +106 -0
- data/lib/ratchet/bufferparser.rb +409 -0
- data/lib/ratchet/commandbuffer.rb +66 -0
- data/lib/ratchet/commandparser.rb +668 -0
- data/lib/ratchet/configuration.rb +278 -0
- data/lib/ratchet/connections.rb +403 -0
- data/lib/ratchet/constants.rb +111 -0
- data/lib/ratchet/contrib/instance_exec.rb +21 -0
- data/lib/ratchet/eventparser.rb +486 -0
- data/lib/ratchet/gtk/bufferlistview.rb +514 -0
- data/lib/ratchet/gtk/bufferview.rb +167 -0
- data/lib/ratchet/gtk/configwindow.rb +229 -0
- data/lib/ratchet/gtk/connectionwindow.rb +218 -0
- data/lib/ratchet/gtk/keybinding.rb +356 -0
- data/lib/ratchet/gtk/linkwindow.rb +137 -0
- data/lib/ratchet/gtk/mainwindow.rb +504 -0
- data/lib/ratchet/gtk/networkpresenceconf.rb +567 -0
- data/lib/ratchet/gtk/pluginconfig.rb +94 -0
- data/lib/ratchet/gtk/pluginwindow.rb +146 -0
- data/lib/ratchet/gtk/userlistview.rb +161 -0
- data/lib/ratchet/help.rb +64 -0
- data/lib/ratchet/items.rb +271 -0
- data/lib/ratchet/lines.rb +63 -0
- data/lib/ratchet/networks.rb +652 -0
- data/lib/ratchet/plugins.rb +616 -0
- data/lib/ratchet/queue.rb +47 -0
- data/lib/ratchet/ratchet-version.rb +21 -0
- data/lib/ratchet/replies.rb +134 -0
- data/lib/ratchet/replyparser.rb +441 -0
- data/lib/ratchet/tabcomplete.rb +98 -0
- data/lib/ratchet/users.rb +237 -0
- data/lib/ratchet/utils.rb +178 -0
- data/share/defaults.yaml +169 -0
- data/share/glade/config.glade +2634 -0
- data/share/glade/connect.glade +950 -0
- data/share/glade/keybindings.glade +109 -0
- data/share/glade/linkwindow.glade +188 -0
- data/share/glade/mainwindow.glade +335 -0
- data/share/glade/network-presences.glade +1373 -0
- data/share/glade/pluginconf.glade +97 -0
- data/share/glade/plugins.glade +360 -0
- data/share/plugins/colorewrite.rb +193 -0
- data/share/plugins/highlighter.rb +115 -0
- data/share/plugins/mpdplay.rb +123 -0
- data/share/plugins/numberswitcher.rb +30 -0
- data/share/plugins/sysinfo.rb +82 -0
- metadata +96 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
This file is part of the Ratchet project, a client for Icecap.
|
|
3
|
+
Copyright (C) 2005-6 Andrew Thompson
|
|
4
|
+
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU General Public License as published by
|
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License
|
|
16
|
+
along with this program; if not, write to the Free Software
|
|
17
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
+
=end
|
|
19
|
+
|
|
20
|
+
#### constants.rb ####
|
|
21
|
+
# Defines some constants
|
|
22
|
+
####
|
|
23
|
+
|
|
24
|
+
#TODO: clean these up a bit
|
|
25
|
+
|
|
26
|
+
module Ratchet
|
|
27
|
+
#define parameters
|
|
28
|
+
PRESENCE = :presence
|
|
29
|
+
MYPRESENCE = :mypresence
|
|
30
|
+
NETWORK = :network
|
|
31
|
+
MSG = :msg
|
|
32
|
+
MSG_XHTML = :msg_xhtml
|
|
33
|
+
ADDRESS = :address
|
|
34
|
+
ERR = :err
|
|
35
|
+
TOPIC = :topic
|
|
36
|
+
TOPIC_SET_BY = :topic_set_by
|
|
37
|
+
TOPIC_TIMESTAMP = :topic_timestamp
|
|
38
|
+
INIT = :init
|
|
39
|
+
DEINIT = :deinit
|
|
40
|
+
OWN = :own
|
|
41
|
+
SOURCE_PRESENCE = :source_presence
|
|
42
|
+
ADD = :add
|
|
43
|
+
REMOVE = :remove
|
|
44
|
+
TYPE = :type
|
|
45
|
+
TIME = :time
|
|
46
|
+
CHANNEL = :channel
|
|
47
|
+
REASON = :reason
|
|
48
|
+
IRC_MODE = :irc_mode
|
|
49
|
+
DATA = :data
|
|
50
|
+
INITIAL_PRESENCES_ADDED = :initial_presences_added
|
|
51
|
+
IDLE_STARTED = :idle_started
|
|
52
|
+
IP = :ip
|
|
53
|
+
ERROR = :error
|
|
54
|
+
PORT = :port
|
|
55
|
+
NO_AUTOREPLY = :no_autoreply
|
|
56
|
+
NAME = :name
|
|
57
|
+
STATUS = :status
|
|
58
|
+
MODE = :mode
|
|
59
|
+
PROTOCOL = :protocol
|
|
60
|
+
REAL_NAME = :real_name
|
|
61
|
+
EVENT = :event
|
|
62
|
+
CHARSET = :charset
|
|
63
|
+
HOST = :host
|
|
64
|
+
AUTOCONNECT = :autoconnect
|
|
65
|
+
ID = :id
|
|
66
|
+
JOINED = :joined
|
|
67
|
+
CONNECTED = :connected
|
|
68
|
+
|
|
69
|
+
#define my own parameters
|
|
70
|
+
EVENT_TYPE = :event_type
|
|
71
|
+
REPLY_STATUS = :reply_status
|
|
72
|
+
|
|
73
|
+
#define some status constants
|
|
74
|
+
INACTIVE = 0
|
|
75
|
+
NEWDATA = 1
|
|
76
|
+
NEWMSG = 2
|
|
77
|
+
HIGHLIGHT = 3
|
|
78
|
+
ACTIVE = 0
|
|
79
|
+
|
|
80
|
+
#define buffer positions
|
|
81
|
+
BUFFER_START = 0
|
|
82
|
+
BUFFER_END = 1
|
|
83
|
+
|
|
84
|
+
#define some event constants
|
|
85
|
+
EVENT_MESSAGE = 'message'
|
|
86
|
+
EVENT_USERMESSAGE = 'usermessage'
|
|
87
|
+
EVENT_JOIN = 'join'
|
|
88
|
+
EVENT_USERJOIN = 'userjoin'
|
|
89
|
+
EVENT_PART = 'part'
|
|
90
|
+
EVENT_USERPART = 'userpart'
|
|
91
|
+
EVENT_ERROR = 'error'
|
|
92
|
+
EVENT_NOTICE = 'notice'
|
|
93
|
+
EVENT_TOPIC = 'topic'
|
|
94
|
+
EVENT_MODECHANGE = 'modechange'
|
|
95
|
+
EVENT_NICKCHANGE = 'nickchange'
|
|
96
|
+
EVENT_USERNICKCHANGE = 'usernickchange'
|
|
97
|
+
#EVENT_CTCP = 'ctcp'
|
|
98
|
+
|
|
99
|
+
TAGMAP = {'color'=>'foreground', 'font-weight' => 'weight', 'font-style' => 'style', 'background-color' => 'background'}
|
|
100
|
+
|
|
101
|
+
#this is probably incomplete and buggy, but I don't care!
|
|
102
|
+
HYPERLINKREGEXP = %r{(?:\b|^)((((http|ftp|irc|https)://|)([\w\-]+\.)+[a-zA-Z]{2,4}|(\d{1,3}\.){3}(\d{1,3}))(\:[0-9]+|)([.\/]{1}[^\s\n\(\)\[\]\r\<\>]+|\b|$))}
|
|
103
|
+
|
|
104
|
+
SENSITIVE = Proc.new {|x, y| x[0].name <=> y[0].name}
|
|
105
|
+
SENSITIVE_NOHASH = Proc.new {|x, y| x[0].name.sub('#', '') <=> y[0].name.sub('#', '')}
|
|
106
|
+
INSENSITIVE = Proc.new {|x, y| x[0].name.downcase <=> y[0].name.downcase}
|
|
107
|
+
INSENSITIVE_NOHASH = Proc.new {|x, y| x[0].name.downcase.sub('#', '') <=> y[0].name.downcase.sub('#', '')}
|
|
108
|
+
|
|
109
|
+
HIERARCHICAL = 0
|
|
110
|
+
FLAT = 1
|
|
111
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#stolen from http://eigenclass.org/hiki.rb?instance_exec
|
|
2
|
+
|
|
3
|
+
class Object
|
|
4
|
+
module InstanceExecHelper; end
|
|
5
|
+
include InstanceExecHelper
|
|
6
|
+
def instance_exec(*args, &block) # !> method redefined; discarding old instance_exec
|
|
7
|
+
mname = "__instance_exec_#{Thread.current.object_id.abs}_#{object_id.abs}"
|
|
8
|
+
InstanceExecHelper.module_eval{ define_method(mname, &block) }
|
|
9
|
+
begin
|
|
10
|
+
# puts args.inspect
|
|
11
|
+
ret = send(mname, *args)
|
|
12
|
+
# puts ret.inspect
|
|
13
|
+
ensure
|
|
14
|
+
InstanceExecHelper.module_eval{ undef_method(mname) } rescue nil
|
|
15
|
+
end
|
|
16
|
+
# puts ret.inspect
|
|
17
|
+
ret
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
# block = Proc.new {|x, y| [x, y]}
|
|
21
|
+
# puts instance_exec(self, 10, &block)
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
This file is part of the Ratchet project, a client for Icecap.
|
|
3
|
+
Copyright (C) 2005-6 Andrew Thompson
|
|
4
|
+
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU General Public License as published by
|
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License
|
|
16
|
+
along with this program; if not, write to the Free Software
|
|
17
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
+
=end
|
|
19
|
+
|
|
20
|
+
#### eventparser.rb ####
|
|
21
|
+
# similar to commandparser, dispatches events to their correct function
|
|
22
|
+
####
|
|
23
|
+
|
|
24
|
+
#TODO: this needs extensive cleanup and/or rewriting, this file has severe bitrot
|
|
25
|
+
|
|
26
|
+
module Ratchet
|
|
27
|
+
module EventParser
|
|
28
|
+
#handle normal output from irssi2
|
|
29
|
+
def event_parse(event)
|
|
30
|
+
#trap for events that refer to a channel that does not exist
|
|
31
|
+
#~ if event[NETWORK] and event[MYPRESENCE]
|
|
32
|
+
#~ if !@serverlist[event[NETWORK], event[MYPRESENCE]]
|
|
33
|
+
#~ else
|
|
34
|
+
#~ network = @serverlist[event[NETWORK], event[MYPRESENCE]]
|
|
35
|
+
#~ end
|
|
36
|
+
|
|
37
|
+
#~ if event[CHANNEL] and network
|
|
38
|
+
#~ if !network[event[CHANNEL]]
|
|
39
|
+
#~ else
|
|
40
|
+
#~ channel = @serverlist[event[NETWORK], event[MYPRESENCE]][event[CHANNEL]]
|
|
41
|
+
#~ end
|
|
42
|
+
#~ end
|
|
43
|
+
#~ end
|
|
44
|
+
|
|
45
|
+
target = find_buffer(event[NETWORK], event[MYPRESENCE], event[CHANNEL], event[PRESENCE])
|
|
46
|
+
#puts "#{[event[NETWORK], event[MYPRESENCE], event[CHANNEL], event[PRESENCE]].inspect} => #{target}"
|
|
47
|
+
|
|
48
|
+
begin
|
|
49
|
+
if self.respond_to?('event_'+event['event_type'])
|
|
50
|
+
res = callback('event_'+event['event_type'], event, target)
|
|
51
|
+
return if res === true
|
|
52
|
+
self.send('event_'+event['event_type'], *res)
|
|
53
|
+
end
|
|
54
|
+
#rescue any exceptions...
|
|
55
|
+
rescue =>exception
|
|
56
|
+
puts 'Error parsing event : '+$!
|
|
57
|
+
puts exception.backtrace
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#connecting to a server
|
|
62
|
+
def event_gateway_connecting(event, target)
|
|
63
|
+
if !target
|
|
64
|
+
target = add_buffer(event[NETWORK], event[MYPRESENCE])
|
|
65
|
+
elsif !target.connected?
|
|
66
|
+
puts 'network '+event[NETWORK]+' exists but is not connected, reconnecting'
|
|
67
|
+
#network = (event[NETWORK], event[MYPRESENCE])
|
|
68
|
+
target.reconnect
|
|
69
|
+
else
|
|
70
|
+
puts 'request to create already existing network, ignoring'
|
|
71
|
+
return
|
|
72
|
+
end
|
|
73
|
+
msg = "Connecting to "+event['ip']
|
|
74
|
+
msg += ":"+event[PORT] if event[PORT]
|
|
75
|
+
event['msg'] = msg
|
|
76
|
+
target.send_event(event, EVENT_NOTICE)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
#disconnected from a network
|
|
80
|
+
def event_gateway_disconnected(event, target)
|
|
81
|
+
if target
|
|
82
|
+
line = {'msg' => 'Disconnected from '+target.name}
|
|
83
|
+
target.send_user_event(line, EVENT_NOTICE)
|
|
84
|
+
#network.chats.each {|chat| chat.disconnect}
|
|
85
|
+
target.disconnect
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def event_gateway_logged_in(event, target)
|
|
90
|
+
return #unless target
|
|
91
|
+
target.loggedin = true
|
|
92
|
+
Thread.new do
|
|
93
|
+
target.bufferedcommands.each do |command|
|
|
94
|
+
puts 'sending command '+command+' to network '+target.name
|
|
95
|
+
command_parse(command, target)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def event_gateway_init(event, target)
|
|
101
|
+
if event[NETWORK] and event[HOST]
|
|
102
|
+
if @networks[event[NETWORK]]
|
|
103
|
+
if event[PORT]
|
|
104
|
+
@networks[event[NETWORK]].add_gateway(event[HOST], event[PORT])
|
|
105
|
+
else
|
|
106
|
+
@networks[event[NETWORK]].add_gateway(event[HOST])
|
|
107
|
+
end
|
|
108
|
+
else
|
|
109
|
+
puts 'unknown network '+event[NETWORK]
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def event_gateway_deinit(event, target)
|
|
115
|
+
if event[NETWORK] and event[HOST]
|
|
116
|
+
if @networks[event[NETWORK]]
|
|
117
|
+
#@networks[event[NETWORK]].add_gateway(event[HOST])
|
|
118
|
+
remove = nil
|
|
119
|
+
|
|
120
|
+
@networks[event[NETWORK]].gateways.list.each do |gw|
|
|
121
|
+
if event[HOST] == gw.host and event[PORT] == gw.port
|
|
122
|
+
remove = gw
|
|
123
|
+
break
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
@networks[event[NETWORK]].gateways.remove(remove)
|
|
128
|
+
else
|
|
129
|
+
puts 'unknown network '+event[NETWORK]
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def event_network_init(event, target)
|
|
135
|
+
@networks.add(event[NETWORK], event[PROTOCOL])
|
|
136
|
+
throw_message('Added '+event[PROTOCOL]+' server '+event[NETWORK])
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def event_network_set(event, target)
|
|
140
|
+
#TODO - update network settings here
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def event_local_presence_init(event, target)
|
|
144
|
+
@networks[event[NETWORK]].presences.add(event[MYPRESENCE])
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def event_local_presence_deinit(event, target)
|
|
148
|
+
ps = @networks[event[NETWORK]].presences[event[MYPRESENCE]]
|
|
149
|
+
if ps
|
|
150
|
+
@networks[event[NETWORK]].presences.remove(ps)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
#joined a channel
|
|
155
|
+
def event_channel_init(event, target)
|
|
156
|
+
return unless target
|
|
157
|
+
if !find_buffer(event[NETWORK], event[MYPRESENCE])
|
|
158
|
+
puts 'Error, non existant channel init event caught for non existant network, ignoring'
|
|
159
|
+
return
|
|
160
|
+
elsif find_buffer(event[NETWORK], event[MYPRESENCE], event[CHANNEL])
|
|
161
|
+
puts 'request to create already existing channel, ignoring'
|
|
162
|
+
return
|
|
163
|
+
else
|
|
164
|
+
puts 'channel added'
|
|
165
|
+
channel = add_buffer(event[NETWORK], event[MYPRESENCE], event[CHANNEL])
|
|
166
|
+
# reply = send_command("window#{rand(100)}", "window add;filter=&(network=#{event[NETWORK]})(mypresence=#{event[MYPRESENCE]})(channel=#{event[CHANNEL]})")
|
|
167
|
+
# reply.network = event[NETWORK]
|
|
168
|
+
# reply.presence = event[MYPRESENCE]
|
|
169
|
+
# reply.channel = event[CHANNEL]
|
|
170
|
+
channel.usersync = channel.eventsync = true
|
|
171
|
+
#send_command('events-'+network.name+channel.name, 'event get;end=*;limit=200;filter=&(channel='+channel.name+')(network='+network.name+')(presence='+network.presence+')(!(event=client_command_reply))')
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def event_channel_join(event, target)
|
|
176
|
+
puts 'channel join'
|
|
177
|
+
# puts "TARGET: #{target}"
|
|
178
|
+
#return unless target.respond_to? :join
|
|
179
|
+
#~ if !assign_window.find_network(event[NETWORK], event[MYPRESENCE])
|
|
180
|
+
#~ puts 'Error, non existant channel init event caught for non existant network, ignoring'
|
|
181
|
+
#~ return
|
|
182
|
+
#~ elsif channel = assign_window.buffers.add_channel(event[NETWORK], event[MYPRESENCE], event[CHANNEL]) and !channel.joined?
|
|
183
|
+
if !target and channel = add_buffer(event[NETWORK], event[MYPRESENCE], event[CHANNEL])
|
|
184
|
+
channel.join
|
|
185
|
+
send_command('events-'+channel.network.name+channel.name, 'event get;end=*;limit=200;filter=&(channel='+channel.name+')(network='+channel.network.name+')(mypresence='+channel.network.presence+')(!(|(event=client_command_reply)(init=*)(deinit=*)(raw=*)))(time>1)')
|
|
186
|
+
elsif target.respond_to? :join and !target.joined?
|
|
187
|
+
puts 'channel exists, but is not connected, reconnecting'
|
|
188
|
+
target.join
|
|
189
|
+
else
|
|
190
|
+
#puts channel.name, channel.connected
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
#notice from the server
|
|
195
|
+
def event_notice(event, target)
|
|
196
|
+
return unless target
|
|
197
|
+
target.send_event(event, EVENT_NOTICE)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
#you left the channel
|
|
201
|
+
def event_channel_presence_removed(event, target)
|
|
202
|
+
return unless target
|
|
203
|
+
if !event[DEINIT]
|
|
204
|
+
event[:type] ||= 'part' #defaults to part
|
|
205
|
+
# puts event.inspect
|
|
206
|
+
if event[PRESENCE] == target.username
|
|
207
|
+
target.send_event(event, EVENT_USERPART)
|
|
208
|
+
else
|
|
209
|
+
target.send_event(event, EVENT_PART)
|
|
210
|
+
end
|
|
211
|
+
target.users.remove(event[PRESENCE])#, false)
|
|
212
|
+
#@window.updateusercount
|
|
213
|
+
#channel.drawusers
|
|
214
|
+
else
|
|
215
|
+
#target.users.remove(event[PRESENCE])
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
#you left the channel
|
|
220
|
+
def event_channel_part(event, target)
|
|
221
|
+
return unless target
|
|
222
|
+
event[:type] ||= 'part'
|
|
223
|
+
target.send_event(event, EVENT_USERPART)
|
|
224
|
+
target.part
|
|
225
|
+
#@serverlist.renumber
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
#another user joined the channel
|
|
229
|
+
def event_channel_presence_added(event, target)
|
|
230
|
+
return unless target
|
|
231
|
+
if user = target.network.users[event[PRESENCE]]
|
|
232
|
+
if !event[INIT]
|
|
233
|
+
chuser = target.users.add(user)
|
|
234
|
+
if event[PRESENCE] == target.username
|
|
235
|
+
target.send_event(event, EVENT_USERJOIN)
|
|
236
|
+
else
|
|
237
|
+
target.send_event(event, EVENT_JOIN)
|
|
238
|
+
end
|
|
239
|
+
else
|
|
240
|
+
chuser = target.users.add(user)#, false)
|
|
241
|
+
end
|
|
242
|
+
if event[MODE]
|
|
243
|
+
chuser.mode=event[MODE]
|
|
244
|
+
# puts 'set '+chuser.name+'\'s status to '+event[MODE]
|
|
245
|
+
#~ if !event[INIT]
|
|
246
|
+
#~ channel.drawusers
|
|
247
|
+
#~ end
|
|
248
|
+
target.users.reorder(chuser)
|
|
249
|
+
end
|
|
250
|
+
else
|
|
251
|
+
puts 'unknown user '+event[PRESENCE]
|
|
252
|
+
send_command("usersync#{rand(100)}", "channel names;#{target.identifier_string}")
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
#a user has changed
|
|
257
|
+
def event_presence_changed(event, target)
|
|
258
|
+
target ||= find_buffer(event[NETWORK], event[MYPRESENCE])
|
|
259
|
+
return unless target
|
|
260
|
+
if event[NAME]
|
|
261
|
+
#network = find_buffer(event[NETWORK], event[MYPRESENCE])
|
|
262
|
+
if event[PRESENCE] == target.username
|
|
263
|
+
target.network.username = event[NAME]
|
|
264
|
+
#@window.get_username
|
|
265
|
+
#@window.show_username
|
|
266
|
+
end
|
|
267
|
+
pattern = @config['notice'].dup
|
|
268
|
+
|
|
269
|
+
user = target.network.users[event[PRESENCE]]
|
|
270
|
+
|
|
271
|
+
if user
|
|
272
|
+
# puts user.inspect
|
|
273
|
+
user.rename(event[NAME])
|
|
274
|
+
# puts user.inspect
|
|
275
|
+
@buffers.values.select{|x| x.network == target.network and x.network != x and x.users}.each do |channel|
|
|
276
|
+
if chuser = channel.users[user.name]
|
|
277
|
+
channel.users.reorder(chuser)
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
if event[NAME] == target.username
|
|
283
|
+
type = EVENT_USERNICKCHANGE
|
|
284
|
+
else
|
|
285
|
+
type = EVENT_NICKCHANGE
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
if type
|
|
289
|
+
@buffers.values.select{|x| x.network == target.network and x.network != x and x.users}.each do |c|
|
|
290
|
+
if c.users[event[NAME]]
|
|
291
|
+
c.send_event(event, type)
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
#TODO - handle chat renaming
|
|
297
|
+
#if event[PRESENCE] and chat = network.has_chat?(event[PRESENCE])
|
|
298
|
+
# chat.rename(event[NAME])
|
|
299
|
+
#end
|
|
300
|
+
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
if event[ADDRESS]
|
|
304
|
+
if user = target.network.users[event[PRESENCE]]
|
|
305
|
+
user.hostname = event[ADDRESS]
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
#a user has caught irssi2's attention
|
|
311
|
+
def event_presence_init(event, target)
|
|
312
|
+
target = find_buffer(event[NETWORK], event[MYPRESENCE])
|
|
313
|
+
return unless target
|
|
314
|
+
# puts "adding network presence #{event[PRESENCE]} to #{target.name}"
|
|
315
|
+
target.network.users.create(event[PRESENCE], event[ADDRESS])
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
#a user has left irssi2's attention
|
|
319
|
+
def event_presence_deinit(event, target)
|
|
320
|
+
target = find_buffer(event[NETWORK], event[MYPRESENCE])
|
|
321
|
+
return unless target
|
|
322
|
+
target.network.users.remove(event[PRESENCE])
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
#a message is recieved
|
|
326
|
+
def event_msg(event, target)
|
|
327
|
+
if target and event[PRESENCE]
|
|
328
|
+
user = target.network.users[event[PRESENCE]]
|
|
329
|
+
if user
|
|
330
|
+
user.lastspoke = event[TIME]
|
|
331
|
+
if !user.hostname
|
|
332
|
+
user.hostname = event[ADDRESS]
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
if !event[CHANNEL] and event[NO_AUTOREPLY]
|
|
338
|
+
target = find_buffer(event[NETWORK], event[MYPRESENCE])
|
|
339
|
+
# puts "target is #{target}"
|
|
340
|
+
return unless target
|
|
341
|
+
if event[PRESENCE]
|
|
342
|
+
target.send_event(event, EVENT_MESSAGE)
|
|
343
|
+
else
|
|
344
|
+
target.send_event(event, EVENT_NOTICE)
|
|
345
|
+
end
|
|
346
|
+
return
|
|
347
|
+
elsif !event[CHANNEL] and event[PRESENCE] and chat = add_buffer(event[NETWORK], event[MYPRESENCE], nil, event[PRESENCE])
|
|
348
|
+
if event[OWN]
|
|
349
|
+
chat.send_event(event, EVENT_USERMESSAGE)
|
|
350
|
+
else
|
|
351
|
+
chat.send_event(event, EVENT_MESSAGE)
|
|
352
|
+
end
|
|
353
|
+
return
|
|
354
|
+
elsif !event[CHANNEL]
|
|
355
|
+
return
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
if event[ADDRESS] and target and target.network.users[event[PRESENCE]] and target.network.users[event[PRESENCE]].hostname == 'hostname'
|
|
359
|
+
target.network.users[event[PRESENCE]].hostname = event[ADDRESS]
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
return unless target and target.respond_to? :join
|
|
363
|
+
if event[OWN]
|
|
364
|
+
target.send_event(event, EVENT_USERMESSAGE)
|
|
365
|
+
else
|
|
366
|
+
unless target.users.include?(event[PRESENCE])
|
|
367
|
+
puts "missing user #{event[PRESENCE]}"
|
|
368
|
+
#send_command('listchan-'+target.network.name+target.name, "channel names;#{target.identifier_string}")
|
|
369
|
+
#puts 'Forcing a userlist sync'
|
|
370
|
+
end
|
|
371
|
+
target.send_event(event, EVENT_MESSAGE)
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
#connected to a server
|
|
376
|
+
def event_gateway_connected(event, target)
|
|
377
|
+
return unless target
|
|
378
|
+
target.connect
|
|
379
|
+
msg = "Connected to "+event[IP]
|
|
380
|
+
msg += ":"+event[PORT] if event[PORT]
|
|
381
|
+
event['msg'] = msg
|
|
382
|
+
target.send_event(event, EVENT_NOTICE)
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
#failed to connect to a server
|
|
386
|
+
def event_gateway_connect_failed(event, target)
|
|
387
|
+
return unless target
|
|
388
|
+
if event['ip']
|
|
389
|
+
err = "Connection to "+event['ip']+':'+event[PORT]+" failed : "+event[ERROR]
|
|
390
|
+
event['err'] = err
|
|
391
|
+
else
|
|
392
|
+
event['err'] = event[ERROR]
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
target.send_event(event, EVENT_ERROR)
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
#the gateway has changed
|
|
399
|
+
def event_gwconn_changed(event, target)
|
|
400
|
+
gateway_changed(event, target)
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
#the gateway has changed
|
|
404
|
+
def event_gateway_changed(event, target)
|
|
405
|
+
return unless target
|
|
406
|
+
if event[IRC_MODE]
|
|
407
|
+
msg = event[MYPRESENCE]+" sets mode +"+event[IRC_MODE]+" "+event[MYPRESENCE]
|
|
408
|
+
event['msg'] = msg
|
|
409
|
+
target.send_event(event, EVENT_NOTICE)
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
#server's message of the day
|
|
414
|
+
def event_gateway_motd(event, target)
|
|
415
|
+
return unless target
|
|
416
|
+
event['msg'] = event['data']
|
|
417
|
+
target.send_event(event, EVENT_NOTICE)
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
#a channel has changed
|
|
421
|
+
def event_channel_changed(event, target)
|
|
422
|
+
return unless target
|
|
423
|
+
if event['initial_presences_added']
|
|
424
|
+
#@window.updateusercount
|
|
425
|
+
#target.drawusers
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
if event[TOPIC] and event[INIT]
|
|
429
|
+
#send the topic stuff as 2 lines
|
|
430
|
+
target.topic = event[TOPIC]
|
|
431
|
+
event['line'] = 1
|
|
432
|
+
target.send_event(event, EVENT_TOPIC)
|
|
433
|
+
event['line'] = 2
|
|
434
|
+
target.send_event(event, EVENT_TOPIC)
|
|
435
|
+
#@window.updatetopic
|
|
436
|
+
elsif event[TOPIC]
|
|
437
|
+
target.topic = event[TOPIC]
|
|
438
|
+
target.send_event(event, EVENT_TOPIC)
|
|
439
|
+
#@window.updatetopic
|
|
440
|
+
end
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
def event_client_config_changed(event, target)
|
|
444
|
+
value = @config.decode_value(event['value'])
|
|
445
|
+
|
|
446
|
+
@config[event['key'].sub('rirc_', '')] = value
|
|
447
|
+
# @window.draw_from_config
|
|
448
|
+
# restyle
|
|
449
|
+
@windows.each{|win| win.draw_from_config}
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
def event_irc_event(event, target)
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
def event_silc_event(event, target)
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
def event_channel_presence_mode_changed(event, target)
|
|
459
|
+
if target and target.users[event[PRESENCE]]
|
|
460
|
+
target.users[event[PRESENCE]].mode=event[MODE]
|
|
461
|
+
target.users.reorder(target.users[event[PRESENCE]])
|
|
462
|
+
if event[ADD]
|
|
463
|
+
target.send_event(event, EVENT_MODECHANGE)
|
|
464
|
+
elsif event[REMOVE]
|
|
465
|
+
target.send_event(event, EVENT_MODECHANGE)
|
|
466
|
+
end
|
|
467
|
+
#channel.drawusers
|
|
468
|
+
#@window.updateusercount
|
|
469
|
+
else
|
|
470
|
+
if !target
|
|
471
|
+
puts 'no such channel as '+event[CHANNEL]
|
|
472
|
+
elsif !target.users[event[PRESENCE]]
|
|
473
|
+
puts 'no such user '+event[PRESENCE]+' on '+event[CHANNEL]
|
|
474
|
+
end
|
|
475
|
+
end
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
def event_presence_status_changed(event, target)
|
|
479
|
+
return unless target
|
|
480
|
+
if user = target.network.users[event[PRESENCE]]
|
|
481
|
+
user.lastspoke = event['idle_started']
|
|
482
|
+
end
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
end
|
|
486
|
+
end
|