-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fab99ad
Showing
559 changed files
with
106,314 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include MANIFEST.in | ||
include Changelog | ||
include jsb/contrib/tornado/ca-certificates.crt | ||
recursive-include files * | ||
recursive-include jsb/data * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Metadata-Version: 1.0 | ||
Name: jsb | ||
Version: 0.84.4 | ||
Summary: The bot for you! | ||
Home-page: http://jsonbot.googlecode.com/ | ||
Author: Bart Thate | ||
Author-email: [email protected] | ||
License: MIT | ||
Download-URL: http://code.google.com/p/jsonbot/downloads | ||
Description: JSONBOT is a remote event-driven framework for building bots that talk JSON to each other over XMPP. This distribution has IRC/Console/XMPP/WWW/Convore bots built on this framework. | ||
Platform: UNKNOWN | ||
Classifier: Development Status :: 4 - Beta | ||
Classifier: Environment :: Console | ||
Classifier: Environment :: Other Environment | ||
Classifier: Intended Audience :: Developers | ||
Classifier: License :: OSI Approved :: MIT License | ||
Classifier: Operating System :: Unix | ||
Classifier: Programming Language :: Python | ||
Classifier: Topic :: Communications :: Chat | ||
Classifier: Topic :: Software Development :: Libraries :: Python Modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Welcome to JSONBOT | ||
================== | ||
|
||
JSONBOT is a remote event-driven framework for building bots that talk JSON to | ||
each other over XMPP. | ||
|
||
This distribution provides bots built on this framework for console, IRC, | ||
XMPP, Convore and WWW on the shell. | ||
|
||
the jsb pakage contains the following programs: | ||
|
||
* jsb - console version of jsb | ||
* jsb-convore - Convore version of jsb | ||
* jsb-makecert - create keys and certifictes for web console SSL | ||
* jsb-init - create data directory and config examples, default ~/.jsb | ||
* jsb-irc - IRC version of jsb | ||
* jsb-fleet - mix IRC and XMPP bots | ||
* jsb-sed - sed a whole directory | ||
* jsb-stop - stop a running bot | ||
* jsb-tornado - a shell web server based on tornado | ||
* jsb-udp - send udp packets to the bot that will relay the data | ||
* jsb-udpdirect - a stand alone udp program, copy & edit | ||
* jsb-xmpp - XMPP version of jsb | ||
|
||
note: JSONBOT is in BETA stage right now and still subject to change of protocols and API. | ||
|
||
see http://jsonbot.googlecode.com. | ||
see https://jsonbot.org for documentation on the bot. | ||
|
||
if you want the GAE part of the bot install from mercurial repo. | ||
|
||
* "hg clone http://jsonbot.googlecode.com/hg mybot" | ||
|
||
license | ||
~~~~~~~ | ||
|
||
JSONBOT is free code (MIT) and can be cloned where needed. | ||
|
||
contact the developer | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
* email: [email protected] | ||
* jabber/xmpp: [email protected] | ||
* IRC: botfather on #dunkbots irc.freenode.net | ||
* twitter: http://twitter.com/jsonbot | ||
|
||
urls | ||
~~~~ | ||
|
||
* Source code: http://jsonbot.googlecode.com | ||
* web: http://jsonbot.org:10102 (web) | ||
* jabber: [email protected] | ||
|
||
running a development version of the bot | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
first checkout the main bot from the mercurial repository | ||
|
||
hg clone http://jsonbot.googlecode.com/hg mybot | ||
|
||
now you can run the programs in the bin directory with the | ||
./bin/<program> command. try ./bin/jsb for the console app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#!/usr/bin/env python | ||
# | ||
# | ||
|
||
""" Console Bot. """ | ||
|
||
|
||
#import warnings | ||
#warnings.simplefilter("ignore") | ||
|
||
## bootstrap | ||
|
||
import os, sys | ||
sys.path.insert(0, os.getcwd()) | ||
|
||
from jsb.version import getversion | ||
|
||
from jsb.utils.log import setloglevel | ||
|
||
## command line parsing | ||
|
||
from optparse import OptionParser | ||
parser = OptionParser(usage='usage: %prog [options] <appid>', version='%prog ' + getversion()) | ||
parser.add_option('-d', '--datadir', type='string', default=False, dest='datadir', help="datadir to use") | ||
parser.add_option('-c', '--channel', type='string', default=False, dest='channel', help="channel to operate on") | ||
parser.add_option('-n', '--name', type='string', default=False, dest='name', help="name of the console bot") | ||
parser.add_option('-l', '--loglevel', type='string', default=False, dest='loglevel', help="logging level") | ||
parser.add_option('-f', '--fast', action="store_true", default=False, dest='fast', help="boot fast (dont load myplugs)") | ||
parser.add_option('', '--nocolors', action="store_true", default=False, dest='nocolors', help="enable the use of colors") | ||
parser.add_option('', '--fleet', action="store_true", default=False, dest='fleet', help="start the fleet") | ||
parser.add_option('', '--nourl', action="store_true", default=False, dest='nourl', help="disable geturl functionality") | ||
|
||
opts, args = parser.parse_args() | ||
opts.args = args | ||
|
||
if not opts.args: print getversion('CONSOLE') | ||
if opts.datadir: | ||
if not os.path.isdir(opts.datadir): os.mkdir(opts.datadir) | ||
from jsb.lib.datadir import setdatadir | ||
setdatadir(opts.datadir) | ||
|
||
## make config from cmndline options | ||
|
||
from jsb.utils.log import setloglevel | ||
setloglevel(opts.loglevel or "error", not opts.nocolors) | ||
|
||
if opts.nourl: | ||
from jsb.utils.url import url_disable | ||
url_disable() | ||
|
||
from jsb.lib.boot import boot | ||
if opts.fast: boot(opts.datadir, fast=True) | ||
else: boot(opts.datadir) | ||
|
||
## jsb imports | ||
|
||
from jsb.utils.exception import handle_exception | ||
from jsb.utils.generic import waitforqueue, waitevents | ||
from jsb.drivers.console.bot import ConsoleBot | ||
from jsb.lib.config import Config | ||
from jsb.lib.errors import NoOwnerSet, NoSuchCommand | ||
from jsb.lib.commands import cmnds | ||
from jsb.lib.exit import globalshutdown | ||
from jsb.lib.fleet import getfleet | ||
from jsb.lib.threads import start_new_thread | ||
from jsb.lib.datadir import getdatadir | ||
|
||
## basic imports | ||
|
||
import getpass | ||
import time | ||
import logging | ||
|
||
## start the bot | ||
name = opts.name or "default-console" | ||
cfg = Config("fleet" + os.sep + name + os.sep + 'config') | ||
if not cfg.owner: cfg.owner = [] | ||
userid = getpass.getuser() + '@' + cfg.uuid | ||
|
||
if userid not in cfg.owner: cfg.owner.append(userid) ; cfg.save() | ||
|
||
try: | ||
bot = ConsoleBot(cfg) | ||
except NoOwnerSet: | ||
print "the owner is not set in %s" % cfg.cfile | ||
os._exit(1) | ||
|
||
if opts.args: | ||
cmndstring = ";" | ||
for cmnd in opts.args: | ||
if "|" in cmnd: break | ||
cmndstring += u"%s " % unicode(cmnd) | ||
event = bot.make_event(userid, opts.channel or userid, cmndstring.strip(), showall=True) | ||
event.nodispatch = False | ||
try: event.execute(True) | ||
except NoSuchCommand, ex: print "no %s command found." % str(ex).strip() | ||
print "" | ||
try: | ||
sys.stdout.close() | ||
except: pass | ||
os._exit(0) | ||
|
||
print "datadir is %s" % getdatadir() | ||
bot.start(False) | ||
if bot.maincfg.dbenable: print "dbtype is %s" % bot.maincfg.dbtype | ||
fleet = getfleet() | ||
fleet.addbot(bot) | ||
|
||
if opts.fleet: | ||
bots = fleet.loadall() | ||
logging.error("starting fleet %s" % fleet.list()) | ||
start_new_thread(fleet.startall, ()) | ||
|
||
bot.startshell() | ||
globalshutdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env python | ||
# | ||
# | ||
|
||
""" Console Bot. """ | ||
|
||
|
||
#import warnings | ||
#warnings.simplefilter("ignore") | ||
|
||
## bootstrap | ||
|
||
from subprocess import Popen, PIPE | ||
import os | ||
import sys | ||
import time | ||
|
||
sys.path.insert(0, os.getcwd()) | ||
|
||
from jsb.version import getversion | ||
|
||
## command line parsing | ||
|
||
from optparse import OptionParser | ||
parser = OptionParser(usage='usage: %prog [options] <appid>', version='%prog' + getversion()) | ||
parser.add_option('-d', '--datadir', type='string', default=False, dest='datadir', help="datadir to use") | ||
parser.add_option('-t', '--target', type='string', default=False, dest='target', help="target dir") | ||
parser.add_option('-l', '--loglevel', type='string', default=False, dest='loglevel', help="logging level") | ||
parser.add_option('', '--colors', action="store_true", default=False, dest='colors', help="enable the use of colors") | ||
opts, args = parser.parse_args() | ||
opts.args = args | ||
|
||
print getversion('BACKUP') | ||
|
||
from jsb.utils.log import setloglevel | ||
setloglevel(opts.loglevel or "warn", opts.colors) | ||
|
||
from jsb.utils.generic import gethighest | ||
from jsb.utils.popen import Popen | ||
from jsb.lib.datadir import getdatadir | ||
|
||
if opts.datadir: ddir = opts.datadir | ||
elif opts.args: ddir = opts.args[0] | ||
else: ddir = getdatadir() | ||
print "source is %s" % ddir | ||
|
||
if not os.path.isdir(ddir): print "can't find %s directory" % ddir ; os._exit(1) | ||
home = os.path.expanduser("~") | ||
print "home is %s" % home | ||
|
||
if opts.target: target = opts.target | ||
else: target = home + os.sep + "jsb-backups" | ||
if not os.path.isdir(target): os.mkdir(target) | ||
print "target is %s" % target | ||
|
||
targetfile = target + os.sep + "jsb.backup.tar.gz" | ||
|
||
if os.path.isfile(targetfile): | ||
highest = gethighest(target, "jsb.backup.tar.gz") | ||
print "renaming backup tar to %s" % highest | ||
os.rename(targetfile, target + os.sep + highest) | ||
|
||
if 'linux' in str(os.uname()).lower(): | ||
execstring = "tar zvcfp %s --totals --exclude-tag-under=SKIP --show-transformed-names --transform=s#%s## %s" % (targetfile, home[1:] + os.sep, ddir) | ||
else: | ||
execstring = "tar zvcfp %s %s" % (targetfile, ddir) | ||
|
||
print "starting backup - %s" % execstring | ||
time.sleep(3) | ||
proc = Popen(execstring.split()) | ||
proc.wait() | ||
print "done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/env python | ||
# | ||
# | ||
|
||
""" run multiple bot instances in 1 program. """ | ||
|
||
## bootstrap | ||
|
||
import warnings | ||
warnings.simplefilter("ignore") | ||
|
||
import os, sys, logging | ||
sys.path.insert(0, os.getcwd()) | ||
|
||
## basic imports | ||
|
||
import logging | ||
import time | ||
import signal | ||
|
||
## options parser | ||
|
||
from jsb.utils.opts import makefleetopts | ||
|
||
opts = makefleetopts() | ||
|
||
from jsb.lib.datadir import setdatadir, getdatadir | ||
if opts.datadir: setdatadir(opts.datadir) | ||
|
||
from jsb.version import getversion | ||
print getversion('FLEET') | ||
|
||
## jsb imports | ||
|
||
from jsb.lib.partyline import partyline | ||
from jsb.lib.datadir import makedirs | ||
from jsb.lib.boot import boot | ||
from jsb.lib.exit import globalshutdown | ||
from jsb.utils.mainloop import mainloop | ||
from jsb.lib.users import users_boot | ||
from jsb.lib.threads import start_new_thread | ||
from jsb.utils.exception import handle_exception | ||
import jsb | ||
|
||
from jsb.lib.fleet import getfleet | ||
fleet = getfleet(opts.datadir) | ||
if opts.all or opts.show: | ||
avail = fleet.avail() | ||
if avail: sys.stdout.write("available bots: " + ", ".join(avail) + ".") | ||
else: sys.stdout.write("no bots available.") | ||
|
||
if opts.all: print "" ; os._exit(0) | ||
|
||
# provide sigterm support | ||
def dostop(a, b): | ||
""" sig handler """ | ||
globalshutdown() | ||
|
||
signal.signal(signal.SIGTERM, dostop) | ||
|
||
if not fleet.avail(): logging.error("fleet - no bots found.") ; os._exit(1) | ||
|
||
## loglevel | ||
|
||
from jsb.utils.log import setloglevel | ||
setloglevel(opts.loglevel or "warn", not opts.nocolors) | ||
|
||
## start the fleet | ||
|
||
boot(opts.datadir) | ||
|
||
if opts.owner: | ||
users = users_boot() | ||
users.make_owner(opts.owner) | ||
|
||
def doresume(): | ||
try: | ||
fleet.resume(opts.doresume) | ||
fleet.startok.wait() | ||
partyline.resume(opts.doresume) | ||
time.sleep(1) | ||
os.unlink(opts.doresume) | ||
except: handle_exception() | ||
|
||
if opts.doresume: start_new_thread(doresume, ()) | ||
else: start_new_thread(fleet.boot, (opts.args, ["tornado", "console"])) | ||
|
||
mainloop() |
Oops, something went wrong.