forked from prehensile/skypebot
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
3 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
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
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,51 @@ | ||
import time | ||
import pkgutil | ||
import datetime | ||
import json | ||
import sys | ||
import logging | ||
import twitterconnector | ||
from hookserver import HookServerMessage, HookServerThread | ||
import queuedthread | ||
import time | ||
from messages import housekeeping, streetnoise | ||
import re | ||
import os | ||
import commands | ||
import urllib2 | ||
import urllib | ||
|
||
command_list=[] | ||
# import commands | ||
all_commands = [] | ||
logging.info( "Loading commands..." ) | ||
## load all commands | ||
reload( commands ) | ||
for loader, modname, ispkg in pkgutil.iter_modules( commands.__path__, prefix="commands." ): | ||
try: | ||
logging.info( "Scan module: %s" % modname) | ||
module = __import__( modname, fromlist="dummy" ) | ||
reload( module ) | ||
for klassname in dir( module ): | ||
if "Command" in klassname and "BaseCommand" not in klassname: | ||
logging.info( "...instantiate command: %s" % klassname ) | ||
try: | ||
kommandklass = getattr( module, klassname ) | ||
kommand = kommandklass() | ||
all_commands.append( kommand ) | ||
logging.info( "......instantiated. Triggers are %s" % kommand.command_mappings ) | ||
except Exception, e: | ||
logging.info( e ) | ||
except Exception, e: | ||
logging.info( e ) | ||
global command_list | ||
command_list=all_commands | ||
|
||
out='commands: ' | ||
for cmd in all_commands: | ||
l=cmd.command_mappings | ||
for c in l: | ||
out=out+c+' ' | ||
|
||
print out | ||
|
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,43 @@ | ||
# coding=UTF-8 | ||
|
||
from string import Template | ||
import random | ||
from commandbase import BaseCommand | ||
|
||
import pkgutil | ||
import commands | ||
|
||
class CommandCommand( BaseCommand ): | ||
|
||
def __init__(self): | ||
BaseCommand.__init__( self ) | ||
self.command_mappings = [ "command", "cmd", "whut" ] | ||
|
||
def generate( self, name ): | ||
|
||
command_list=[] | ||
# import commands | ||
all_commands = [] | ||
|
||
## load all commands | ||
reload( commands ) | ||
for loader, modname, ispkg in pkgutil.iter_modules( commands.__path__, prefix="commands." ): | ||
|
||
|
||
module = __import__( modname, fromlist="dummy" ) | ||
reload( module ) | ||
for klassname in dir( module ): | ||
if "Command" in klassname and "BaseCommand" not in klassname: | ||
|
||
|
||
kommandklass = getattr( module, klassname ) | ||
kommand = kommandklass() | ||
all_commands.append( kommand ) | ||
out='commands: ' | ||
for cmd in all_commands: | ||
l=cmd.command_mappings | ||
for c in l: | ||
out=out+c+' ' | ||
|
||
message_out = out | ||
return "/me %s" % message_out |