Download the PHP package cyrille-hugues/alyosha without Composer
On this page you can find all versions of the php package cyrille-hugues/alyosha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package alyosha
Alyosha
What is this ?
Alyosha is a framework for IRC bot, and basically a event driven framework to fiddle with for any purpose – be it a cross social media bot or a web server (please don't do this).
Why ?
Because the other framework for IRC were entirely focused on IRC and I wanted something cross medium. By writing a module, you can wire up Slack, Facebook bot, ...
It's written in PHP because I like this language pretty much and I started before thinking about the asynchronous needs of this project.
Usage
Requirements
- PHP, no kidding
- composer
Installation
Create a new composer project with this library.
Add the following bot.php
to the project
You can now start the bot, which does nothing because he doesn't have any modules.
Your first use
Let's say you use IRC to chat with some friends and want to celebrate the leet time, which is 13:37. For this, you need the following modules:
- TimeModule
- Fire the
time_module.date
with the time every seconds so that you can trigger an event when you want.
- Fire the
- IrcModule
- Connect to IRC servers and channels and send you events for every activities
- IrcAdminModule
- You don't want a bot without a master, right ?
So let's add them to the mix in bot.php
.
Execute the script again: php bot.php
.
Wow it's writing a whole bunch of text !
Yep, it connected to irc.iiens.net
server and handled all the tedious work to get you to the Alyosha
channel.
Nice, that's not where I want it to connect.
Ok, let's talk about configuration.
Configuration
If you read your bot.php
script, you have this line:
It create the kernel with a .yml file from the lib. Let's write our own config.yml
.
Let's start with the IRC configuration:
Here we configured the bot to connect to my.super.server
with the nickname i_m_a_robot
. You can make it connect to several server
by adding another key (see https://symfony.com/doc/3.3/components/yaml.html).
For this server we make it connect to a list of one chan, doc_chan.
Since we are responsible, we use IrcAdminModule which need a password for you to authenticate yourself.
Now, let's make our bot take this configuration into account by modifying this line
to
and start the bot again. It connect to your channel with the provided nickname ... and does nothing. Let's change that.
Scripting
Configuring composer to autoload our classes
Look, i'm not a monster to send scripting like it's PHP4 with include
and require
.
Add the following to your composer.json
and run composer install
again. Now you can write PHP classes in the src
and use Bot\Smthg
as
in every modern PHP files.
Creating your first module
Create a src/LeetModule.php
with this content
and add it to the bot.php
script.
Now you can execute php bot.php
and at 13:37 every day, it will output "LEET TIME !!" in all the channels.
Managing Alyosha
Don't let the script in a random window on a computer/server. Please use PM2 to manage Alyosha's process.