From 7bc381479e15646dfec98cb206aa228a656e5a26 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Wed, 3 Dec 2014 21:33:04 +0100 Subject: Bootstrapped arthur implementation in perl --- .gitignore | 2 ++ Avalon.pm | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ INSTALL.markdown | 9 +++++++++ arthur.cfg.example | 11 +++++++++++ arthur.pl | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 .gitignore create mode 100644 Avalon.pm create mode 100644 INSTALL.markdown create mode 100644 arthur.cfg.example create mode 100755 arthur.pl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38b9ef8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.swp +arthur.cfg diff --git a/Avalon.pm b/Avalon.pm new file mode 100644 index 0000000..3bf30b2 --- /dev/null +++ b/Avalon.pm @@ -0,0 +1,53 @@ +package Bot::BasicBot::Pluggable::Module::Avalon; + +use strict; +use warnings; +use v5.12; +use experimental qw(switch); + +use base qw(Bot::BasicBot::Pluggable::Module); + +sub help { + return "The avalon game simulator : https://github.com/adyxax/avalon-arthur"; +} + +sub told { + my ( $self, $mess ) = @_; + my $body = $mess->{body}; + my $ispriv = defined $mess->{address}; + + my ( $command, @args ) = split /\s+/, $mess->{body}; + given ($command) { + when ("REGISTER") {} + when ("REGISTERED") {} + when ("UNREGISTER") {} + when ("UNREGISTERED") {} + when ("GAMESTART") {} + when ("ROLE") {} + when ("KING") {} + when ("RULENOW") {} + when ("TEAM") {} + when ("VOTE") {} + when ("VOTENOW") {} + when ("VOTERESULT") {} + when ("QUESTRESULT") {} + when ("KILLMERLIN") {} + when ("KILLMERLINNOW") {} + when ("KILL") {} + when ("WINNERSIDE") {} + when ("INFO") {} + when ("GAMEURL") {} + when ("ERR_NICK_RESERVED") {} + when ("ERR_PROTOCOL_MISMATCH") {} + when ("ERR_BANNED") {} + when ("ERR_INVALID_TEAM") {} + when ("ERR_INVALID_VOTE") {} + when ("ERR_VOTE_TIMEOUT") {} + when ("ERR_NOT_THE_ASSASSIN") {} + when ("ERR_NOT_NOW") {} + when ("ERR_JOIN_AVALON_FIRST") {} + default {} + } +} + +1; diff --git a/INSTALL.markdown b/INSTALL.markdown new file mode 100644 index 0000000..1c07e06 --- /dev/null +++ b/INSTALL.markdown @@ -0,0 +1,9 @@ +Perl Version +------------ +5.12 + +Required Perl modules +--------------------- +Bot::BasicBot::Pluggable +Config::Simple +POE::Component::SSLify diff --git a/arthur.cfg.example b/arthur.cfg.example new file mode 100644 index 0000000..ad80555 --- /dev/null +++ b/arthur.cfg.example @@ -0,0 +1,11 @@ +[admin] +password = admin_password + +[irc] +nick = arthur +ircname = Arthur the Avalon Game Master +server = example.org +port = 6667 +password = +channel = "#avalon" +ssl = 1 diff --git a/arthur.pl b/arthur.pl new file mode 100755 index 0000000..f2d0ec1 --- /dev/null +++ b/arthur.pl @@ -0,0 +1,34 @@ +#!/usr/bin/env perl + +use warnings; +use strict; + +package Avalon::Arthur; +{ + $Avalon::Arthur::VERSION = '0.01'; +} + +use Bot::BasicBot::Pluggable; +use Config::Simple; + +my %cfg; +Config::Simple->import_from('arthur.cfg', \%cfg); + +my $bot = Bot::BasicBot::Pluggable->new( + nick => $cfg{'irc.nick'}, + ircname => $cfg{'irc.ircname'}, + server => $cfg{'irc.server'}, + port => $cfg{'irc.port'}, + password => $cfg{'irc.password'}, + ssl => $cfg{'irc.ssl'}, + channels => ($cfg{'irc.channel'}), + store => Bot::BasicBot::Pluggable::Store->new(), +); +$bot->{cfg} = \%cfg; + +$bot->load("Auth"); +$bot->{store_object}->{store}->{Auth}->{password_admin} = $cfg{'admin.password'}; +$bot->load("Loader"); +$bot->load("Avalon"); + +$bot->run(); -- cgit v1.2.3