cinch-imap 0.0.4 → 0.0.5
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/README.md +5 -2
- data/lib/cinch/plugins/imap.rb +6 -5
- metadata +2 -2
data/README.md
CHANGED
@@ -4,6 +4,9 @@ The Cinch Imap Plugin. Poll an IMAP mailbox at a defined interval.
|
|
4
4
|
|
5
5
|
Change Log
|
6
6
|
----------
|
7
|
+
0.0.5
|
8
|
+
- bug fixes
|
9
|
+
|
7
10
|
0.0.4
|
8
11
|
- Added from_rewrites configuration option
|
9
12
|
- Added !monitor showconfig command
|
@@ -36,6 +39,7 @@ Commands
|
|
36
39
|
!monitor status - Issues a status report to the channel
|
37
40
|
!monitor clear - Resets the number of "messages seen" to 0
|
38
41
|
!monitor interval [n] - Set polling interval to n second
|
42
|
+
!monitor showconfig - shows all config options other than password
|
39
43
|
|
40
44
|
Example Configuration
|
41
45
|
---------------------
|
@@ -83,5 +87,4 @@ eyes only.
|
|
83
87
|
TODO
|
84
88
|
----
|
85
89
|
|
86
|
-
|
87
|
-
* Support configurable from address rewrites
|
90
|
+
- Figure out how to auto-start this thing
|
data/lib/cinch/plugins/imap.rb
CHANGED
@@ -5,7 +5,7 @@ module Cinch
|
|
5
5
|
class Imap
|
6
6
|
include Cinch::Plugin
|
7
7
|
|
8
|
-
VERSION='0.0.
|
8
|
+
VERSION='0.0.5'
|
9
9
|
|
10
10
|
match /monitor (on|off)/
|
11
11
|
match /monitor status/, method: :status
|
@@ -87,20 +87,21 @@ module Cinch
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def execute(m, option)
|
90
|
-
@monitor = option == "on"
|
90
|
+
@monitor = option == "on"
|
91
91
|
|
92
92
|
background_job do
|
93
93
|
imap = Net::IMAP.new(@mail_host, @mail_port, @mail_ssl)
|
94
94
|
imap.login(@mail_user, @mail_password)
|
95
95
|
imap.select(@mail_folder)
|
96
96
|
get_messages(imap) do |from, subj|
|
97
|
+
message_from, message_prefix = from, nil
|
97
98
|
@from_rewrites.each do |k, v|
|
98
|
-
|
99
|
+
message_from = "#{v}" if from =~ /#{k}/
|
99
100
|
end
|
100
101
|
@subject_matches.each do |k, v|
|
101
|
-
|
102
|
+
message_prefix = "#{v}" if subj =~ /#{k}/
|
102
103
|
end
|
103
|
-
m.reply "#{message_prefix} #{message_from} #{subj}"
|
104
|
+
m.reply "#{message_prefix} #{message_from}: #{subj}"
|
104
105
|
end
|
105
106
|
imap.disconnect
|
106
107
|
end if @monitor
|