Showing 1 changed files with 10 additions and 6 deletions
+10 -6
sms/bot
... ...
@@ -12,7 +12,7 @@ use open ':utf8';
12 12
 use open ':std';
13 13
 use utf8;
14 14
 
15
-use Data::Dumper;
15
+#use Data::Dumper;
16 16
 
17 17
 use threads;
18 18
 use threads::shared;
... ...
@@ -114,7 +114,9 @@ sub massive_send_sms {
114 114
 }
115 115
 
116 116
 sub send_mail {
117
-    while (my $msg = $mail_queue->dequeue) {
117
+    while (1) {
118
+        my $msg = $mail_queue->dequeue_timed(10, 1);
119
+        next if ! defined $msg;
118 120
         defined($msg->{to}) or $msg->{to} = $cfg::config{mail};
119 121
         open(MAIL, "|msmtp $msg->{to}");
120 122
         print MAIL "Subject: $msg->{Subject}\n";
... ...
@@ -214,7 +216,9 @@ sub react_on_message {
214 216
 }
215 217
 
216 218
 sub inbox_sms_parse {
217
-    while (my $msg = $inbox_sms_queue->dequeue) {
219
+    while (1) {
220
+        my $msg = $inbox_sms_queue->dequeue_timed(10, 1);
221
+        next if ! defined $msg;
218 222
 
219 223
         my %part_from_user = (
220 224
             $cfg::user{"message de groupe"} => sub {
... ...
@@ -229,9 +233,9 @@ sub inbox_sms_parse {
229 233
             $cfg::user{"ping"} => sub {
230 234
                 my $envoi_en_cours = '';
231 235
                 if ($outbox_sms_queue->pending() > 0) {
232
-                    for (my $queue_id = $outbox_sms_queue->pending(); $queue_id >= 0; $queue_id--) {
233
-                        log_bot(Dumper($outbox_sms_queue->peek($queue_id)));
234
-                    }
236
+#                    for (my $queue_id = $outbox_sms_queue->pending(); $queue_id >= 0; $queue_id--) {
237
+#                        log_bot(Dumper($outbox_sms_queue->peek($queue_id)));
238
+#                    }
235 239
                     $envoi_en_cours = "\nenvoi en cours de traitement (reste " . $outbox_sms_queue->pending() . ") ";
236 240
                     $envoi_en_cours .= "par $cfg::config{last_sender}" if defined($cfg::config{last_sender});
237 241
                 }