Schrift
[thread]4472[/thread]

Versuche eine mail zu löschen...: GMail::Checker



<< >> 5 Einträge, 1 Seite
FlorianL
 2007-07-24 23:08
#37611 #37611
User since
2007-05-18
142 Artikel
BenutzerIn
[default_avatar]
Hi, ich hole mir alle mails vom gmail konto ab, parse ein paar sachen raus und möchte die mail dann anschliessen löschen, bis aufs löschen klappts auch...

hier der code:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl
use strict;
#use warnings;
use GMail::Checker;

my $gmail_login = "bla";
my $gmail_pass = "titten";
my $gwrapper = new GMail::Checker();

# gmail-login
$gwrapper->login($gmail_login,$gmail_pass);
my ($gmail_mails, $gmail_size) = $gwrapper->get_msg_nb_size(); # Get total number and size

# mailbox info
my $gmail_total =  $gwrapper->get_pretty_nb_messages(ALERT => "TOTAL_MSG");
print("$gmail_total\n");

# parse messages
my @mails = (1 .. $gmail_mails);
foreach (@mails) {
        my $host;
        if ($host eq '') { shift } else { print("--\n"); }
        my @msg;
        my @msg = $gwrapper->get_msg(MSG => $_);
        my @irc_server_string = $msg[0]->{body} =~ /Connects to \"(.+)\" on port (\d+) \(TCP\)./;
        my $host = $irc_server_string[0];
        my $port = $irc_server_string[1];
        if ($host eq '') { shift } else {
               
 print("Host: $host\n");
        }
        if ($port eq '') { shift } else {
               
 print("Port: $port\n");
        }
        my @irc_bot_nick = $msg[0]->{body} =~ /IRC: Uses nickname (.+)./;
        chop(my $botnick = $irc_bot_nick[0]);
        if ($botnick eq '') { shift } else {
               
 print("Botnick: $botnick\n");
        }
        my @irc_bot_username = $msg[0]->{body} =~ /IRC: Uses username (.+)./;
        chop(my $botusername = $irc_bot_username[0]);
        if ($botusername eq '') { shift } else {
               
 print("Botusername: $botusername\n");
        }
        my @irc_bot_usermode = $msg[0]->{body} =~ /IRC: Sets the usermode for user .+ to (.+)./;
        chop(my $botusermode = $irc_bot_usermode[0]); # =~ s/./\+/g;
        if (($botusermode eq '') or ($botusermode eq 'is')) { shift } else {
               
 print("Mode On Connect: $botusermode\n");
        }
        my @irc_channel_string = $msg[0]->{body} =~ /IRC: Joins channel (.+) with password (.+)./;
        chop(my $ircchannel = $irc_channel_string[0]);
        chop(my $ircpass = $irc_channel_string[1]);
        if ($ircchannel eq '') { shift } else {
               
 print("IRC-Channel: $ircchannel\n");
        }
        if (($ircpass eq '') or ($ircpass eq ' ')) {
               
 shift;
        } else {
               
 print("Channel-Pass: $ircpass\n");
        }
        my @irc_channel_modes = $msg[0]->{body} =~ /IRC: Sets the channel mode for channel .+ to (.+)./;
        chop(my $ircchannelmode = $irc_channel_modes[0]);
        if ($ircchannelmode eq '') { shift } else {
               
 print("Channel-Mode: $ircchannelmode\n");
        }
        if ($host eq '') { shift } else { print("--\n");}
        if ($_ > 2) { $gwrapper->get_msg(DELETE => '$_--'); }
}


output:

mindfuck@mindfucked:~/scripts/judas$ ./judas.pl
You have 2075 messages in your inbox (size 9.50 Mbytes)

Can't use string ("9959216") as an ARRAY ref while "strict refs" in use at /usr/local/share/perl/5.8.8/GMail/Checker.pm line 271.
mindfuck@mindfucked:~/scripts/judas$

hat jemand ne idee dazu? :)
renee
 2007-07-25 11:10
#37612 #37612
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Ich kenne das Modul nicht, aber das hier:
Code: (dl )
DELETE => '$_--'
sieht mir nicht richtig aus...

Mach mal:
Code: (dl )
1
2
my $i = $_-1;
...get_msg( DELETE => $i )



Wenn Du den Fehler nicht findest, würde ich auf ein neueres Modul umsteigen wie CPAN:Mail::Webmail::Gmail oder CPAN:GMail::IMAPD
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
pq
 2007-07-25 11:58
#37613 #37613
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
keine warnings (warum hast du die auskommentiert??)
der code:
Code: (dl )
1
2
        my $host;
if ($host eq '') { shift } else { print("--\n"); }

ist ziemlich sinnfrei. wie um alles in der welt soll $host jemals einen anderen
wert als undef haben?
und das shift shiftet in diesem fall von @ARGV - ist das so gewollt?

im übrigen wäre es schön, etwas mehr kreativität beim ausdenken des
pseudopasswortes zu zeigen und nicht das zu nehmen, was du gerade
im kopf hast, das ist bei männern einfach nur peinlich.
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
FlorianL
 2007-07-25 12:13
#37614 #37614
User since
2007-05-18
142 Artikel
BenutzerIn
[default_avatar]
[quote=pq,25.07.2007, 09:58]keine warnings (warum hast du die auskommentiert??)
der code:
Code: (dl )
1
2
        my $host;
if ($host eq '') { shift } else { print("--\n"); }

ist ziemlich sinnfrei. wie um alles in der welt soll $host jemals einen anderen
wert als undef haben?
und das shift shiftet in diesem fall von @ARGV - ist das so gewollt?

im übrigen wäre es schön, etwas mehr kreativität beim ausdenken des
pseudopasswortes zu zeigen und nicht das zu nehmen, was du gerade
im kopf hast, das ist bei männern einfach nur peinlich.[/quote]
moin! =)

ich shifte doch von @mails oder nicht?

Code: (dl )
1
2
my $host;
if ($host eq '') { shift } else { print("--\n"); }


hab ich nur als work-around gebastelt damit ich bei jeder mail vorher -- als trenner drin stehn hab... aber jetzt wo ichs nochma seh, sinnfrei indeed ^^

und tschuldige mein pseudopass, so sind wir männer halt ab und zu ;)

@renee: ich hab bei ner cpansuche nach gmail nur müll entdeckt, werde gleich erstmal deine lösung testen und ansonsten gern auf ein anderes modul, wenn nötig halt ein pop3 modul umsteigen...
renee
 2007-07-25 12:32
#37615 #37615
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
[quote=FlorianL,25.07.2007, 10:13]ich shifte doch von @mails oder nicht?

Code: (dl )
1
2
my $host;
if ($host eq '') { shift } else { print("--\n"); }
[/quote]
Nö, dann musst Du das angeben: shift @mails

Aus <!--pod_f1--><a href="//perldoc.perl.org/functions/shift.html" target="_blank"><img alt="perldoc " src="/iB_html/non-cgi/Skin/SKIN-3/images/perldoc.gif" border="0"> <!--pod_f2-->perldoc -f shift<!--pod_f3--></a><!--pod_f4-->:
Quote
shift ARRAY
shift Shifts the first value of the array off and returns it,
shortening the array by 1 and moving everything down. If there
are no elements in the array, returns the undefined value. If
ARRAY is omitted, shifts the @_ array within the lexical scope
of subroutines and formats, and the @ARGV array at file scopes

or within the lexical scopes established by the "eval ''",
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
<< >> 5 Einträge, 1 Seite



View all threads created 2007-07-24 23:08.