This is my wiki. There's nothing here yet.
All wikis are supposed to have a SandBox, so this one does too.
source code of the chat bot
# Author: gry@lecturify.net
# Licence: public domain
# Year: 2020-2021
# Date: Jan 28th 2021 (v1)
use strict;
use warnings;
# Subclass Bot::BasicBot to provide event-handling methods.
package UppercaseBot;
use base qw(Bot::BasicBot);
use Future::Queue;
use Future::AsyncAwait;
use feature qw(signatures);
async sub send_with_ack ($self, $ack_queue, $to_send, $topic, $chan) {
foreach my $part (@{$to_send}) {
foreach my $msg (split '\n', $part){
$self->say(channel => $chan, body => $msg);
}
# $self->say(channel => $chan, body => "Topic $topic completed. To start > await $self->{ack_queue}->shift;
}
}
sub said {
my $self = shift;
my $msg = shift; # Contains the message that the bot heard.
my @args = split ' ', $msg->{body};
my $argslength = scalar @args;
if($argslength eq 2){
my $cmd = $args[0];
my $topic = $args[1];
my @chunks = ();
if ($cmd eq 'start' and $topic){
$self->{ack_queue} = Future::Queue->new;
my $filename = "l/$topic.md";
open(my $fh, '<:encoding(UTF-8)', $filename) or $self->say(channel > my $break = 1; my $chunk = '';
while (my $row = <$fh>) {
chomp $row; if($break){$chunk = $row;$break=0;}
elsif($row eq '----'){push (@chunks, $chunk); $break = 1;}
else{$chunk="$chunk\n$row";}
print "$row\n";
}
#@chunks = ("test 1\ntest 2", "3\n4\n5");
$self->{future} = $self->send_with_ack($self->{ack_queue}, \@chunks> $self->{future}->on_ready(sub { delete $self->{future} });
}
}
if($msg->{body} eq "next") {
$self->{ack_queue}->push(1); # ack_queue undefined here -- can't push t> }
# $self->{future}->on_ready(sub { delete $self->{future} });
# Create an object of your Bot::BasicBot subclass and call its run method.
package main;
my $bot = UppercaseBot->new(
server => 'irc.libera.chat',
port => '6667',
channels => ['#lecturify'],
nick => 'lbot',
name => 'bot owner: gry',
);
$bot->run();
how to define a course
put it in l/coursename.md
content goes like this
some text for Lbot to say
some more text to say more
----
this separator causes the bot to pause
and this is more to say
----
any issues with this bot, query #lecturify channel at libera IRC network
Thanks