Class: TermtterIrcGateway
- Inherits:
-
Net::IRC::Server::Session
- Object
- Net::IRC::Server::Session
- TermtterIrcGateway
- Defined in:
- lib/plugins/irc_gw.rb
Constant Summary collapse
- @@listners =
[]
- @@last_statuses =
[]
Instance Method Summary collapse
- #call(statuses, event) ⇒ Object
-
#initialize(*args) ⇒ TermtterIrcGateway
constructor
A new instance of TermtterIrcGateway.
- #main_channel ⇒ Object
- #on_message(m) ⇒ Object
- #on_privmsg(m) ⇒ Object
- #on_user(m) ⇒ Object
- #server_name ⇒ Object
- #server_version ⇒ Object
Constructor Details
#initialize(*args) ⇒ TermtterIrcGateway
Returns a new instance of TermtterIrcGateway.
33 34 35 36 |
# File 'lib/plugins/irc_gw.rb', line 33 def initialize(*args) super @@listners << self end |
Instance Method Details
#call(statuses, event) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/plugins/irc_gw.rb', line 38 def call(statuses, event) msg_type = case event when :update_friends_timeline PRIVMSG else NOTICE end statuses.each do |s| post s.user.screen_name, msg_type, main_channel, [s.text, s.id].join(' ') end end |
#main_channel ⇒ Object
31 |
# File 'lib/plugins/irc_gw.rb', line 31 def main_channel; '#termtter' end |
#on_message(m) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/plugins/irc_gw.rb', line 52 def (m) termtter_command = m.command.downcase + ' ' + m.params.join(' ') unless Termtter::Client.find_commands(termtter_command).empty? post '#termtter', NOTICE, main_channel, '> ' + termtter_command Termtter::Client.call_commands(termtter_command) end end |
#on_privmsg(m) ⇒ Object
67 68 69 70 |
# File 'lib/plugins/irc_gw.rb', line 67 def on_privmsg(m) target, = *m.params Termtter::Client.call_commands('update ' + ) end |
#on_user(m) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/plugins/irc_gw.rb', line 60 def on_user(m) super post @prefix, JOIN, main_channel post server_name, MODE, main_channel, "+o", @prefix.nick self.call(@@last_statuses || [], :update_friends_timeline) end |
#server_name ⇒ Object
29 |
# File 'lib/plugins/irc_gw.rb', line 29 def server_name; 'termtter' end |
#server_version ⇒ Object
30 |
# File 'lib/plugins/irc_gw.rb', line 30 def server_version; '0.0.0' end |