Updating r.msg to use PushBullet instead of mail

This commit is contained in:
DarkFeather 2017-12-04 16:32:37 -06:00
parent b78da4c77c
commit b377d1d969
12 changed files with 293 additions and 106 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
raven.mono raven.mono
theraven-*.tar.xz
pkg/

27
LICENSE Normal file
View File

@ -0,0 +1,27 @@
# http://www.wtfpl.net/about/
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
ANINIX ADDENDUM
Trademark Pending 2017 (https://aninix.net/irc/)
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.
Attribution is appreciated for other materials but not legally
required or necessary.

View File

@ -1,40 +1,39 @@
CONFDIR = /usr/local/etc/TheRaven CONFDIR = ${pkgdir}/usr/local/etc/TheRaven
INSTALLER != bash -c `curl -s https://aninix.net/foundation/installer-test.bash` INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | /bin/bash
compile: clean ./chatbot-support.bash ./math-support.bash compile: clean ./chatbot-support.bash ./math-support.bash /usr/sbin/pb
if [ ! -x /usr/bin/mcs ] || [ ! -x /usr/bin/mono ] || [ ! -x /usr/bin/lynx ] || [ ! -x /usr/bin/bash ] || [ ! -x /usr/bin/wget ]; then ${INSTALLER} mono wget lynx bash; fi mkdir -p ${pkgdir}/usr/local/src/
# Hook to use Djinni for notification if [ ! -d ${pkgdir}/usr/local/src/SharedLibraries ]; then git -C ${pkgdir}/usr/local/src/ clone https://aninix.net/foundation/SharedLibraries; fi
if [ ! -d ../Djinni ]; then git clone -C '..' https://aninix.net/foundation/Djinni; fi git -C ${pkgdir}/usr/local/src/SharedLibraries pull
git -C ../Djinni pull mcs -out:raven.mono ${pkgdir}/usr/local/src/SharedLibraries/CSharp/*.csharp *.csharp Raven.csharp
cd /usr/local/src/Djinni; make install
if [ ! -d ../SharedLibraries ]; then git clone -C '..' https://aninix.net/foundation/SharedLibraries; fi
git -C ../SharedLibraries pull
mcs -out:raven.mono ../SharedLibraries/CSharp/*.csharp *.csharp Raven.csharp
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" /tmp/raven-test.log script -c "mono ./raven.mono -c raven-test.conf -v" ${pkgdir}/tmp/raven-test.log
install: compile install: compile
cp raven.mono /opt/raven.mono mkdir -p ${pkgdir}/opt
if [ ! -d ${CONFDIR} ]; then mkdir -p /usr/local/etc/TheRaven; cp ./sample-conf/* ${CONFDIR}; fi cp raven.mono ${pkgdir}/opt/raven.mono
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 if ! getent passwd raven; then useradd -M -G git,ircd,api -d ${CONFDIR} raven; fi
make checkperm make checkperm
# Hook for Heartbeat # Hook for Heartbeat
if [ -f /usr/local/etc/Heartbeat/services.list ] && [ `grep -c TheRaven /usr/local/etc/Heartbeat/services.list` -eq 0 ]; then echo "" >> /usr/local/etc/Heartbeat/services.list; fi 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
cp ./raven.service /usr/lib/systemd/system/raven.service mkdir -p ${pkgdir}/usr/lib/systemd/system/
systemctl daemon-reload cp /usr/local/src/TheRaven/raven.service ${pkgdir}/usr/lib/systemd/system/raven.service
systemctl enable raven
reverse: /usr/lib/systemd/system/raven.service reverse: ${pkgdir}/usr/lib/systemd/system/raven.service
cp /usr/lib/systemd/system/raven.service . cp ${pkgdir}/usr/lib/systemd/system/raven.service .
checkperm: /opt/raven.mono checkperm: ${pkgdir}/opt/raven.mono
chown -R raven:raven /opt/raven.mono ${CONFDIR}* chown -R raven:raven ${pkgdir}/opt/raven.mono ${CONFDIR}*
chmod 0600 /opt/raven.mono ${CONFDIR}*/* chmod 0600 ${pkgdir}/opt/raven.mono ${CONFDIR}*/*
chmod 0700 ${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

44
PKGBUILD Normal file
View File

@ -0,0 +1,44 @@
# Maintainer: Shikoba Kage <darkfeather@aninix.net>
pkgname=theraven
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')
makedepends=('make>=4.2')
checkdepends=()
optdepends=()
provides=('theraven')
conflicts=()
replaces=()
backup=()
options=()
install=
changelog=
source=()
noextract=()
md5sums=()
validpgpkeys=()
prepare() {
git pull
}
build() {
make -C ..
}
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.
ls -l ../raven.mono
}
package() {
export pkgdir="${pkgdir}"
make -C .. install
install -D -m644 ../LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

View File

@ -23,7 +23,8 @@ namespace AniNIX.TheRaven {
public List<String> channels; //This is the list of channels to join public List<String> channels; //This is the list of channels to join
public List<String> whitelist; //This is the list of admin users. public List<String> whitelist; //This is the list of admin users.
public List<String> blacklist; // This is the list of blocked people. public List<String> blacklist; // This is the list of blocked people.
public String helpText; // This is the text to send when people ask for help -- this is configurable to allow for skinning public String helpText = "Available commands are r.d <dice test>, r.heartbeat, r.magic8, r.math <math problem>, r.msg <memo for admin>, r.raven, r.searches, r.tinyurl <url>, r.wikidiff \"one\" \"other\", and r.uptime";
// This is the text to send when people ask for help -- this is configurable to allow for skinning
public List<String> searches; //These are the searches public List<String> searches; //These are the searches
public String searchesIndex; //This is the helptext for the searches public String searchesIndex; //This is the helptext for the searches
public List<String> magic8; //These are the strings to return like a Magic 8-ball to questions. public List<String> magic8; //These are the strings to return like a Magic 8-ball to questions.
@ -58,17 +59,16 @@ namespace AniNIX.TheRaven {
// 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() {
String confFilePath = String.Format("/usr/local/etc/TheRaven/{0}",_configFile); if (!File.Exists(_configFile)) {
throw new Exception(String.Format("Configuration file {0} doesn't exist.",_configFile));
if (!File.Exists(confFilePath)) {
ReportMessage.Log(Verbosity.Error,"Configuration file doesn't exist.");
return;
} }
ReportMessage.Log(Verbosity.Always,String.Format("Reading from config file in /usr/local/etc/{0} and the global files in the same directory...",_configFile)); ReportMessage.Log(Verbosity.Always,String.Format("Reading from config file in {0} and the global files in the same directory...",_configFile));
Configure conf = new Configure(confFilePath); Configure conf = new Configure(_configFile);
//These are locals that will be used throughout //These are locals that will be used throughout
ReportMessage.Log(Verbosity.Verbose,"Reading login info");
try {
Dictionary<String,String> loginDefaults = conf.ReadSection("Login"); Dictionary<String,String> loginDefaults = conf.ReadSection("Login");
this.Host = loginDefaults["host"]; this.Host = loginDefaults["host"];
this.Port = Int32.Parse(loginDefaults["port"]); this.Port = Int32.Parse(loginDefaults["port"]);
@ -79,13 +79,32 @@ namespace AniNIX.TheRaven {
foreach (String channel in conf.ReadSectionLines("Rooms")) { foreach (String channel in conf.ReadSectionLines("Rooms")) {
channels.Add(String.Format("#{0}",channel)); channels.Add(String.Format("#{0}",channel));
} }
} catch (Exception e) {
throw new Exception("Failed to read default login info from Login section in configuration.");
}
//Parse the lists. //Parse the lists.
ReportMessage.Log(Verbosity.Verbose,"Building lists.");
try {
notifications = conf.ReadSection("Notifications"); notifications = conf.ReadSection("Notifications");
} catch (Exception e) {
throw new Exception("Couldn't read Notifications section.");
}
try {
whitelist = conf.ReadSectionLines("Whitelist"); whitelist = conf.ReadSectionLines("Whitelist");
} catch (Exception e) {
throw new Exception("Couldn't read Whitelist section.");
}
try {
blacklist = conf.ReadSectionLines("Blacklist"); blacklist = conf.ReadSectionLines("Blacklist");
helpText = "Available commands are r.d <dice test>, r.heartbeat, r.magic8, r.math <math problem>, r.msg <memo for admin>, r.raven, r.searches, r.tinyurl <url>, and r.uptime"; } catch (Exception e) {
throw new Exception("Couldn't read Blacklist section.");
}
try {
searches = conf.ReadSectionLines("Searches"); searches = conf.ReadSectionLines("Searches");
} catch (Exception e) {
throw new Exception("Couldn't read Searches section.");
}
StringBuilder searchIndexBuilder = new StringBuilder(); StringBuilder searchIndexBuilder = new StringBuilder();
foreach (String searchLine in searches) { foreach (String searchLine in searches) {
String[] byPipe = searchLine.Split('|'); String[] byPipe = searchLine.Split('|');
@ -138,7 +157,7 @@ namespace AniNIX.TheRaven {
//TODO Add helptext //TODO Add helptext
break; break;
case "-c": case "-c":
if (i < args.Length-1) _configFile = args[++i]; if (i < args.Length-1) _configFile = String.Format("/usr/local/etc/TheRaven/{0}",args[++i]);
break; break;
case "--version": case "--version":
ReportMessage.Log(Verbosity.Always,"AniNIX::TheRaven version 0.2"); ReportMessage.Log(Verbosity.Always,"AniNIX::TheRaven version 0.2");
@ -165,16 +184,17 @@ namespace AniNIX.TheRaven {
/// <summary> /// <summary>
/// Create a raven with default settings. /// Create a raven with default settings.
/// </summary> /* </summary>
public Raven(String host = "localhost", int port = 6667, String nick = "TheRaven-Guest", String nickServPass = "null", String autoSend = null, String _configFile = "raven.conf", Verbosity verbosity = Verbosity.Verbose) { public Raven(String host = "localhost", int port = 6667, String nick = "TheRaven-Guest", String nickServPass = "null", String autoSend = null, String configFile = "raven.conf", Verbosity verbosity = Verbosity.Verbose) {
this.Host = host; this.Host = host;
Port = port; Port = port;
Nick = nick; Nick = nick;
_nickServPass = nickServPass; _nickServPass = nickServPass;
_autoSend = autoSend; _autoSend = autoSend;
this._configFile = _configFile; this._configFile = String.Format("/usr/local/etc/TheRaven/{0}",configFile);
ReportMessage.verbosity = verbosity; ReportMessage.verbosity = verbosity;
} }
*/
/// <summary> /// <summary>
/// Identify to the server and join the initial channels /// Identify to the server and join the initial channels
@ -236,6 +256,7 @@ namespace AniNIX.TheRaven {
if (notifications.TryGetValue(response.target,out result)) { if (notifications.TryGetValue(response.target,out result)) {
if (response.message.Contains(result)) { if (response.message.Contains(result)) {
try { try {
ReportMessage.Log(Verbosity.Verbose,"Sending notification.");
ExecuteCommand.Run(String.Format("/usr/local/bin/djinni admin \"Found {1} in {0}\"",response.target,result)); ExecuteCommand.Run(String.Format("/usr/local/bin/djinni admin \"Found {1} in {0}\"",response.target,result));
} catch (Exception e) { } catch (Exception e) {
ReportMessage.Log(Verbosity.Error,e.ToString()); ReportMessage.Log(Verbosity.Error,e.ToString());
@ -344,7 +365,8 @@ namespace AniNIX.TheRaven {
Host = null; Host = null;
Port = 0; Port = 0;
_nickServPass = null; _nickServPass = null;
_autoSend = null; _configFile = null; _autoSend = null;
_configFile = null;
whitelist = null; whitelist = null;
blacklist = null; blacklist = null;
magic8 = null; magic8 = null;
@ -382,7 +404,7 @@ namespace AniNIX.TheRaven {
//If an exception gets here, something went wrong //If an exception gets here, something went wrong
} catch (Exception e) { } catch (Exception e) {
ReportMessage.Log(Verbosity.Error,"Unexpected exception caught!"); ReportMessage.Log(Verbosity.Error,"Unexpected exception caught!");
ReportMessage.Log(Verbosity.Error,e.ToString()); ReportMessage.Log(Verbosity.Error,e.Message);
return 1; return 1;
} }
} }

View File

@ -113,7 +113,7 @@ namespace AniNIX.TheRaven {
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 { try {
ExecuteCommand.Run(String.Format("djinni admin \"Page from {0}\"",incoming.user)); ExecuteCommand.Run(String.Format("pb push \"Page from {0}\"",incoming.user));
send.PrivMsg("Sent!",incoming.user); send.PrivMsg("Sent!",incoming.user);
} catch (Exception e) { } catch (Exception e) {
ReportMessage.Log(Verbosity.Error,e.ToString()); ReportMessage.Log(Verbosity.Error,e.ToString());
@ -147,6 +147,15 @@ namespace AniNIX.TheRaven {
send.PrivMsg(theRaven.searchesIndex,(incoming.target.Equals(theRaven.Nick))?incoming.user:incoming.target); send.PrivMsg(theRaven.searchesIndex,(incoming.target.Equals(theRaven.Nick))?incoming.user:incoming.target);
connection.Write(send); connection.Write(send);
return; return;
case "r.wikidiff":
String[] byQuote = incoming.message.Split('"');
try {
send.PrivMsg(String.Format("https://wikidiff.com/{0}/{1}",byQuote[1],byQuote[3]),(incoming.target.Equals(theRaven.Nick))?incoming.user:incoming.target);
} catch(IndexOutOfRangeException e) {
send.PrivMsg("Format: r.wikidiff \"Search 1\" \"Search 2\"",(incoming.target.Equals(theRaven.Nick))?incoming.user:incoming.target);
}
connection.Write(send);
return;
} }
/* SEARCHES */ /* SEARCHES */

View File

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
url="$(wget -q -O - http://alice.pandorabots.com/ | grep iframe | cut -f 2 -d \")" url="$(wget -q -O - http://alice.pandorabots.com/ | grep iframe | cut -f 2 -d \")"
curl -m 30 -s --data "input=$(echo $1 | sed "s/$2//g" | sed 's/^: //')" "$url" | grep 'ALICE:' | tail -n 1 | cut -f 3 -d '>' | sed 's/ ALICE: //' | sed "s/ALICE/$2/g" | sed "s/Alice/$2/g" | sed "s/ om/ friend/" | sed "s/ \+/ /g" curl -m 30 -s --data "input=$(echo $1 | sed "s/$2//g" | sed 's/^: //')" "$url" | grep 'ALICE:' | tail -n 1 | cut -f 3 -d '>' | sed 's/ ALICE: //' | sed "s/ALICE/$2/g" | sed "s/Alice/$2/g" | sed "s/ om/ friend/" | sed "s/ \+/ /g" | sed "s/judge/my creator/g"

View File

@ -0,0 +1,52 @@
There's an old nonsense song called the Old Carrion Crow.
From 2000 to 2003 the world's best wooden roller coaster was called The Raven.
The average raven has a four-foot wingspan.
The average crow has a three-foot wingspan.
Crows and ravens are members of the corvid family, the most adaptable and intelligent family of birds in the world.
Crows and ravens can mimic sounds and associate sounds with events.
Crows roost in flocks of several thousand in the winter.
Crows are omnivorous, making them capable scavangers and opportunistic hunters.
Crows prefer coniferous trees to build their homes at least 60 feet above the ground.
Paired males and females share in the raising of the four to six eggs.
One crow baby will frequently remain in the nest to assist in the caring for the next nestlings.
While crows have a reputation for eating corn, they often eat the bugs that plague crops.
Crows and ravens are territorial when young are in the nest, dive-bombing passersby.
The Sioux have a story of a white crow warning buffalo of approaching hunting parties. The bird turned black when a hunter threw it into the fire in rage.
Crows have been hunted and even had bounties placed on them by several governments, including by Kings of England.
Crows can use a number of calls to communicate situations and emotions.
Crows mate for life and share the care of nestlings.
Crows are often challenged by larger hunting birds, like owls and hawks; they use superior numbers when outmatched.
Crows only migrate long distances in harsh winters.
A group of crows or ravens is called a murder.
Crows live everywhere except Antarctica.
Crows are susceptible to West Nile Virus, which has felled many of them since 1999.
Crows' association with death comes from their scavenger natures -- they are often seen near the dead on battlefields.
Ravens are acrobatic fliers on par with hawks and falcons. In mating season, they put on acrobatic shows for potential mates.
Native Americans often honor ravens in their stories for their playful nature.
Ravens hunt in groups to bring down prey too large for a single bird.
Ravens range from the Arctic to the Mediterranean, building large stick nests.
Ravens have an average wild lifespan of 13 years.
Common ravens range from 24 to 30 inches long with up to a 5 foot (1.5m) wingspan, weighing in at 2.3 pounds.
Legend has it that if ravens leave the Tower of London, the fortress will fall and the British kingdom along with it.
Ravens are the largest passerine (perching) birds in North America.
Ravens can live up to 40 years in captivity or protected conditions.
https://upload.wikimedia.org/wikipedia/commons/9/92/Krummi_1.jpg
Ravens have one of the largest bills of perching birds.
Common ravens have quarrelsome family lives, but they are extremely devoted to their families.
Common ravens (Corvus corax) store food, hiding it from other ravens.
A group of ravens is commonly called a flock.
Ravens don't migrate except in the harshest winters.
In addition to their bills, ravens may drop rocks as weapons.
Young ravens are fascinated with all things new, but older ravens become more cautious and neophobic with experience.
Ravens are known to play, sliding down snowdrifts for fun and play games with wolves and other animals.
Ravens are one of only a few species known to make toys, breaking off branches for social play.
The raven is the national bird of Bhutan and the official bird of the Yukon.
The raven was the first bird sent forth by Noah but didn't return until the flood waters receded.
Ravens feed the prophet Elijah in 1 Kings 17:1 and are a subject of a parable in Luke 12:24, as a sign for man not to be materialistic.
The Native Americans saw the Raven as a creator and world-shaper.
Native American mythology holds that Raven brought the sun, moon, stars, and fire into 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 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.

12
sample-confs/hangman.txt Normal file
View File

@ -0,0 +1,12 @@
EZIO
CONNOR
ALTAIR
YUSUF
ACHILLES
MARIA
MALIK
SEF
DARIM
MACHIAVELLI
MARIO
PAOLA

20
sample-confs/magic8.txt Normal file
View File

@ -0,0 +1,20 @@
It is certain
It is decidedly so
Without a doubt
Yes definitely
You may rely on it
As I see it yes
Most likely
Outlook good
Yes
Signs point to yes
Reply hazy try again
Ask again later
Better not tell you now
Cannot predict now
Concentrate and ask again
Don't count on it
My reply is no
My sources say no
Outlook not so good
Very doubtful