Class: SSCBot::User::JRobotMessageSender
Overview
Constant Summary
MessageSender::DEFAULT_ESCAPE_STR, MessageSender::DEFAULT_FLOOD_COUNT, MessageSender::DEFAULT_FLOOD_MIN_SLEEP, MessageSender::DEFAULT_FLOOD_SECS, MessageSender::MM_AREA, MessageSender::MM_BOUNTY, MessageSender::MM_COORD, MessageSender::MM_ENERGY, MessageSender::MM_FLAGS, MessageSender::MM_FREQ, MessageSender::MM_KILLED, MessageSender::MM_KILLER, MessageSender::MM_RED, MessageSender::MM_REDBOUNTY, MessageSender::MM_REDFLAGS, MessageSender::MM_REDNAME, MessageSender::MM_SELFNAME, MessageSender::MM_SQUAD, MessageSender::MM_TICKNAME
Instance Attribute Summary collapse
#escape_str, #flood_count, #flood_min_sleep, #flood_secs, #message_count, #message_time
Instance Method Summary
collapse
#escape_pub, #prevent_flood, #put_or_type, #send, #send_chat, #send_chat_to, #send_freq, #send_freq_eq, #send_or_types, #send_or_types_safe, #send_private, #send_private_to, #send_private_to_last, #send_pub, #send_q_chat, #send_q_chat_eq, #send_q_enter, #send_q_find, #send_q_kill, #send_q_leave, #send_q_lines, #send_q_lines_eq, #send_q_loadmacro, #send_q_log, #send_q_log_to, #send_q_logbuffer, #send_q_logbuffer_to, #send_q_namelen, #send_q_namelen_eq, #send_q_savemacro, #send_q_spec, #send_q_team, #send_safe, #send_squad, #send_squad_to, #send_team, #send_team2, #types, #types_safe
Constructor Details
#initialize(auto_delay: 110, msg_key: nil, os: Util::OS, warn_user: false, warn_user_key: KeyEvent::VK_BACK_SPACE, warn_user_sleep: 0.747, **kargs) ⇒ JRobotMessageSender
Returns a new instance of JRobotMessageSender.
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 51
def initialize(auto_delay: 110,msg_key: nil,os: Util::OS,warn_user: false,
warn_user_key: KeyEvent::VK_BACK_SPACE,warn_user_sleep: 0.747,**kargs)
super(**kargs)
@clipboard = Toolkit.getDefaultToolkit.getSystemClipboard
@msg_key = msg_key
@os = os
@robot = Robot.new
@warn_user = warn_user
@warn_user_key = warn_user_key
@warn_user_sleep = warn_user_sleep
@robot.setAutoDelay(auto_delay)
@shortcut_paste = lambda do |ms|
if ms.os == :macos
@shortcut_paste_macos.call(ms)
else
@shortcut_paste_default.call(ms)
end
end
@shortcut_paste_default = ->(ms) { ms.roll_keys(KeyEvent::VK_CONTROL,KeyEvent::VK_V) }
@shortcut_paste_macos = ->(ms) { ms.roll_keys(KeyEvent::VK_META,KeyEvent::VK_V) }
end
|
Instance Attribute Details
#clipboard ⇒ Object
40
41
42
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 40
def clipboard
@clipboard
end
|
#msg_key ⇒ Object
41
42
43
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 41
def msg_key
@msg_key
end
|
#os ⇒ Object
42
43
44
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 42
def os
@os
end
|
#robot ⇒ Object
43
44
45
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 43
def robot
@robot
end
|
#shortcut_paste ⇒ Object
44
45
46
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 44
def shortcut_paste
@shortcut_paste
end
|
#shortcut_paste_default ⇒ Object
45
46
47
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 45
def shortcut_paste_default
@shortcut_paste_default
end
|
#shortcut_paste_macos ⇒ Object
46
47
48
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 46
def shortcut_paste_macos
@shortcut_paste_macos
end
|
#warn_user_key ⇒ Object
48
49
50
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 48
def warn_user_key
@warn_user_key
end
|
#warn_user_sleep ⇒ Object
49
50
51
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 49
def warn_user_sleep
@warn_user_sleep
end
|
Instance Method Details
#backspace ⇒ Object
76
77
78
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 76
def backspace
return type_key(KeyEvent::VK_BACK_SPACE)
end
|
#copy(str) ⇒ Object
80
81
82
83
84
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 80
def copy(str)
@clipboard.setContents(StringSelection.new(str),nil)
return self
end
|
#enter ⇒ Object
86
87
88
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 86
def enter
return type_key(KeyEvent::VK_ENTER)
end
|
#paste(str = nil) ⇒ Object
90
91
92
93
94
95
96
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 90
def paste(str=nil)
copy(str) unless str.nil?
@shortcut_paste.call(self)
return self
end
|
#press_key(*key_codes) ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 98
def press_key(*key_codes)
key_codes.each do |key_code|
@robot.keyPress(key_code)
end
return self
end
|
#put(message) ⇒ Object
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 106
def put(message)
return warn_user.
type_msg_key.
paste(message)
end
|
#release_key(*key_codes) ⇒ Object
117
118
119
120
121
122
123
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 117
def release_key(*key_codes)
key_codes.each do |key_code|
@robot.keyRelease(key_code)
end
return self
end
|
#roll_keys(*key_codes) ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 125
def roll_keys(*key_codes)
key_codes.each do |key_code|
@robot.keyPress(key_code)
end
(key_codes.length - 1).downto(0) do |i|
@robot.keyRelease(key_codes[i])
end
return self
end
|
#send_message ⇒ Object
137
138
139
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 137
def send_message
enter
end
|
#type(message) ⇒ Object
TODO: implement type(message)
142
143
144
145
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 142
def type(message)
super(message)
end
|
#type_key(*key_codes) ⇒ Object
147
148
149
150
151
152
153
154
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 147
def type_key(*key_codes)
key_codes.each do |key_code|
@robot.keyPress(key_code)
@robot.keyRelease(key_code)
end
return self
end
|
#type_msg_key ⇒ Object
156
157
158
159
160
161
162
163
164
165
166
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 156
def type_msg_key
if @msg_key
if @msg_key.respond_to?(:call)
@msg_key.call(self)
else
type_key(@msg_key)
end
end
return self
end
|
#warn_user ⇒ Object
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# File 'lib/ssc.bot/user/jrobot_message_sender.rb', line 168
def warn_user
if @warn_user
if @warn_user_key.respond_to?(:call)
@warn_user_key.call(self)
else
press_key(@warn_user_key)
sleep(@warn_user_sleep)
release_key(@warn_user_key)
end
end
return self
end
|