Compare commits

..

No commits in common. "6663651c0b425dc13ad181b2604f2e3820980cbe" and "8a80ff8d93113ba566f2aaeac1ff9bf4d5465baf" have entirely different histories.

11 changed files with 58 additions and 100 deletions

3
.gitignore vendored
View File

@ -1,6 +1,5 @@
raven.mono
**.pkg.tar.zst
TheRaven-*.pkg.tar.zst
pkg/
src/
.config
wiki/

12
LICENSE
View File

@ -16,16 +16,12 @@
ANINIX ADDENDUM
Trademark 2017 (https://aninix.net/)
Trademark Pending 2017 (https://aninix.net/irc/)
The "AniNIX" name and |> logo are trademarked as of 2017/11/21.
AniNIX materials may be reproduced and re-used (though you must
The "AniNIX" name and |> logo is trademark-pending as of 2017. All
AniNIX materials can be reproduced and re-used, though you must
contact the admins of the network to get written permission to use
the AniNIX name or logo) so long as such reproduction or re-use
does not inhibit the original AniNIX use of the same.
the AniNIX name.
Attribution is appreciated for other materials but not legally
required or necessary.
"AniNIX" trademark serial: 87177883
|> Logo trademark serial: 87177887

View File

@ -1,14 +1,17 @@
CONFDIR = ${pkgdir}/usr/local/etc/TheRaven
INSTALLDIR = ${pkgdir}/opt/aninix/TheRaven
SCRIPTS != ls -1 *.bash
compile: clean ./chatbot-support.bash ./math-support.bash
(mcs -out:raven.mono /opt/aninix/Uniglot/CSharp/*.csharp *.csharp Raven.csharp 2>&1 | grep -v CS2002); printf ""
clean:
for i in raven.mono; do if [ -f $$i ]; then rm $$i; fi; done
test: compile
cd ./sample-confs; mono ../raven.mono -c sample.conf -v -h
install: compile
source $$PWD/installscript && pre_install || true
install -o raven -g raven -m 0750 -d ${INSTALLDIR}
for script in ${SCRIPTS} raven.mono; do install -o raven -g raven -m 0640 $$script ${INSTALLDIR}; done
mkdir -p ${pkgdir}/opt
cp raven.mono ${pkgdir}/opt/raven.mono
if [ ! -d ${CONFDIR} ]; then mkdir -p ${CONFDIR}; cp sample-confs/* ${CONFDIR}; fi
# Hook to deprivilege bot
make checkperm
@ -16,26 +19,15 @@ install: compile
mkdir -p ${pkgdir}/usr/lib/systemd/system/
cp ./raven.service ${pkgdir}/usr/lib/systemd/system/raven.service
clean:
for i in raven.mono; do if [ -f $$i ]; then rm $$i; fi; done
reverse: ${pkgdir}/usr/lib/systemd/system/raven.service
cp ${pkgdir}/usr/lib/systemd/system/raven.service .
uninstall:
rm -Rf ${INSTALLDIR} ${CONFDIR}
systemctl disable --now raven.service
rm /usr/lib/systemd/system/raven.service
test: compile
cd ./sample-confs; mono ../raven.mono -c sample.conf -v -h
checkperm: ${INSTALLDIR}/raven.mono
chown -R raven:raven ${INSTALLDIR} ${CONFDIR}
chmod 0600 ${INSTALLDIR}/* ${CONFDIR}/*
chmod 0700 ${CONFDIR} ${INSTALLDIR}
checkperm: ${pkgdir}/opt/raven.mono
if ! id raven; then sudo useradd raven; echo User raven added; fi
chown -R raven:raven ${pkgdir}/opt/raven.mono ${CONFDIR}*
chmod 0600 ${pkgdir}/opt/raven.mono ${CONFDIR}*/*
chmod 0700 ${CONFDIR}*
diff:
diff ./raven.service ${pkgdir}/usr/lib/systemd/system/raven.service
diff ./sample.conf ${pkgdir}/usr/local/etc/TheRaven/raven.conf
reverse: /usr/lib/systemd/system/raven.service /usr/local/etc/TheRaven
cp /usr/lib/systemd/system/raven.service .
cp ${INSTALLDIR}/*.bash .

View File

@ -17,10 +17,10 @@ license=('custom')
groups=()
provides=("${pkgname}")
conflicts=()
replaces=("${pkgname,,}" "aninix-${pkgname,,}")
replaces=("${pkgname,,}", "aninix-${pkgname,,}")
backup=()
options=()
install=installscript
install=
changelog=
source=()
noextract=()

View File

@ -1,37 +1,16 @@
This is a simple IRC bot for the AniNIX's operations.
# Etymology
The Raven is a named after the [common raven](https://en.wikipedia.org/wiki/Raven) by [DarkFeather](/DarkFeather). There's a lot of history there, but it's effectively that user's namesake & avatar.
# Relevant Files and Software
The Raven's source code can be compiled into a deployable agent. To enable this bot, just install the package from [the AniNIX repository](https://maat.aninix.net) or run the following:
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 enable --now raven.service
sudo systemctl start raven.service
sudo systemctl enable raven.service
```
The configuration lives in `/usr/local/etc/TheRaven`. Unique files are provided for logins, search functions, help text, CrowFacts and magic8 functions, etc.
TheRaven is dependent on /bin/bash and [wget](https://wiki.archlinux.org/index.php/Wget) for the TinyURL features. It is dependent on the [Mono](https://wiki.archlinux.org/index.php/Mono) package for compiling on Linux.
TheRaven also expects an OS script, `api-keys`, that will return a TinyURL API key when run with the `tinyurl` parameter.
# Available Clients
There are no direct clients -- connect to [IRC](https://irc.aninix.net) or our Discord bridge. Use `r.help` in any channel where TheRaven is present to find out what it can do, or PM it directly.
# Equivalents or Competition
[Sopel](https://sopel.chat/) is an equivalent, maintained IRC bot. We maintain our own for the use case of testing code development.
Various Discord bots also perform the same function.
# Functionality
This IRC bot has some simple commands that can be found by most users with `r.help` in whatever channel the bot has joined.
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`.

View File

@ -283,7 +283,7 @@ namespace AniNIX.TheRaven {
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();
try {
String aliceResponse = ExecuteCommand.Run(String.Format("bash /opt/aninix/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");
send.PrivMsg(aliceResponse,(response.target.Equals(Nick))?response.user:response.target);
} catch (Exception e) {

View File

@ -84,7 +84,7 @@ namespace AniNIX.TheRaven {
if (bySpace.Length < 2) {
} else {
send.PrivMsg(ExecuteCommand.Run(String.Format("/bin/bash /opt/aninix/TheRaven/math-support.bash \"{0}\"",incoming.message.Replace("r.math ","").Replace("'","").Replace("\"",""))),(incoming.target.Equals(theRaven.Nick))?incoming.user:incoming.target);
send.PrivMsg(ExecuteCommand.Run(String.Format("/bin/bash /usr/local/src/TheRaven/math-support.bash \"{0}\"",incoming.message.Replace("r.math ","").Replace("'","").Replace("\"",""))),(incoming.target.Equals(theRaven.Nick))?incoming.user:incoming.target);
}
connection.Write(send);
return;
@ -127,7 +127,7 @@ namespace AniNIX.TheRaven {
connection.Write(send);
return;
case "r.ip":
send.PrivMsg(ExecuteCommand.Run("/bin/bash /opt/aninix/TheRaven/ip.bash"),(incoming.target.Equals(theRaven.Nick))?incoming.user:incoming.target);
send.PrivMsg(ExecuteCommand.Run("curl -s $(ip r list | grep default | cut -f 3 -d \" \"):80 | grep \"WAN IP\" | cut -f 13 -d \">\" | cut -f 1 -d \"<\""),(incoming.target.Equals(theRaven.Nick))?incoming.user:incoming.target);
connection.Write(send);
return;
case "r.searches":

View File

@ -1,8 +0,0 @@
pre_install() {
groupadd raven &>/dev/null
useradd -g raven -s /bin/false raven &> /dev/null
}
pre_remove() {
getent passwd raven &>/dev/null && userdel raven &> /dev/null
}

View File

@ -1,2 +1,2 @@
#!/bin/bash
lynx -connect_timeout=3 -read_timeout=3 --dump 'http://m.wolframalpha.com/input/?i='"$(echo $1 | sed 's/+/%2B/g' | tr ' ' '+')"'&x=0&y=0' | cat -n | grep -E '^ 21' | head -n 1 | xargs | sed 's/^21 //'
lynx -connect_timeout=3 -read_timeout=3 --dump 'http://m.wolframalpha.com/input/?i='"$(echo $1 | sed 's/+/%2B/g' | tr ' ' '+')"'&x=0&y=0' | cat -n | egrep '^ 21' | head -n 1 | xargs | sed 's/^21 //'

View File

@ -4,7 +4,7 @@ After=network.target
[Service]
WorkingDirectory=/usr/local/etc/TheRaven
ExecStart=/usr/bin/mono /opt/aninix/TheRaven/raven.mono -c raven.conf
ExecStart=/usr/bin/mono /opt/raven.mono -c raven.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always

View File

@ -28,7 +28,7 @@ function getAPIConfigValue() {
# Get the api config value
# param attr: the attribute to look for
# returns: the attribute's value
grep -A 10 -E '^\[ API \]$' "$file" | grep -m 1 -E '^'"$1"'=' | sed 's/^'"$1"'=//'
egrep -A 10 '^\[ API \]$' "$file" | egrep -m 1 '^'"$1"'=' | sed 's/^'"$1"'=//'
}
# Parse arguments