Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 84bcc9959ae3d83d7c0767fc7934983e4b9c4513
  • master par défaut protégée
  • devel
  • v5.2.6
  • v5.2.5
5 résultats

Action.pm

Blame
    • ElTata's avatar
      84bcc995
      bug fixes · 84bcc995
      ElTata a rédigé
      - fixed conditions for classes
      - fixed steal failure 5% (from truncate to round)
      - fixed points repartition
      84bcc995
      Historique
      bug fixes
      ElTata a rédigé
      - fixed conditions for classes
      - fixed steal failure 5% (from truncate to round)
      - fixed points repartition
    Sam.pm 3,06 Kio
    package Sam;
    
    require Exporter;
    our @ISA = qw(Exporter);
    our @EXPORT_OK = qw(start);
    
    use strict;
    use warnings;
    
    use POE;
    use POE::Component::IRC;
    use DBI;
    use JSON;
    use Logging;
    use commands::parser;
    
    my $log = Logging->new('STDOUT', 1);
    
    # config
    my $serveur = 'IRC.iiens.net';
    my $nick = 'Sam';
    my $port = 6667;
    my $ircname = 'nightiies';
    my $username = 'nightiies';
    my @channels = qw(#nightiies #bigphatsubwoofer);
    my $admin = 'moise';
    my $baseurl = 'http://nightiies.iiens.net/sam/';
    my %lastID;
    my %commandes_admin = ("cycle" => \&cycle);
    
    my $debug = 0;
    
    # mode debug
    if ($#ARGV + 1) {
    	@channels = qw(#hormone);
    	$nick = 'glloq';
    	$debug = 1;
    }
    
    
    local $/;
    open CONF, '<', 'sam.conf';
    my $json = <CONF>;
    my $conf = decode_json($json);
    
    
    my ($irc) = POE::Component::IRC->spawn();
    my $dbh = DBI->connect('DBI:mysql:'.$conf->{'bdd'}.';host='.$conf->{'host'}, $conf->{'user'}, $conf->{'passwd'}, {
    	    PrintError => 0,
    	    AutoCommit => 1,
    		mysql_auto_reconnect => 1
    	})
    	or die("Couldn't connect to database: ".DBI->errstr);
    
    # Evenements que le bot va gérer
    POE::Session->create(
    	inline_states => {
            _start     => \&bot_start,
            irc_001    => \&on_connect,
            irc_public => \&on_speak,
            irc_msg    => \&on_query,
            irc_invite => \&on_invite
    	},
    );
    
    
    sub cycle
    {
    	my ($arg) = @_;