public
Description: Direct Connect bot written in Ruby
Clone URL: git://github.com/kballard/dcbot.git
Search Repo:
Pipe keyboard input to the public chat
kballard (author)
Sat Feb 16 08:28:32 -0800 2008
commit  7648b1a8b5acafa65a23256aae09bb5148fe68a1
tree    76da8d17d1827753543506f2cf7521881451d1b9
parent  295af7bf0817496987310a390cf35a06c74b64ba
...
5
6
7
 
8
9
10
11
...
36
37
38
 
39
40
41
42
43
44
45
 
46
47
48
...
5
6
7
8
9
10
11
12
...
37
38
39
40
41
42
43
44
45
46
 
47
48
49
50
0
@@ -5,6 +5,7 @@
0
 require 'eventmachine'
0
 require './config'
0
 require './dcprotocol'
0
+require './keyboard'
0
 require './plugin'
0
 require 'pp'
0
 
0
0
@@ -36,13 +37,14 @@
0
   end
0
   
0
   EventMachine::run do
0
+ EventMachine::open_keyboard KeyboardInput
0
     setupConnection(host, port, nickname, description, 0)
0
   end
0
   STDERR.puts "Shutting Down"
0
 end
0
 
0
 def setupConnection(host, port, nickname, description, sleep)
0
- socket = DCClientProtocol.connect(host, port, nickname, :description => description) do |c|
0
+ $socket = DCClientProtocol.connect(host, port, nickname, :description => description) do |c|
0
     c.registerCallback :message do |socket, sender, message, isprivate, isaction|
0
       if isprivate or sender == "*Dtella" then
0
         if isaction then
...
107
108
109
110
 
111
112
113
...
107
108
109
 
110
111
112
113
0
@@ -107,7 +107,7 @@
0
     else
0
       nick = @nickname
0
     end
0
- send_data "<#{nick}> #{message}!"
0
+ send_data "<#{nick}> #{message}|"
0
   end
0
   
0
   def sendPrivateMessage(recipient, message, isaction = false)
...
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
0
@@ -1 +1,9 @@
0
+module KeyboardInput
0
+ include EventMachine::Protocols::LineText2
0
+
0
+ def receive_line(line)
0
+ line.chomp!
0
+ $socket.sendPublicMessage(line)
0
+ end
0
+end

Comments

    No one has commented yet.