Class ::Bot
In: lib/rbot/core/utils/filters.rb
lib/rbot/core/utils/wordlist.rb
lib/rbot/core/utils/extends.rb
lib/rbot/core/remote.rb
Parent: Object
User HTTPResponse BasicUserMessage Bot\n[lib/rbot/core/remote.rb\nlib/rbot/core/utils/extends.rb\nlib/rbot/core/utils/filters.rb\nlib/rbot/core/utils/wordlist.rb] HttpUtil lib/rbot/core/userdata.rb lib/rbot/core/utils/httputil.rb lib/rbot/core/utils/extends.rb lib/rbot/core/remote.rb lib/rbot/core/utils/httputil.rb ParseTime Utils (null) dot/m_15_0.png

Methods

Classes and Modules

Module ::Bot::Auth
Module ::Bot::Plugins
Class ::Bot::DataFilter
Class ::Bot::DataStream
Class ::Bot::RemoteDispatcher
Class ::Bot::RemoteMessage
Class ::Bot::RemoteObject
Class ::Bot::Wordlist

Public Instance methods

This method clears the filter list and installs the identity filter

[Source]

     # File lib/rbot/core/utils/filters.rb, line 142
142:     def clear_filters
143:       @filters ||= {}
144:       @filters.clear
145: 
146:       @filter_group ||= {}
147:       @filter_group.clear
148: 
149:       register_filter(:identity) { |stream| stream }
150:     end

This method processes the DataStream stream with the filters filter1, filter2, …, filterN, in sequence (the output of each filter is used as input for the next one. stream can be provided either as a DataStream or as a String and a Hash (see DataStream.new).

[Source]

    # File lib/rbot/core/utils/filters.rb, line 63
63:     def filter(*args)
64:       @filters ||= {}
65:       if Hash === args.last
66:         # the stream is a Hash, check if the previous element is not a Symbol
67:         if Symbol === args[-2]
68:           ds = DataStream.new(args.pop)
69:         else
70:           ds = DataStream.new(*args.slice!(-2, 2))
71:         end
72:       else
73:         # the stream is just whatever else
74:         ds = DataStream.new(args.pop)
75:       end
76:       names = args.dup
77:       return ds if names.empty?
78:       # check if filters exist
79:       missing = names - @filters.keys
80:       raise "Missing filters: #{missing.join(', ')}" unless missing.empty?
81:       fs = @filters.values_at(*names)
82:       fs.inject(ds) { |mid, f| mid = f.call(mid) }
83:     end

This method is used to retrieve the filter group names

[Source]

     # File lib/rbot/core/utils/filters.rb, line 136
136:     def filter_groups
137:       return [] unless defined? @filter_group
138:       return @filter_group.keys
139:     end

This method is used to retrieve the filter names (in a given group)

[Source]

     # File lib/rbot/core/utils/filters.rb, line 124
124:     def filter_names(group=nil)
125:       if group
126:         gkey = group.to_sym
127:         return [] unless defined? @filter_group and @filter_group.key?(gkey)
128:         return @filter_group[gkey].keys
129:       else
130:         return [] unless defined? @filters
131:         return @filters.keys
132:       end
133:     end

This method returns the global filter name for filter name in group group

[Source]

    # File lib/rbot/core/utils/filters.rb, line 87
87:     def global_filter_name(name, group=nil)
88:       (group ? "#{group}.#{name}" : name.to_s).intern
89:     end

This method checks if the bot has a filter named name (in group group)

[Source]

    # File lib/rbot/core/utils/filters.rb, line 93
93:     def has_filter?(name, group=nil)
94:       @filters.key?(global_filter_name(name, group))
95:     end

This method checks if the bot has a filter group named name

[Source]

     # File lib/rbot/core/utils/filters.rb, line 98
 98:     def has_filter_group?(name)
 99:       @filter_group.key?(name)
100:     end

This method is used to register a new filter

[Source]

     # File lib/rbot/core/utils/filters.rb, line 103
103:     def register_filter(name, group=nil, &block)
104:       raise "No block provided" unless block_given?
105:       @filters ||= {}
106:       tlkey = global_filter_name(name, group)
107:       key = name.to_sym
108:       if has_filter?(tlkey)
109:         debug "Overwriting filter #{tlkey}"
110:       end
111:       @filters[tlkey] = DataFilter.new(&block)
112:       if group
113:         gkey = group.to_sym
114:         @filter_group ||= {}
115:         @filter_group[gkey] ||= {}
116:         if @filter_group[gkey].key?(key)
117:           debug "Overwriting filter #{key} in group #{gkey}"
118:         end
119:         @filter_group[gkey][key] = @filters[tlkey]
120:       end
121:     end

The bot also manages a single (for the moment) remote dispatcher. This method makes it accessible to the outside world, creating it if necessary.

[Source]

     # File lib/rbot/core/remote.rb, line 241
241:     def remote_dispatcher
242:       if defined? @remote_dispatcher
243:         @remote_dispatcher
244:       else
245:         @remote_dispatcher = RemoteDispatcher.new(self)
246:       end
247:     end

The bot also manages a single (for the moment) remote object. This method makes it accessible to the outside world, creating it if necessary.

[Source]

     # File lib/rbot/core/remote.rb, line 252
252:     def remote_object
253:       if defined? @remote_object
254:         @remote_object
255:       else
256:         @remote_object = RemoteObject.new(self)
257:       end
258:     end

[Validate]