Recent changes to this wiki:
lecturify
diff --git a/index.mdwn b/index.mdwn index eeffb5d..5940aed 100644 --- a/index.mdwn +++ b/index.mdwn @@ -68,7 +68,7 @@ package main; my $bot = UppercaseBot->new( server => 'irc.libera.chat', port => '6667', - channels => ['#lbot'], + channels => ['#lecturify'], nick => 'lbot', name => 'bot owner: gry', ); @@ -91,6 +91,6 @@ and this is more to say ---- ```` -any issues with this bot, query #lbot channel at libera IRC network +any issues with this bot, query #lecturify channel at libera IRC network Thanks
`
diff --git a/index.mdwn b/index.mdwn index af52219..eeffb5d 100644 --- a/index.mdwn +++ b/index.mdwn @@ -74,7 +74,7 @@ my $bot = UppercaseBot->new( ); $bot->run(); -``` +```` # how to define a course
diff --git a/index.mdwn b/index.mdwn index e1b0835..af52219 100644 --- a/index.mdwn +++ b/index.mdwn @@ -4,6 +4,7 @@ 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
code
diff --git a/index.mdwn b/index.mdwn new file mode 100644 index 0000000..e1b0835 --- /dev/null +++ b/index.mdwn @@ -0,0 +1,95 @@ +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 => ['#lbot'], + 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 #lbot channel at libera IRC network + +Thanks
initial commit
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eecda60 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.ikiwiki