tasbot Package

tasbot Package

Client Module

class tasbot.Client.Flags[source]
norecwait = False
register = False
class tasbot.Client.ServerEvents[source]
oncommandfromserver(command, args, socket)[source]
onconnected()[source]
onconnectedplugin()[source]
ondisconnected()[source]
onexit()[source]
onloggedin(socket)[source]
onmotd(content)[source]
onpong()[source]
onsaid(channel, user, message)[source]
onsaidex(channel, user, message)[source]
onsaidprivate(user, message)[source]
class tasbot.Client.Tasclient(app)[source]

Bases: object

the main interaction with server class

connect(server, port)[source]
disconnect(hard=False)[source]
join(channel)[source]
leave(channel)[source]
login(username, password, client, cpu, lanip='*')[source]
mainloop()[source]
parsecommand(command, args)[source]
ping()[source]
receive()[source]
register(username, password)[source]
say(channel, phrase)[source]
sayex(channel, phrase)[source]
class tasbot.Client.User(username, id, country, cpu)[source]
clientstatus(status)[source]

Main Module

class tasbot.Main.MainApp(configfile, pidfile, register, verbose)[source]

Bases: tasbot.daemon.Daemon

main application object that has creates tasclient, pluginhandler and PingLoop instances

Dologin()[source]

handle tasserver login

PingLoop()[source]

sned a PING to the server every 10 seconds until either force_quit is true or i got into an error state

Register(username, password)[source]

register new account on tasserver

ReloadConfig()[source]

reload config and admins from file

SaveConfig()[source]

commit current config dictionary to file

destroy()[source]

deprecated

isAdmin(username)[source]

return true if either username or the asscoiated id is in self.admins

onlogin(socket)[source]

start PingLoop and client mainloop, connect event handlers

run()[source]

the main loop for MainApp, once this exists MainApp will be in unsable state

ParseConfig Module

class tasbot.ParseConfig.Config(filename)[source]
GetOptionList(key, seperator=', ', default=[])[source]
GetSingleOption(key, default)[source]
write(filename)[source]
tasbot.ParseConfig.parselist(string, sep)[source]
tasbot.ParseConfig.readconfigfile(filename)[source]
tasbot.ParseConfig.writeconfigfile(filename, entries)[source]

Plugin Module

class tasbot.Plugin.IPlugin(name, tasclient)[source]

Bases: object

base class all plugins should derive from (and expose fitting ctor)

ondestroy()[source]

tell myself i’m dying and try to stop all my threads

startThread(func, *args)[source]

run a given function with args in a new thread that is added to an internal list

class tasbot.Plugin.PluginHandler(main)[source]

Bases: object

manage runtime loaded modules (plugins)

addplugin(name, tasc)[source]

try to import module name and init it

forall(func_name, *args)[source]

execute a given function(name) on all plugins that expose it

forceunloadplugin(name, tasc)[source]

simply removes name from internal list, only call if unload else fails

oncommandfromserver(command, args, socket)[source]
onconnected()[source]
ondisconnected()[source]
onexit()[source]
onloggedin(socket)[source]
onmotd(content)[source]
onpong()[source]
onsaid(channel, user, message)[source]
onsaidex(channel, user, message)[source]
onsaidprivate(user, message)[source]

react on a few given keywords and also pass the call to all plugins

reloadplugin(name)[source]

broken

unloadAll()[source]

convenience function to unload all plugins at once

unloadplugin(name)[source]

unload plugin, stop all its threads via ondestroy and remove from interal list

class tasbot.Plugin.PluginThread(func, *args)[source]

Bases: threading.Thread

tiny wrapper to execute function with args in a thread

run()[source]

color_formatter Module

class tasbot.color_formatter.ColoredFormatter(msg, use_color=True)[source]

Bases: logging.Formatter

format(record)[source]
tasbot.color_formatter.formatter_message(message, use_color=True)[source]

customlog Module

class tasbot.customlog.CLog[source]

Bases: tasbot.customlog.ILogger

Init(logfile_name, level='info', stdout_log=True)[source]
getPluginLogger(name)[source]
class tasbot.customlog.ILogger(prefix=None)[source]

Bases: object

Debug(msg, prefix=None)[source]
Error(msg, prefix=None)[source]
Except(e)[source]
Info(msg, prefix=None)[source]
bad(t)[source]
good(t)[source]
loaded(t)[source]
notice(t)[source]
reloaded(t)[source]
class tasbot.customlog.PrefixedLogger(clog, name)[source]

Bases: tasbot.customlog.ILogger

daemon Module

* Modified generic daemon class *

Author: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
www.boxedice.com

License: http://creativecommons.org/licenses/by-sa/3.0/

Changes: 23rd Jan 2009 (David Mytton <david@boxedice.com>)
  • Replaced hard coded ‘/dev/null in __init__ with os.devnull
  • Added OS check to conditionally remove code that doesn’t work on OS X
  • Added output to console on completion
  • Tidied up formatting

11th Mar 2009 (David Mytton <david@boxedice.com>) - Fixed problem with daemon exiting on Python 2.4 (before SystemExit was part of the Exception base) 13th Aug 2010 (David Mytton <david@boxedice.com> - Fixed unhandled exception if PID file is empty

class tasbot.daemon.Daemon(pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null')[source]

Bases: object

A generic daemon class.

Usage: subclass the Daemon class and override the run() method

daemonize()[source]

Do the UNIX double-fork magic, see Stevens’ “Advanced Programming in the UNIX Environment” for details (ISBN 0201563177) http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16

delpid()[source]
restart()[source]

Restart the daemon

run()[source]

You should override this method when you subclass Daemon. It will be called after the process has been daemonized by start() or restart().

start()[source]

Start the daemon

stop()[source]

Stop the daemon

tasbot.daemon.check_pid(pid)[source]

Check For the existence of a unix pid.

testplugin Module

class tasbot.testplugin.Main[source]
oncommandfromserver(command, args, socket)[source]
onconnected()[source]
ondisconnected()[source]
onexit()[source]
onloggedin(socket)[source]
onmotd(content)[source]
onpong()[source]
onsaid(channel, user, message)[source]
onsaidex(channel, user, message)[source]
onsaidprivate(user, message)[source]

utilities Module

tasbot.utilities.getally(status)[source]
tasbot.utilities.getaway(status)[source]
tasbot.utilities.getbot(status)[source]
tasbot.utilities.getcolor(status)[source]
tasbot.utilities.gethand(status)[source]
tasbot.utilities.getingame(status)[source]
tasbot.utilities.getmod(status)[source]
tasbot.utilities.getrank(status)[source]
tasbot.utilities.getready(status)[source]
tasbot.utilities.getside(status)[source]
tasbot.utilities.getspec(status)[source]
tasbot.utilities.getsync(status)[source]
tasbot.utilities.getteam(status)[source]