Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • e5a304655be66ca33459b2333952a632703890e6
  • develop par défaut protégée
  • implement-discord-markdown-update
  • matrix-attachments-order-fix
  • fix-oversized-file-transfer
  • matrix-attachment-order-fix
  • matrix-answer-modified-fix
  • cherry-pick-moise
8 résultats

matrixeventprocessor.ts

Blame
  • Bifurcation depuis ARISE / matrix-appservice-discord
    Le projet source a une visibilité limitée.
    get.pm 5,14 Kio
    package commands::get;
    
    use strict;
    use warnings;
    
    use lib "$FindBin::Bin/lib/";
    use utils::print;
    use utils::db;
    
    use commands::get::query;
    
    our $irc;
    our $log;
    
    my %last_req;
    my $dbh;
    my $sth;
    
    sub exec {
    	my ($kernel, $nick, $chan, $msg) = @_;
    
        my $query = commands::get::query->new(
            chan => $chan->[0],
            query  => ($msg) ? $msg : ''
        );
    
        my $content;
        my $req;
        my $rows;
    
        if (not defined $last_req{$query->chan} or not ($query ~~ $last_req{$query->chan})) {
            # we close a previous session if needed
            if ($dbh) {
                $sth->finish if $sth->{'Active'};
                $dbh->commit;
                $dbh->disconnect;
            }
    
            $dbh = utils::db::get_new_session;
    
            my @words_param;
            foreach (@{$query->words}) {
                unshift @words_param, '%'.$_.'%';
            }
    
            my $words_sql;
            foreach (@{$query->words}) {
                $words_sql .= ' and ' if ($words_sql);
                $words_sql .= "concat(sender, ' ', title) like ?";
            }
    
            if ($query->id >= 0) {
                $sth = $dbh->prepare('select id, sender, title, url, duration
                    from playbot
                    where id = ?');
                $sth->execute($query->id);
            }
            elsif (@{$query->tags}) {
                my @where;
    
                foreach my $tag (@{$query->tags}) {
                    unshift @where, 'p.id in (select pt.id from playbot_tags pt where pt.tag = ?)';
                }
    
                my $where = join ' and ' => @where;
    
                if ($query->is_global) {
                    $req = 'select id, sender, title, url, duration
                        from playbot
                        where '.$where;