Skip to content

Commit 2246c79

Browse files
author
chaos95
committed
MAJOR refactoring, I've touched just about every file here. Cleaned up the package structure and made it more in line with best practices. Also changed a lot of relative import paths to absolute to reflect the new structure. It's a lot more straightforward to read now, and a lot easier for IDEs to parse as well.
git-svn-id: http://pygbot.svn.sourceforge.net/svnroot/pygbot/trunk@12 4ffac776-36fa-42b0-9124-184eb47ee2cf
1 parent cf725b6 commit 2246c79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+118
-266
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/Plugins/games/Mafia.py pyGBot/Plugins/games/Mafia.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@
4242
"""
4343

4444
import sys, string, random, time
45-
import log
46-
from BasePlugin import BasePlugin
45+
46+
from pyGBot import log
47+
from pyGBot.BasePlugin import BasePlugin
4748

4849
#if self.bot.has_key("ChanOp"):
4950
# chanops = self.bot.plugins["ChanOp"]

src/Plugins/games/Poker.py pyGBot/Plugins/games/Poker.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
20-
from BasePlugin import BasePlugin
19+
from pyGBot import log
20+
from pyGBot.BasePlugin import BasePlugin
2121

22-
from .pokerfiles.tourney import Tourney
23-
from .pokerfiles.command import Command
22+
from pyGBot.Plugins.games.pokerfiles.tourney import Tourney
23+
from pyGBot.Plugins.games.pokerfiles.command import Command
2424

2525
class Poker(BasePlugin):
2626
def __init__(self, bot, options):

src/Plugins/games/Uno.py pyGBot/Plugins/games/Uno.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
# Also, ability to challenge draw-fours, possibly with !challenge
2121
import random
2222

23-
import log
24-
from BasePlugin import BasePlugin
23+
from pyGBot import log
24+
from pyGBot.BasePlugin import BasePlugin
2525

2626
class Uno(BasePlugin):
2727
colours = ['B', 'G', 'R', 'Y']

src/Plugins/games/Werewolf.py pyGBot/Plugins/games/Werewolf.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@
4242
"""
4343

4444
import sys, string, random, time
45-
import log
46-
from BasePlugin import BasePlugin
45+
46+
from pyGBot import log
47+
from pyGBot.BasePlugin import BasePlugin
4748

4849
#---------------------------------------------------------------------
4950
# General texts for narrating the game. Change these global strings
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/Plugins/games/pokerfiles/card.py pyGBot/Plugins/games/pokerfiles/card.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# You should have received a copy of the GNU General Public License
1616
# along with this program; if not, write to the Free Software
1717
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18-
import log
18+
from pyGBot import log
1919

2020
def ranksym(rank):
2121
#log.logger.debug('Card.ranksym()')

src/Plugins/games/pokerfiles/command.py pyGBot/Plugins/games/pokerfiles/command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17-
import log
17+
from pyGBot import log
1818

1919
class Command:
2020
"Extracts protocol, id, command, and arg from mail filter input"

src/Plugins/games/pokerfiles/deck.py pyGBot/Plugins/games/pokerfiles/deck.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from random import random, seed, shuffle
1818
from struct import unpack
1919
from card import Card
20-
import log
20+
from pyGBot import log
2121

2222
class Deck:
2323
'''

src/Plugins/games/pokerfiles/hand.py pyGBot/Plugins/games/pokerfiles/hand.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17-
import log
17+
from pyGBot import log
1818
import card
1919

2020
class Hand:

src/Plugins/games/pokerfiles/player.py pyGBot/Plugins/games/pokerfiles/player.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17-
import log
17+
from pyGBot import log
1818
from hand import Hand
1919
from command import Command
2020

src/Plugins/games/pokerfiles/pot.py pyGBot/Plugins/games/pokerfiles/pot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17-
import log
17+
from pyGBot import log
1818

1919
class Pot:
2020
def __init__(self, trigger = 0):

src/Plugins/games/pokerfiles/tourney.py pyGBot/Plugins/games/pokerfiles/tourney.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
from datetime import datetime
2222
from random import choice
2323

24+
from pyGBot import log
25+
2426
from command import Command
2527
from deck import Deck
26-
import log
2728
from player import Player
2829
from pot import Pot
2930

src/Plugins/math/Calculate.py pyGBot/Plugins/math/Calculate.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
2019
from math import *
21-
from BasePlugin import BasePlugin
20+
21+
from pyGBot import log
22+
from pyGBot.BasePlugin import BasePlugin
2223

2324
class Calculate(BasePlugin):
2425
__plugintype__ = "active"
File renamed without changes.

src/Plugins/probability/Decide.py pyGBot/Plugins/probability/Decide.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
19+
from pyGBot import log
2020
from random import choice
21-
from BasePlugin import BasePlugin
21+
from pyGBot.BasePlugin import BasePlugin
2222

2323
class Decide(BasePlugin):
2424
__plugintype__ = "active"

src/Plugins/probability/DnDStatsRoll.py pyGBot/Plugins/probability/DnDStatsRoll.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
2019
import random
2120
import re
22-
from BasePlugin import BasePlugin
21+
22+
from pyGBot import log
23+
from pyGBot.BasePlugin import BasePlugin
2324

2425
class DnDStatsRoll(BasePlugin):
2526
__plugintype__ = "active"

src/Plugins/probability/Roll.py pyGBot/Plugins/probability/Roll.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
2019
import random
2120
import re
22-
from BasePlugin import BasePlugin
21+
22+
from pyGBot import log
23+
from pyGBot.BasePlugin import BasePlugin
2324

2425
class Roll(BasePlugin):
2526
__plugintype__ = "active"
File renamed without changes.

src/Plugins/system/Auth.py pyGBot/Plugins/system/Auth.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
import hashlib
2020

21-
import log
22-
from BasePlugin import BasePlugin
23-
from contrib.configobj import ConfigObj, ConfigObjError
21+
from pyGBot import log
22+
from pyGBot.BasePlugin import BasePlugin
23+
from contrib.configobj import ConfigObj
2424

2525
class AuthLevels:
2626
User = 0

src/Plugins/system/CommandSpec/Do.py pyGBot/Plugins/system/CommandSpec/Do.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
20-
from ..Commands import BaseCommand
21-
from ..Auth import AuthLevels as AL
19+
from pyGBot import log
20+
from pyGBot.Plugins.system.Commands import BaseCommand
21+
from pyGBot.Plugins.system.Auth import AuthLevels as AL
2222

2323
class Do(BaseCommand):
2424
level = AL.Admin

src/Plugins/system/CommandSpec/JoinChannel.py pyGBot/Plugins/system/CommandSpec/JoinChannel.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
20-
from ..Commands import BaseCommand
21-
from ..Auth import AuthLevels as AL
19+
from pyGBot import log
20+
from pyGBot.Plugins.system.Commands import BaseCommand
21+
from pyGBot.Plugins.system.Auth import AuthLevels as AL
2222

2323
class JoinChannel(BaseCommand):
2424
level = AL.Admin

src/Plugins/system/CommandSpec/ListGames.py pyGBot/Plugins/system/CommandSpec/ListGames.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
from ..Commands import BaseCommand
20-
from ..Auth import AuthLevels as AL
19+
from pyGBot.Plugins.system.Commands import BaseCommand
20+
from pyGBot.Plugins.system.Auth import AuthLevels as AL
2121

2222
class ListGames(BaseCommand):
2323
level = AL.User

src/Plugins/system/CommandSpec/PartChannel.py pyGBot/Plugins/system/CommandSpec/PartChannel.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
20-
from ..Commands import BaseCommand
21-
from ..Auth import AuthLevels as AL
19+
from pyGBot import log
20+
from pyGBot.Plugins.system.Commands import BaseCommand
21+
from pyGBot.Plugins.system.Auth import AuthLevels as AL
2222

2323
class PartChannel(BaseCommand):
2424
level = AL.Admin

src/Plugins/system/CommandSpec/PlayGame.py pyGBot/Plugins/system/CommandSpec/PlayGame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
from ..Commands import BaseCommand
20-
from ..Auth import AuthLevels as AL
19+
from pyGBot.Plugins.system.Commands import BaseCommand
20+
from pyGBot.Plugins.system.Auth import AuthLevels as AL
2121

2222
class PlayGame(BaseCommand):
2323
level = AL.User

src/Plugins/system/CommandSpec/Say.py pyGBot/Plugins/system/CommandSpec/Say.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
20-
from ..Commands import BaseCommand
21-
from ..Auth import AuthLevels as AL
19+
from pyGBot import log
20+
from pyGBot.Plugins.system.Commands import BaseCommand
21+
from pyGBot.Plugins.system.Auth import AuthLevels as AL
2222

2323
class Say(BaseCommand):
2424
level = AL.Admin

src/Plugins/system/CommandSpec/StatsRoll.py pyGBot/Plugins/system/CommandSpec/StatsRoll.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
20-
from ..Commands import BaseCommand
21-
from ..Auth import AuthLevels as AL
19+
import random
20+
21+
from pyGBot import log
22+
from pyGBot.Plugins.system.Commands import BaseCommand
23+
from pyGBot.Plugins.system.Auth import AuthLevels as AL
2224

2325
class StatsRoll(BaseCommand):
2426
level = AL.User

src/Plugins/system/CommandSpec/StopGame.py pyGBot/Plugins/system/CommandSpec/StopGame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
from ..Commands import BaseCommand
20-
from ..Auth import AuthLevels as AL
19+
from pyGBot.Plugins.system.Commands import BaseCommand
20+
from pyGBot.Plugins.system.Auth import AuthLevels as AL
2121

2222
class StopGame(BaseCommand):
2323
level = AL.User

src/Plugins/system/Commands.py pyGBot/Plugins/system/Commands.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
20-
from BasePlugin import BasePlugin
19+
from pyGBot import log
20+
from pyGBot.BasePlugin import BasePlugin
2121

22-
from .Auth import AuthLevels as AL
22+
from pyGBot.Plugins.system.Auth import AuthLevels as AL
2323

2424
class BaseCommand:
2525
"""Static base class for one-line commands.
@@ -45,9 +45,9 @@ def __init__(self, bot, options):
4545

4646
for friendlyname, commandname in options.iteritems():
4747
if not friendlyname.startswith('_'):
48-
exec "from .CommandSpec." + commandname + " import " + commandname + " as C_" + commandname
49-
exec "command = C_" + commandname
50-
self.commands[friendlyname] = command
48+
log.logger.info("Importing command " + commandname + " with friendly name " + friendlyname)
49+
command = __import__("pyGBot.Plugins.system.CommandSpec." + commandname, fromlist = [commandname])
50+
self.commands[friendlyname] = getattr(command, commandname)
5151

5252
def pubout(self, channel, message):
5353
self.bot.pubout(channel, message)

src/Plugins/system/Startup.py pyGBot/Plugins/system/Startup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
## along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
##
1818

19-
import log
20-
from BasePlugin import BasePlugin
19+
from pyGBot import log
20+
from pyGBot.BasePlugin import BasePlugin
2121

2222
class Startup(BasePlugin):
2323
def __init__(self, bot, options):
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)