Standardizing docs between python-slackclient and rtmbot

Added copyright to License File
Added standard format for issues/PRs
Added Code of Conduct
Moved doc/ to docs/
This commit is contained in:
Jeff Ammons 2016-07-09 10:02:53 -07:00
parent 7cbbb03a04
commit 3cd9b9a828
13 changed files with 124 additions and 0 deletions

View file

@ -0,0 +1,3 @@
DEBUG: False
SLACK_TOKEN: "xoxb-111111111111-2222222222222222222"

76
docs/example-init/rtmbot.init Executable file
View file

@ -0,0 +1,76 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: exampledaemon
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example
# Description: Example start-stop-daemon - Debian
### END INIT INFO
NAME="rtmbot"
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
APPDIR="/opt/rtmbot"
APPBIN="rtmbot.py"
APPARGS="--config ${APPDIR}/rtmbot.conf"
USER="ubuntu"
GROUP="ubuntu"
# Include functions
set -e
. /lib/lsb/init-functions
start() {
printf "Starting '$NAME'... "
start-stop-daemon --start --background --chuid "$USER:$GROUP" --make-pidfile --pidfile /var/run/$NAME.pid --exec "$APPDIR/$APPBIN" -- $APPARGS || true
printf "done\n"
}
#We need this function to ensure the whole process tree will be killed
killtree() {
local _pid=$1
local _sig=${2-TERM}
for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
killtree ${_child} ${_sig}
done
kill -${_sig} ${_pid}
}
stop() {
printf "Stopping '$NAME'... "
[ -z `cat /var/run/$NAME.pid 2>/dev/null` ] || \
while test -d /proc/$(cat /var/run/$NAME.pid); do
killtree $(cat /var/run/$NAME.pid) 15
sleep 0.5
done
[ -z `cat /var/run/$NAME.pid 2>/dev/null` ] || rm /var/run/$NAME.pid
printf "done\n"
}
status() {
status_of_proc -p /var/run/$NAME.pid "" $NAME && exit 0 || exit $?
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $NAME {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0

View file

@ -0,0 +1,12 @@
from __future__ import unicode_literals
# don't convert to ascii in py2.7 when creating string to return
import time
outputs = []
def canary():
# NOTE: you must add a real channel ID for this to work
outputs.append(["D12345678", "bot started: " + str(time.time())])
canary()

View file

@ -0,0 +1,13 @@
from __future__ import unicode_literals
# don't convert to ascii in py2.7 when creating string to return
import time
crontable = []
outputs = []
crontable.append([5, "say_time"])
def say_time():
# NOTE: you must add a real channel ID for this to work
outputs.append(["D12345678", time.time()])

View file

@ -0,0 +1,12 @@
from __future__ import unicode_literals
# don't convert to ascii in py2.7 when creating string to return
crontable = []
outputs = []
def process_message(data):
if data['channel'].startswith("D"):
outputs.append([data['channel'], "from repeat1 \"{}\" in channel {}".format(
data['text'], data['channel'])]
)

View file

@ -0,0 +1,45 @@
from __future__ import print_function
from __future__ import unicode_literals
# don't convert to ascii in py2.7 when creating string to return
import os
import pickle
outputs = []
crontabs = []
tasks = {}
FILE = "plugins/todo.data"
if os.path.isfile(FILE):
tasks = pickle.load(open(FILE, 'rb'))
def process_message(data):
global tasks
channel = data["channel"]
text = data["text"]
# only accept tasks on DM channels
if channel.startswith("D"):
if channel not in tasks.keys():
tasks[channel] = []
# do command stuff
if text.startswith("todo"):
tasks[channel].append(text[5:])
outputs.append([channel, "added"])
if text == "tasks":
output = ""
counter = 1
for task in tasks[channel]:
output += "%i) %s\n" % (counter, task)
counter += 1
outputs.append([channel, output])
if text == "fin":
tasks[channel] = []
if text.startswith("done"):
num = int(text.split()[1]) - 1
tasks[channel].pop(num)
if text == "show":
print(tasks)
pickle.dump(tasks, open(FILE, "wb"))