поиск Perl+icq_bot

Discussion in 'PHP' started by KENNY_McCORMICK, 10 Sep 2008.

  1. KENNY_McCORMICK

    KENNY_McCORMICK Elder - Старейшина

    Joined:
    9 Nov 2007
    Messages:
    29
    Likes Received:
    3
    Reputations:
    0
    Исчу icq bot'a на perl'е или python
    поделитесь люди добрые)
    с меня +
     
  2. Gifts

    Gifts Green member

    Joined:
    25 Apr 2008
    Messages:
    2,494
    Likes Received:
    807
    Reputations:
    614
    Например тут http://search.cpan.org/dist/Net-OSCAR/lib/Net/OSCAR.pm
     
    _________________________
  3. biophreak

    biophreak Elder - Старейшина

    Joined:
    3 Aug 2007
    Messages:
    348
    Likes Received:
    63
    Reputations:
    15
    Выкладывал тут с примитивными ф-иями, бот юзает все тот же Net::OSCAR, простейшего бота на нем написать,который будет отвечать "Привет" на любое сообщение - 10 строчек максимум)
    Так же делал ICQ2IRC гейт на базе него-же( http://icq2irc.googlecode.com )
    Вот пример бота
    Code:
    #!/usr/bin/perl -s
    use strict;
    use warnings;
    use diagnostics;
    use Net::OSCAR;
    my $uin = 123456;
    my $passwd = 'qwerty';
    my $adminuin = 654321; ## Your UIN
    my $icq = Net::OSCAR->new;
    $icq->set_callback_im_in(\&in) or die '[ERROR] [Cannot set callback] [$!]';
    $icq->signon($uin, $passwd) or die '[ERROR] [Cannot sign on] [$!]';
    $icq->do_one_loop while (not $icq->is_on);
    $icq->do_one_loop while ($icq->is_on);
    sub in {
    	my($oscar, $sender, $message, $is_away) = @_;
    	print "$sender: $message\n";
    	$oscar->signoff() if ($message eq '!quit'  and $sender eq $adminuin);
    	$oscar->send_im($sender,`uptime`) if ($message eq '!uptime' and $sender eq $adminuin);
    
    }
    
     
    #3 biophreak, 10 Sep 2008
    Last edited: 10 Sep 2008
  4. KENNY_McCORMICK

    KENNY_McCORMICK Elder - Старейшина

    Joined:
    9 Nov 2007
    Messages:
    29
    Likes Received:
    3
    Reputations:
    0
    >>biophreak

    [​IMG]

    see up....
    ето типо он OSCAR подключить на может?
    шо делатЬ?))
     
  5. Gifts

    Gifts Green member

    Joined:
    25 Apr 2008
    Messages:
    2,494
    Likes Received:
    807
    Reputations:
    614
    KENNY_McCORMICK ты модуль то подключи
     
    _________________________
  6. KENNY_McCORMICK

    KENNY_McCORMICK Elder - Старейшина

    Joined:
    9 Nov 2007
    Messages:
    29
    Likes Received:
    3
    Reputations:
    0
    ppm install Net-OSCAR так?
     
  7. KENNY_McCORMICK

    KENNY_McCORMICK Elder - Старейшина

    Joined:
    9 Nov 2007
    Messages:
    29
    Likes Received:
    3
    Reputations:
    0
    теперь говорит:
    [​IMG]
     
  8. biophreak

    biophreak Elder - Старейшина

    Joined:
    3 Aug 2007
    Messages:
    348
    Likes Received:
    63
    Reputations:
    15
    perl -V покажи
    А вообще что-то с прототипами,видимо когда сокет создается...неблокирующийся создать не может =\
    Под виндой даже не тестил оскар)
     
  9. n3m0

    n3m0 Elder - Старейшина

    Joined:
    11 May 2007
    Messages:
    133
    Likes Received:
    92
    Reputations:
    11
    тут наверно требуются не одинарные кавычки , а двойные , т.к. не будет интерполяции и спец. символ $! не чего интересного не скажет.
     
    1 person likes this.
  10. biophreak

    biophreak Elder - Старейшина

    Joined:
    3 Aug 2007
    Messages:
    348
    Likes Received:
    63
    Reputations:
    15
    Да,ты прав,спс,за 2 минуты писал)))
     
  11. KENNY_McCORMICK

    KENNY_McCORMICK Elder - Старейшина

    Joined:
    9 Nov 2007
    Messages:
    29
    Likes Received:
    3
    Reputations:
    0
    Code:
    #!/usr/bin/perl -s
    use strict;
    use warnings;
    use diagnostics;
    use Net::OSCAR;
    my $uin = тут_юин;
    my $passwd = 'пасс_к_нему';
    my $adminuin = мой_юин;
    my $icq = Net::OSCAR->new;
    $icq->set_callback_im_in(\&in) or die "[ERROR] [Cannot set callback] [$!]";
    $icq->signon($uin, $passwd) or die "[ERROR] [Cannot sign on] [$!]";
    $icq->do_one_loop while (not $icq->is_on);
    $icq->do_one_loop while ($icq->is_on);
    sub in {
    	my($oscar, $sender, $message, $is_away) = @_;
    	print "$sender: $message\n";
    	$oscar->signoff() if ($message eq '!quit'  and $sender eq $adminuin);
    	$oscar->send_im($sender,`uptime`) if ($message eq '!uptime' and $sender eq $adminuin);
    
    }
    
    исправил ' -> "
    так же пишет:
    [​IMG]

    Подпись ошибки Perl Command Line Interpreter
    Code:
    AppName: perl.exe	 AppVer: 5.10.0.1003	 ModName: msvcrt.dll
    ModVer: 7.0.2600.2180	 Offset: 0003709c
    чё за ххх? моск пухнет уже)
     
  12. KENNY_McCORMICK

    KENNY_McCORMICK Elder - Старейшина

    Joined:
    9 Nov 2007
    Messages:
    29
    Likes Received:
    3
    Reputations:
    0
    perl -V here
    Code:
    C:\Documents and Settings\Admin>perl -V
    Set up gcc environment - 3.4.5 (mingw-vista special r3)
    Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
      Platform:
        osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread
        uname=''
        config_args='undef'
        hint=recommended, useposix=true, d_sigaction=undef
        useithreads=define, usemultiplicity=define
        useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
        use64bitint=undef, use64bitall=undef, uselongdouble=undef
        usemymalloc=n, bincompat5005=undef
      Compiler:
        cc='gcc', ccflags ='-DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYP
    T -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLI
    CIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX -DHASATTRIBUTE -fno-strict-aliasing -
    mms-bitfields',
        optimize='-O2',
        cppflags='-DWIN32'
        ccversion='', gccversion='3.4.5 (mingw-vista special r3)', gccosandvers=''
        intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
        d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
        ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksi
    ze=8
        alignbytes=8, prototype=define
      Linker and Libraries:
        ld='g++', ldflags ='-L"C:\Perl\lib\CORE"'
        libpth=\lib
        libs=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32
    -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -
    lodbccp32 -lmsvcrt
        perllibs=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshel
    l32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc
    32 -lodbccp32 -lmsvcrt
        libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl510.lib
        gnulibc_version=''
      Dynamic Linking:
        dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
        cccdlflags=' ', lddlflags='-mdll -L"C:\Perl\lib\CORE"'
    
    
    Characteristics of this binary (from libperl):
      Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
                            PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
                            PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_ITHREADS
                            USE_LARGE_FILES USE_PERLIO USE_SITECUSTOMIZE
      Locally applied patches:
            ActivePerl Build 1003 [285500]
            33741 avoids segfaults invoking S_raise_signal() (on Linux)
            33763 Win32 process ids can have more than 16 bits
            32809 Load 'loadable object' with non-default file extension
            32728 64-bit fix for Time::Local
      Built under MSWin32
      Compiled at May 13 2008 16:52:49
      @INC:
        C:/Perl/site/lib
        C:/Perl/lib
        .
     
  13. biophreak

    biophreak Elder - Старейшина

    Joined:
    3 Aug 2007
    Messages:
    348
    Likes Received:
    63
    Reputations:
    15
    Хм...виста чтоль?:)
    PS: perl -MNet::OSCAR -le'print $Net::OSCAR::VERSION,$Net::OSCAR::REVISION' покажи
    PPS: Да и попробуй модуль не из ppm ставить, а с CPAN'а
     
    #13 biophreak, 12 Sep 2008
    Last edited: 12 Sep 2008
  14. KENNY_McCORMICK

    KENNY_McCORMICK Elder - Старейшина

    Joined:
    9 Nov 2007
    Messages:
    29
    Likes Received:
    3
    Reputations:
    0
    с одной ковычкой
    Code:
    C:\Documents and Settings\Admin>perl -MNet::OSCAR -le 'print $Net::OSCAR::VERSIO
    N,$Net::OSCAR::REVISION'
    Prototype mismatch: sub Net::OSCAR::Connection::F_GETFL () vs none at (eval 5) l
    ine 1.
    Prototype mismatch: sub Net::OSCAR::Connection::F_SETFL () vs none at (eval 6) l
    ine 1.
    Prototype mismatch: sub Net::OSCAR::Connection::O_NONBLOCK () vs none at (eval 7
    ) line 1.
    Can't find string terminator "'" anywhere before EOF at -e line 1.
    с двумя
    Code:
    C:\Documents and Settings\Admin>perl -MNet::OSCAR -le "print $Net::OSCAR::VERSIO
    N,$Net::OSCAR::REVISION"
    Prototype mismatch: sub Net::OSCAR::Connection::F_GETFL () vs none at (eval 5) l
    ine 1.
    Prototype mismatch: sub Net::OSCAR::Connection::F_SETFL () vs none at (eval 6) l
    ine 1.
    Prototype mismatch: sub Net::OSCAR::Connection::O_NONBLOCK () vs none at (eval 7
    ) line 1.
    1.925$Revision: 1.221 $
    Code:
    C:\Documents and Settings\Admin>ver
    Microsoft Windows XP [Версия 5.1.2600]
    C:\Documents and Settings\Admin>
    З.Ы а как из CPAN'а ставить?
     
  15. KENNY_McCORMICK

    KENNY_McCORMICK Elder - Старейшина

    Joined:
    9 Nov 2007
    Messages:
    29
    Likes Received:
    3
    Reputations:
    0
  16. biophreak

    biophreak Elder - Старейшина

    Joined:
    3 Aug 2007
    Messages:
    348
    Likes Received:
    63
    Reputations:
    15
    Хм...как из цпана ставить
    http://snipplr.com/view/3718/how-to-start-cpan-on-windowsactiveperl/
    Если вкратце,то perl -MCPAN -e'install Module::Name' или же perl -MCPAN -eshell и там уже install Module::Name

    ЗЫЖ А бот, что я запостил тут - рабочий, проверял, так что ищи косяки в винде, вроде как в офдоке к Net::OSCAR не заявлена полная поддержка Win32.Так что делайте выводы;)
     
    1 person likes this.