Removed Pushbullet support
Added Usage function Reformated PKGBUILD to fit standards Corrections to README.md Removed static paths in favor of referential. Test case update Removed unneeded statements from crowfacts
This commit is contained in:
parent
778416c0a2
commit
5e360b0da2
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
|||||||
raven.mono
|
raven.mono
|
||||||
theraven-*.tar.xz
|
TheRaven-*.pkg.tar.zst
|
||||||
pkg/
|
pkg/
|
||||||
src/
|
src/
|
||||||
.config
|
.config
|
||||||
|
13
Makefile
13
Makefile
@ -1,28 +1,23 @@
|
|||||||
CONFDIR = ${pkgdir}/usr/local/etc/TheRaven
|
CONFDIR = ${pkgdir}/usr/local/etc/TheRaven
|
||||||
|
|
||||||
compile: clean ./chatbot-support.bash ./math-support.bash /usr/sbin/pb
|
compile: clean ./chatbot-support.bash ./math-support.bash
|
||||||
mkdir -p ${pkgdir}/usr/local/src/
|
(mcs -out:raven.mono /opt/aninix/Uniglot/CSharp/*.csharp *.csharp Raven.csharp 2>&1 | grep -v CS2002); printf ""
|
||||||
(mcs -out:raven.mono /opt/aninix/SharedLibraries/CSharp/*.csharp *.csharp Raven.csharp 2>&1 | grep -v CS2002); printf ""
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
for i in raven.mono; do if [ -f $$i ]; then rm $$i; fi; done
|
for i in raven.mono; do if [ -f $$i ]; then rm $$i; fi; done
|
||||||
|
|
||||||
test: compile
|
test: compile
|
||||||
script -c "mono ./raven.mono -c raven-test.conf -v" ${pkgdir}/tmp/raven-test.log
|
cd ./sample-confs; mono ../raven.mono -c sample.conf -v -h
|
||||||
|
|
||||||
install: compile
|
install: compile
|
||||||
mkdir -p ${pkgdir}/opt
|
mkdir -p ${pkgdir}/opt
|
||||||
cp raven.mono ${pkgdir}/opt/raven.mono
|
cp raven.mono ${pkgdir}/opt/raven.mono
|
||||||
if [ ! -d ${CONFDIR} ]; then mkdir -p ${CONFDIR}; cp sample-confs/* ${CONFDIR}; fi
|
if [ ! -d ${CONFDIR} ]; then mkdir -p ${CONFDIR}; cp sample-confs/* ${CONFDIR}; fi
|
||||||
# Hook to deprivilege bot
|
# Hook to deprivilege bot
|
||||||
if ! getent passwd raven; then useradd -M -G git,ircd,api -d ${CONFDIR} raven; fi
|
|
||||||
echo "raven:$$(/usr/sbin/pwgen 24 1)" | chpasswd;
|
|
||||||
make checkperm
|
make checkperm
|
||||||
# Hook for Heartbeat
|
|
||||||
if [ -f ${pkgdir}/usr/local/etc/Heartbeat/services.list ] && [ `grep -c TheRaven ${pkgdir}/usr/local/etc/Heartbeat/services.list` -eq 0 ]; then echo "" >> ${pkgdir}/usr/local/etc/Heartbeat/services.list; fi
|
|
||||||
# Hook for Systemd
|
# Hook for Systemd
|
||||||
mkdir -p ${pkgdir}/usr/lib/systemd/system/
|
mkdir -p ${pkgdir}/usr/lib/systemd/system/
|
||||||
cp /usr/local/src/TheRaven/raven.service ${pkgdir}/usr/lib/systemd/system/raven.service
|
cp ./raven.service ${pkgdir}/usr/lib/systemd/system/raven.service
|
||||||
|
|
||||||
reverse: ${pkgdir}/usr/lib/systemd/system/raven.service
|
reverse: ${pkgdir}/usr/lib/systemd/system/raven.service
|
||||||
cp ${pkgdir}/usr/lib/systemd/system/raven.service .
|
cp ${pkgdir}/usr/lib/systemd/system/raven.service .
|
||||||
|
33
PKGBUILD
33
PKGBUILD
@ -1,20 +1,23 @@
|
|||||||
# Maintainer: Shikoba Kage <darkfeather@aninix.net>
|
# Maintainer: DarkFeather <ircs://aninix.net:6697/darkfeather>
|
||||||
pkgname=theraven
|
depends=('mono>=5.0.0' 'curl' 'grep' 'bash>=4.4' 'git>=2.13' 'wget' 'nmap>=7.70')
|
||||||
pkgver=0.1
|
|
||||||
pkgrel=1
|
|
||||||
epoch=
|
|
||||||
pkgdesc="AniNIX::TheRaven \\\\ IRC Bot"
|
|
||||||
arch=("x86_64")
|
|
||||||
url="https://aninix.net/foundation/TheRaven"
|
|
||||||
license=('custom')
|
|
||||||
groups=()
|
|
||||||
depends=('mono>=5.0.0' 'curl' 'grep' 'bash>=4.4' 'git>=2.13' 'pushbullet-cli' 'lynx' 'wget' 'nmap>=7.70')
|
|
||||||
makedepends=('make>=4.2' 'pwgen')
|
makedepends=('make>=4.2' 'pwgen')
|
||||||
checkdepends=()
|
checkdepends=()
|
||||||
optdepends=()
|
optdepends=()
|
||||||
provides=('theraven')
|
pkgname="$(git config remote.origin.url | rev | cut -f 1 -d '/' | rev | sed 's/.git$//')"
|
||||||
|
pkgver="$(git describe --tag --abbrev=0)"."$(git rev-parse --short HEAD)"
|
||||||
|
pkgrel=1
|
||||||
|
pkgrel() {
|
||||||
|
echo $(( `git log "$(git describe --tag --abbrev=0)"..HEAD | grep -c commit` + 1 ))
|
||||||
|
}
|
||||||
|
epoch="$(git log | grep -c commit)"
|
||||||
|
pkgdesc="$(head -n 1 README.md)"
|
||||||
|
arch=("x86_64")
|
||||||
|
url="$(git config remote.origin.url | sed 's/.git$//')"
|
||||||
|
license=('custom')
|
||||||
|
groups=()
|
||||||
|
provides=("${pkgname}")
|
||||||
conflicts=()
|
conflicts=()
|
||||||
replaces=()
|
replaces=("${pkgname,,}", "aninix-${pkgname,,}")
|
||||||
backup=()
|
backup=()
|
||||||
options=()
|
options=()
|
||||||
install=
|
install=
|
||||||
@ -33,8 +36,8 @@ build() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check() {
|
check() {
|
||||||
# We're not using test because it makes an actual connection. That case is useful but not quite as a regression the way PKGBUILD needs.
|
chmod -R u+r ../pkg
|
||||||
ls -l ../raven.mono
|
make -C .. test
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
|
2
README
2
README
@ -1,2 +0,0 @@
|
|||||||
This project is enabled for AniNIX::Bazaar. You can check it out remotely with the bzr package.
|
|
||||||
Project URL is bzr://bazaar.aninix.net/TheRaven
|
|
17
README.md
Normal file
17
README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
This is a simple IRCbot for the AniNIX's operations.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
To enable this bot, just install the package from [the AniNIX repository](https://maat.aninix.net) or run the following:
|
||||||
|
```
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
sudo systemctl start raven.service
|
||||||
|
sudo systemctl enable raven.service
|
||||||
|
```
|
||||||
|
|
||||||
|
# Functionality
|
||||||
|
This IRCbot has some simple commands that can be found by most users with `r.help` in whatever channel the bot has joined.
|
||||||
|
|
||||||
|
Administrative functions are controlled by the access lists and can be found with `r.adminhelp`.
|
||||||
|
|
||||||
|
The bot can also be invoked with `mono ./raven.mono -h` to get more detailed help.
|
111
Raven.csharp
111
Raven.csharp
@ -59,7 +59,7 @@ namespace AniNIX.TheRaven {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read from the files in the /usr/local/etc/TheRaven directory to configure this Raven
|
/// Read from the files in the current directory to configure this Raven
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// TODO: This and ParseArgs may get punted into their own static class to improve readability.
|
// TODO: This and ParseArgs may get punted into their own static class to improve readability.
|
||||||
private void ConfigureSelfFromFiles() {
|
private void ConfigureSelfFromFiles() {
|
||||||
@ -119,10 +119,30 @@ namespace AniNIX.TheRaven {
|
|||||||
searchesIndex = searchIndexBuilder.ToString();
|
searchesIndex = searchIndexBuilder.ToString();
|
||||||
|
|
||||||
//Read the globals
|
//Read the globals
|
||||||
magic8 = (new Configure("/usr/local/etc/TheRaven/magic8.txt")).GetLines();
|
magic8 = (new Configure("magic8.txt")).GetLines();
|
||||||
crowFacts = (new Configure("/usr/local/etc/TheRaven/crowfacts.txt")).GetLines();
|
crowFacts = (new Configure("crowfacts.txt")).GetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Print helptext and exit
|
||||||
|
/// param retcode: what to return to the system.
|
||||||
|
/// </summary>
|
||||||
|
public void Usage() {
|
||||||
|
ReportMessage.Log(Verbosity.Always,"Usage: mono ./raven.mono -c conf # start the Raven with the conf file");
|
||||||
|
ReportMessage.Log(Verbosity.Always,"Usage: mono ./raven.mono -h # Get help");
|
||||||
|
ReportMessage.Log(Verbosity.Always,"");
|
||||||
|
ReportMessage.Log(Verbosity.Always,"The following flags are optional:");
|
||||||
|
ReportMessage.Log(Verbosity.Always,"-n Nickname");
|
||||||
|
ReportMessage.Log(Verbosity.Always,"-t Host");
|
||||||
|
ReportMessage.Log(Verbosity.Always,"-p Port");
|
||||||
|
ReportMessage.Log(Verbosity.Always,"-v Verbose");
|
||||||
|
ReportMessage.Log(Verbosity.Always,"-q Quiet");
|
||||||
|
ReportMessage.Log(Verbosity.Always,"-P NickServ passphrase");
|
||||||
|
ReportMessage.Log(Verbosity.Always,"-a Autosend command");
|
||||||
|
throw new RavenExitedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parse arguments from the command line.
|
/// Parse arguments from the command line.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -135,7 +155,7 @@ namespace AniNIX.TheRaven {
|
|||||||
case "-n":
|
case "-n":
|
||||||
if (i < args.Length-1) Nick = args[++i];
|
if (i < args.Length-1) Nick = args[++i];
|
||||||
break;
|
break;
|
||||||
case "-h":
|
case "-t":
|
||||||
if (i < args.Length-1) Host = args[++i];
|
if (i < args.Length-1) Host = args[++i];
|
||||||
break;
|
break;
|
||||||
case "-p":
|
case "-p":
|
||||||
@ -155,19 +175,15 @@ namespace AniNIX.TheRaven {
|
|||||||
case "-P":
|
case "-P":
|
||||||
if (i < args.Length-1) _nickServPass = args[++i];
|
if (i < args.Length-1) _nickServPass = args[++i];
|
||||||
break;
|
break;
|
||||||
//TODO: Add daemonizing?
|
|
||||||
case "-a":
|
case "-a":
|
||||||
if (i < args.Length-1) _autoSend = args[++i];
|
if (i < args.Length-1) _autoSend = args[++i];
|
||||||
break;
|
break;
|
||||||
case "--help":
|
case "-h":
|
||||||
//TODO Add helptext
|
Usage();
|
||||||
break;
|
return;
|
||||||
case "-c":
|
case "-c":
|
||||||
if (i < args.Length-1) _configFile = args[++i];
|
if (i < args.Length-1) _configFile = args[++i];
|
||||||
break;
|
break;
|
||||||
case "--version":
|
|
||||||
ReportMessage.Log(Verbosity.Always,"AniNIX::TheRaven version 0.2");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,6 +200,7 @@ namespace AniNIX.TheRaven {
|
|||||||
// If we have arguments
|
// If we have arguments
|
||||||
this.ParseArguments(args);
|
this.ParseArguments(args);
|
||||||
this.ConfigureSelfFromFiles();
|
this.ConfigureSelfFromFiles();
|
||||||
|
this._isDisposed = false;
|
||||||
ReportMessage.Log(Verbosity.VeryVerbose,"Started with these values:");
|
ReportMessage.Log(Verbosity.VeryVerbose,"Started with these values:");
|
||||||
ReportMessage.Log(Verbosity.VeryVerbose,this.ToString());
|
ReportMessage.Log(Verbosity.VeryVerbose,this.ToString());
|
||||||
}
|
}
|
||||||
@ -260,26 +277,12 @@ namespace AniNIX.TheRaven {
|
|||||||
if (response != null && response.message != null && response.message.Length > 3 && response.message.Substring(0,2).Equals("r.")) {
|
if (response != null && response.message != null && response.message.Length > 3 && response.message.Substring(0,2).Equals("r.")) {
|
||||||
RavenCommand.Respond(_connection,response,this);
|
RavenCommand.Respond(_connection,response,this);
|
||||||
} else if (response != null) {
|
} else if (response != null) {
|
||||||
//Try to notify the admins when a given string is found in a given channel
|
|
||||||
String result;
|
|
||||||
if (notifications.TryGetValue(response.target,out result)) {
|
|
||||||
if (response.message.Contains(result)) {
|
|
||||||
try {
|
|
||||||
ReportMessage.Log(Verbosity.Verbose,"Sending notification.");
|
|
||||||
ExecuteCommand.Run(String.Format("/usr/local/bin/djinni admin \"Found {1} in {0}\"",response.target,result));
|
|
||||||
} catch (Exception e) {
|
|
||||||
ReportMessage.Log(Verbosity.Error,e.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Integrate with the ALICE chatbot project.
|
// Integrate with the ALICE chatbot project.
|
||||||
// TODO Create a local instance instead
|
// TODO Create a local instance instead
|
||||||
if (response.msgCode.Equals("PRIVMSG") && !String.IsNullOrWhiteSpace(response.message) && (response.target.Equals(Nick) || response.message.StartsWith(String.Format("{0}:",Nick)) || response.message.EndsWith(String.Format("{0}!",Nick)) || response.message.EndsWith(String.Format("{0}?",Nick)) || response.message.EndsWith(String.Format("{0}.",Nick)) || response.message.EndsWith(String.Format("{0}",Nick)))) {
|
if (response.msgCode.Equals("PRIVMSG") && !String.IsNullOrWhiteSpace(response.message) && (response.target.Equals(Nick) || response.message.StartsWith(String.Format("{0}:",Nick)) || response.message.EndsWith(String.Format("{0}!",Nick)) || response.message.EndsWith(String.Format("{0}?",Nick)) || response.message.EndsWith(String.Format("{0}.",Nick)) || response.message.EndsWith(String.Format("{0}",Nick)))) {
|
||||||
IRCClientMessage send = new IRCClientMessage();
|
IRCClientMessage send = new IRCClientMessage();
|
||||||
try {
|
try {
|
||||||
String aliceResponse = ExecuteCommand.Run(String.Format("bash /usr/local/src/TheRaven/chatbot-support.bash \"{0}\" {1}",response.message.Replace("'","").Replace("\"","").Split('\n')[0].Trim(),Nick)).Trim();
|
String aliceResponse = ExecuteCommand.Run(String.Format("bash ./chatbot-support.bash \"{0}\" {1}",response.message.Replace("'","").Replace("\"","").Split('\n')[0].Trim(),Nick)).Trim();
|
||||||
if (String.IsNullOrWhiteSpace(aliceResponse)) throw new Exception("No response from ALICE chatbot service");
|
if (String.IsNullOrWhiteSpace(aliceResponse)) throw new Exception("No response from ALICE chatbot service");
|
||||||
send.PrivMsg(aliceResponse,(response.target.Equals(Nick))?response.user:response.target);
|
send.PrivMsg(aliceResponse,(response.target.Equals(Nick))?response.user:response.target);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -318,7 +321,9 @@ namespace AniNIX.TheRaven {
|
|||||||
/// Close the _connection
|
/// Close the _connection
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CloseConnection() {
|
private void CloseConnection() {
|
||||||
this._connection.Dispose();
|
if (this._connection != null) {
|
||||||
|
this._connection.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -363,12 +368,15 @@ namespace AniNIX.TheRaven {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This bool indicates whether we have disposed of this Raven
|
// This bool indicates whether we have disposed of this Raven
|
||||||
public bool _isDisposed = false;
|
public bool _isDisposed = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose of this Raven's's resources responsibly.
|
/// Dispose of this Raven's's resources responsibly.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void Dispose(bool disposing) {
|
private void Dispose(bool disposing) {
|
||||||
|
if (this == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!_isDisposed) {
|
if (!_isDisposed) {
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
Host = null;
|
Host = null;
|
||||||
@ -394,29 +402,34 @@ namespace AniNIX.TheRaven {
|
|||||||
/// The default function
|
/// The default function
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static int Main(string[] args) {
|
static int Main(string[] args) {
|
||||||
Raven theRaven = new Raven(args);
|
try {
|
||||||
ReportMessage.Log(Verbosity.Verbose,"### AniNIX::TheRaven ###");
|
Raven theRaven = new Raven(args);
|
||||||
//Continue until we cleanly exit.
|
ReportMessage.Log(Verbosity.Verbose,"### AniNIX::TheRaven ###");
|
||||||
while (true) {
|
//Continue until we cleanly exit.
|
||||||
try {
|
while (true) {
|
||||||
return theRaven.Run();
|
try {
|
||||||
//If we are already identified, we're done.
|
return theRaven.Run();
|
||||||
} catch (AlreadyIdentifiedException e) {
|
//If we are already identified, we're done.
|
||||||
ReportMessage.Log(Verbosity.Error,"There is already a Raven on this Host.");
|
} catch (AlreadyIdentifiedException e) {
|
||||||
ReportMessage.Log(Verbosity.Error,e.Message);
|
ReportMessage.Log(Verbosity.Error,"There is already a Raven on this Host.");
|
||||||
return 0;
|
ReportMessage.Log(Verbosity.Error,e.Message);
|
||||||
// Timeouts should result in a respawn
|
return 0;
|
||||||
} catch (RavenTimedOutException e) {
|
// Timeouts should result in a respawn
|
||||||
ReportMessage.Log(Verbosity.Always,"Connection timed out. Respawning");
|
} catch (RavenTimedOutException e) {
|
||||||
ReportMessage.Log(Verbosity.Verbose,e.Message);
|
ReportMessage.Log(Verbosity.Always,"Connection timed out. Respawning");
|
||||||
continue;
|
ReportMessage.Log(Verbosity.Verbose,e.Message);
|
||||||
//If an exception gets here, something went wrong
|
continue;
|
||||||
} catch (Exception e) {
|
//If an exception gets here, something went wrong
|
||||||
ReportMessage.Log(Verbosity.Error,"Unexpected exception caught!");
|
} catch (Exception e) {
|
||||||
ReportMessage.Log(Verbosity.Error,e.Message);
|
ReportMessage.Log(Verbosity.Error,"Unexpected exception caught!");
|
||||||
return 1;
|
ReportMessage.Log(Verbosity.Error,e.Message);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (RavenExitedException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,13 +114,6 @@ namespace AniNIX.TheRaven {
|
|||||||
ReportMessage.Log(Verbosity.Error,e.Message);
|
ReportMessage.Log(Verbosity.Error,e.Message);
|
||||||
ReportMessage.Log(Verbosity.Error,"Make sure user raven can write to /var/log/r.msg.log");
|
ReportMessage.Log(Verbosity.Error,"Make sure user raven can write to /var/log/r.msg.log");
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
ExecuteCommand.Run(String.Format("pb push \"Page from {0}\"",incoming.user));
|
|
||||||
send.PrivMsg("Sent!",incoming.user);
|
|
||||||
} catch (Exception e) {
|
|
||||||
ReportMessage.Log(Verbosity.Error,e.ToString());
|
|
||||||
send.PrivMsg("Mailer error. Could not send.",incoming.user);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
connection.Write(send);
|
connection.Write(send);
|
||||||
return;
|
return;
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=AniNIX::Raven IRC Bot
|
Description=AniNIX/Raven | IRC Bot
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
WorkingDirectory=/usr/local/etc/TheRaven
|
||||||
ExecStart=/usr/bin/mono /opt/raven.mono -c raven.conf
|
ExecStart=/usr/bin/mono /opt/raven.mono -c raven.conf
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
KillMode=process
|
KillMode=process
|
||||||
|
@ -7,7 +7,7 @@ unset channel
|
|||||||
unset message
|
unset message
|
||||||
unset passphrase
|
unset passphrase
|
||||||
export file="/usr/local/etc/TheRaven/raven.conf"
|
export file="/usr/local/etc/TheRaven/raven.conf"
|
||||||
export port="9501"
|
export port="8373"
|
||||||
export host="localhost"
|
export host="localhost"
|
||||||
|
|
||||||
# Show help
|
# Show help
|
||||||
|
@ -48,5 +48,3 @@ Native American mythology holds that Raven brought the sun, moon, stars, and fir
|
|||||||
The Norse god Odin had two ravens Huginn and Muninn (Thought and Mind) to serve as his eyes in the world.
|
The Norse god Odin had two ravens Huginn and Muninn (Thought and Mind) to serve as his eyes in the world.
|
||||||
The raven is the symbol of the Celtic figure Morrigan and the namesake of Lugh, the god responsible for creating arts and science.
|
The raven is the symbol of the Celtic figure Morrigan and the namesake of Lugh, the god responsible for creating arts and science.
|
||||||
The raven appears in the Quran but once, only to teach man to bury the dead in the story of Cain and Abel.
|
The raven appears in the Quran but once, only to teach man to bury the dead in the story of Cain and Abel.
|
||||||
GI_Auditore finds Mutated Ravens in Prototype 2 extremely annoying.
|
|
||||||
Lost_Fragment will lose in a fight with TheRaven.
|
|
||||||
|
Loading…
Reference in New Issue
Block a user