Remove yaml, convert all configs to json

This commit is contained in:
dave 2015-11-01 17:40:13 -08:00
parent bdf0081ba8
commit f6404047cf
52 changed files with 1517 additions and 1034 deletions

View File

@ -3,6 +3,10 @@
Module capable of operating Bitcoind-style RPC. Provided as a service.
.. note:: This module requires installation of some :doc:`optional dependencies </setup/dependencies>`:
* bitcoinrpc
Class Reference
---------------

View File

@ -1,7 +1,14 @@
:mod:`DogeRPC` --- A dogecoind RPC service
==========================================
This module provides a service for interacting with dogecoind.
This module provides a service called ``dogerpc`` for interacting with dogecoind.
.. note:: This module requires installation of some :doc:`optional dependencies </setup/dependencies>`:
* bitcoinrpc
A dogecoin daemon is required to use this module. It must be configured to
allow RPC connections.
Class Reference
---------------
@ -10,3 +17,5 @@ Class Reference
:members:
:undoc-members:
:show-inheritance:

View File

@ -2,7 +2,67 @@
=========================================================
This module provides a word scrambling game that rewards winners with small
amounts of Dogecoin
amounts of Dogecoin. Requires a ``dogerpc`` service provider such as
:doc:`DogeRPC </api/modules/dogerpc>`.
Config
------
.. code-block:: json
{
"hintDelay": 15,
"delayNext": 5,
"maxHints": 5,
"abortAfterNoGuesses": 2,
"categoryduration": 10,
"winAmount": 5,
"decreaseFactor": 0.75
}
In addition to the json config above, additional categories of words may be
added by adding additional text files to the DogeScramble data dir.
.. cmdoption:: hintDelay
Seconds between hints if the word is not guessed
.. cmdoption:: delayNext
Delay in seconds between the end of one round and start of the next
.. cmdoption:: maxHints
How many letters will be hinted before the word is thrown away
.. cmdoption:: abortAfterNoGuesses
How many rounds may pass with no players guessing. Once this count is
passed, the game is automatically stopped.
.. cmdoption:: categoryduration
Number of words used from a category before changing the category
.. cmdoption:: winAmount
Amount of dogecoin to send the winner
.. cmdoption:: decreaseFactor
For subsequent wins by the same player, the reward will be the previous
reward multiplied times this number
Commands
--------
.. cmdoption:: .scramble
Start the unscramble game
.. cmdoption:: .scrambleoff
Stop the unscramble game
Class Reference
---------------

View File

@ -1,7 +1,21 @@
:mod:`DuckHunt` --- Duckhunt game
=================================
An animal hunting IRC game
Example usage:
.. code-block:: none
3:15:06 PM <pyircbot3> \_o< Quack!
3:15:08 PM <@dave-irccloud> !shoot
3:15:08 PM <pyircbot3> dave-irccloud fires after 1.73 seconds and misses!
3:15:09 PM <@dave-irccloud> !shoot
3:15:10 PM <pyircbot3> dave-irccloud fires after 3.83 seconds and misses!
3:15:11 PM <@dave-irccloud> !shoot
3:15:11 PM <pyircbot3> dave-irccloud bags a 2.63 lb Duck in 4.92 seconds!
3:15:19 PM <@dave-irccloud> !huntscore
<< in pm >>
3:15:19 PM <pyircbot3> 0 prime catches, 0 runts, 3 bullets used and 2 misses.
3:15:20 PM <pyircbot3> You've shot 1 Ducks for a total weight of 2.63 lbs.
Class Reference
---------------

View File

@ -1,5 +1,21 @@
:mod:`Scramble` --- Module to provide a word scramble game
==========================================================
:mod:`Scramble` --- Word scramble game module
=============================================
Example usage:
.. code-block:: none
3:04:00 PM <@dave-irccloud> .scrambleon
3:04:00 PM <pyircbot3> New word - leppa
3:04:15 PM <pyircbot3> Hint: - a____
3:04:30 PM <pyircbot3> Hint: - ap___
3:04:32 PM <@dave-irccloud> apple
3:04:32 PM <pyircbot3> dave-irccloud guessed the word - apple! dave-irccloud now has 3 points. Next word in 5 seconds.
3:04:35 PM <@dave-irccloud> .scrambleoff
3:04:39 PM <@dave-irccloud> .scramble top
3:04:39 PM <pyircbot3> Top 1: dave-irccloud: 3
Requires a dictionary to pull words from, ``words.txt`` should be placed in: ``./datadir/data/Scramble/``
Class Reference
---------------

View File

@ -1,7 +1,7 @@
Setup Tutorial
==============
Installing and runnig PyIRCBot requires installing the needed dependancies and
Installing and runnig PyIRCBot requires installing the needed dependencies and
providing some environmental information about where the bot is being run.
Contents:
@ -9,6 +9,6 @@ Contents:
.. toctree::
:maxdepth: 8
dependancies.rst
dependencies.rst
initial_config.rst
running.rst

View File

@ -1,5 +1,5 @@
************
Dependancies
Dependencies
************
PyIRCBot is designed to run on Python 3, and is usually tested with 3.4. Python
@ -23,3 +23,10 @@ them.
- **bitcoinrpc** - https://github.com/jgarzik/python-bitcoinrpc
- **pymysql** - https://github.com/dpedu/MySQL-for-Python-3 (needs \
libmysqlclient-dev on your system)
At time of writing there is a bug that will prevent the bitcoinrpc module from
working with Python 3. When pull `#55`_ is merged, the bug will be fixed.
Until then, using my `fork`_ is recommended.
.. _#55: https://github.com/jgarzik/python-bitcoinrpc/pull/55
.. _fork: https://github.com/dpedu/python-bitcoinrpc

View File

@ -0,0 +1,3 @@
{
"cache": 300
}

View File

@ -1 +0,0 @@
cache: 300

View File

@ -0,0 +1,16 @@
{
"allowDelete": true,
"delaySubmit": 0,
"delayCalc": 0,
"delayCalcSpecific": 0,
"delayMatch": 0,
"cmd_calc": [
".calc",
"calc",
".quote"
],
"cmd_match": [
".match",
"match"
]
}

View File

@ -1,12 +0,0 @@
allowDelete: true
delaySubmit: 0
delayCalc: 0
delayCalcSpecific: 0
delayMatch: 0
cmd_calc:
- .calc
- calc
- .quote
cmd_match:
- .match
- match

View File

@ -0,0 +1,26 @@
{
"types": {
"LTC": {
"name": "Litecoin",
"abbr": "LTC",
"host": "127.0.0.1",
"username": "user",
"password": "pass",
"port": 12893,
"precision": 8,
"reserve": 0.01,
"link": "https://litecoin.org/"
},
"BTC": {
"name": "Bitcoin",
"abbr": "BTC",
"host": "127.0.0.1",
"username": "user",
"password": "pass",
"port": 48191,
"precision": 8,
"reserve": 0.001,
"link": "http://bitcoin.org/"
}
}
}

View File

@ -1,21 +0,0 @@
types:
LTC:
name: Litecoin
abbr: LTC
host: 127.0.0.1
username: user
password: pass
port: 12893
precision: 8
reserve: .01
link: https://litecoin.org/
BTC:
name: Bitcoin
abbr: BTC
host: 127.0.0.1
username: user
password: pass
port: 48191
precision: 8
reserve: .001
link: http://bitcoin.org/

View File

@ -0,0 +1,9 @@
{
"minBet": 0.01,
"lobbyIdleSeconds": 15,
"channelWhitelistOn": true,
"channelWhitelist": [
"dogegamestest",
"test"
]
}

View File

@ -1,6 +0,0 @@
minBet: .01
lobbyIdleSeconds: 15
channelWhitelistOn: True
channelWhitelist:
- dogegamestest
- test

View File

@ -0,0 +1,6 @@
{
"host": "127.0.0.1",
"username": "wallet_rpc_user",
"password": "wallet_rpc_pass",
"port": 22555
}

View File

@ -1,4 +0,0 @@
host: 127.0.0.1
username: wallet_rpc_user
password: wallet_rpc_pass
port: 22555

View File

@ -0,0 +1,9 @@
{
"hintDelay": 15,
"delayNext": 5,
"maxHints": 5,
"abortAfterNoGuesses": 2,
"categoryduration": 10,
"winAmount": 5,
"decreaseFactor": 0.75
}

View File

@ -0,0 +1,17 @@
{
"delayMin": 5,
"delayMax": 15,
"missChance": 50,
"animal": "\\_o< Quack!",
"animalSpecies": "Duck",
"animalSpeciesPlural": "Ducks",
"animalNameMale": "Duck",
"animalNameFemale": "Duck",
"runtChance": 10,
"primeChance": 5,
"weightMin": 2.5,
"weightMax": 3.5,
"weightRunt": 1.5,
"weightFat": 5,
"activeChannel": "##xmopx"
}

View File

@ -1,15 +0,0 @@
delayMin: 5
delayMax: 15
missChance: 50
animal: "\\_o< Quack!"
animalSpecies: "Duck"
animalSpeciesPlural: "Ducks"
animalNameMale: "Duck"
animalNameFemale: "Duck"
runtChance: 10
primeChance: 5
weightMin: 2.5
weightMax: 3.5
weightRunt: 1.5
weightFat: 5.0
activeChannel: "#xmopx"

View File

@ -0,0 +1,6 @@
{
"channelWhitelistOn": true,
"channelWhitelist": [
"test"
]
}

View File

@ -1,3 +0,0 @@
channelWhitelistOn: True
channelWhitelist:
- test

View File

@ -0,0 +1,13 @@
{
"limit": 25,
"recv_msg": "Oh, thanks, I'll keep %(adjective)s%(item)s safe",
"inv_msg": "\u0000\u0001ACTION is carrying %(itemlist)s\u0000\u0001",
"swap_msg": "\u0000\u0001ACTION takes %(adjective)s%(recv_item)s but drops %(drop_item)s\u0000\u0010",
"dupe_msg": "No thanks, I've already got %(item)s",
"adjectives": [
"some",
"the",
"an",
"these"
]
}

View File

@ -1,10 +0,0 @@
limit: 25
recv_msg: "Oh, thanks, I'll keep %(adjective)s%(item)s safe"
inv_msg: "\x01ACTION is carrying %(itemlist)s\x01"
swap_msg: "\x01ACTION takes %(adjective)s%(recv_item)s but drops %(drop_item)s\x10"
dupe_msg: "No thanks, I've already got %(item)s"
adjectives:
- some
- the
- an
- these

View File

@ -0,0 +1,6 @@
{
"host": "localhost",
"username": "root",
"password": "root",
"database": "pyircbot"
}

View File

@ -1,4 +0,0 @@
host: 10.0.3.14
username: root
password: root
database: pyircbot_dev

View File

@ -0,0 +1,3 @@
{
"cache": 90
}

View File

@ -1 +0,0 @@
cache: 90

View File

@ -0,0 +1,3 @@
{
"limit": 10000
}

View File

@ -1 +0,0 @@
limit: 10000

View File

@ -0,0 +1,4 @@
{
"mytimezone": "US/Pacific",
"precision": 5
}

View File

@ -1,2 +0,0 @@
mytimezone: US/Pacific
precision: 5

View File

@ -0,0 +1,6 @@
{
"hintDelay": 15,
"delayNext": 5,
"maxHints": 5,
"abortAfterNoGuesses": 5
}

View File

@ -1,4 +0,0 @@
hintDelay: 15
delayNext: 5
maxHints: 5
abortAfterNoGuesses: 5

View File

@ -0,0 +1,4 @@
{
"timezone": "EST",
"add_hours": 0
}

View File

@ -1,2 +0,0 @@
timezone: EST
add_hours: 0

View File

@ -19,7 +19,7 @@
"ghost_cmd":"ghost %(nick)s %(password)s"
},
"channels":[
"#xmopx"
"##xmopx"
],
"privatechannels":{
"to":"chanserv",

View File

@ -0,0 +1,4 @@
{
"max": 10,
"maxage": 2678400
}

View File

@ -1,2 +0,0 @@
max: 10
maxage: 2678400

View File

@ -0,0 +1,4 @@
{
"apikey": "get an API key at: http://www.wunderground.com/weather/api/ (choose 'anvil')",
"defaultUnit": "c"
}

View File

@ -1,2 +0,0 @@
apikey: "get an API key at: http://www.wunderground.com/weather/api/ (choose \"anvil\")"
defaultUnit: c

View File

@ -0,0 +1,313 @@
Air
Stone
Grass
Dirt
Cobblestone
Wooden Plank
Sapling
Redwood Sapling
Birch Sapling
Bedrock
Water
Lava
Sand
Gravel
Gold Ore
Iron Ore
Coal Ore
Wood
Redwood
Birchwood
Leaves
Redwood Leaves
Birchwood Leaves
Sponge
Glass
Lapis Lazuli Ore
Lapis Lazuli Block
Dispenser
Sandstone
Note Block
Bed Block
Powered Rail
Detector Rail
Sticky Piston
Web
Dead Shrub
Tall Grass
Live Shrub
Dead Shrub
Piston
Piston Head
White Wool
Orange Wool
Magenta Wool
Light Blue Wool
Yellow Wool
Light Green Wool
Pink Wool
Gray Wool
Light Gray Wool
Cyan Wool
Purple Wool
Blue Wool
Brown Wool
Dark Green Wool
Red Wool
Black Wool
Dandelion
Rose
Brown Mushroom
Red Mushroom
Gold Block
Iron Block
Double Stone Slab
Double Sandstone Slab
Double Wooden Slab
Double Cobblestone Slab
Double Brick Slab
Double Stone Brick Slab
Stone Slab
Sandstone Slab
Wooden Slab
Cobblestone Slab
Brick Slab
Stone Brick Slab
Brick
TNT
Bookshelf
Mossy Cobblestone
Obsidian
Torch
Fire
Monster Spawner
Wooden Stairs
Chest
Redstone Wire
Diamond Ore
Diamond Block
Workbench
Wheat Crops
Soil
Furnace
Sign Post
Wooden Door
Ladder
Rails
Cobblestone Stairs
Wall Sign
Lever
Stone Pressure Plate
Iron Door Block
Wooden Pressure Plate
Redstone Ore
Redstone Torch
Stone Button
Snow
Ice
Snow Block
Cactus
Clay
Sugar Cane
Jukebox
Fence
Pumpkin
Netherrack
Soul Sand
Glowstone
Portal
Jack-O-Lantern
Cake Block
Redstone Repeater Block
Locked Chest
Trapdoor
Stone (Silverfish)
Stone Brick
Mossy Stone Brick
Cracked Stone Brick
Red Mushroom Cap
Brown Mushroom Cap
Iron Bars
Glass Pane
Melon Block
Pumpkin Stem
Melon Stem
Vines
Fence Gate
Brick Stairs
Stone Brick Stairs
Mycelium
Lily Pad
Nether Brick
Nether Brick Fence
Nether Brick Stairs
Nether Wart
Iron Shovel
Iron Pickaxe
Iron Axe
Flint and Steel
Apple
Bow
Arrow
Coal
Charcoal
Diamond
Iron Ingot
Gold Ingot
Iron Sword
Wooden Sword
Wooden Shovel
Wooden Pickaxe
Wooden Axe
Stone Sword
Stone Shovel
Stone Pickaxe
Stone Axe
Diamond Sword
Diamond Shovel
Diamond Pickaxe
Diamond Axe
Stick
Bowl
Mushroom Soup
Gold Sword
Gold Shovel
Gold Pickaxe
Gold Axe
String
Feather
Sulphur
Wooden Hoe
Stone Hoe
Iron Hoe
Diamond Hoe
Gold Hoe
Wheat Seeds
Wheat
Bread
Leather Helmet
Leather Chestplate
Leather Leggings
Leather Boots
Chainmail Helmet
Chainmail Chestplate
Chainmail Leggings
Chainmail Boots
Iron Helmet
Iron Chestplate
Iron Leggings
Iron Boots
Diamond Helmet
Diamond Chestplate
Diamond Leggings
Diamond Boots
Gold Helmet
Gold Chestplate
Gold Leggings
Gold Boots
Flint
Raw Porkchop
Cooked Porkchop
Painting
Golden Apple
Sign
Wooden Door
Bucket
Water Bucket
Lava Bucket
Minecart
Saddle
Iron Door
Redstone
Snowball
Boat
Leather
Milk Bucket
Clay Brick
Clay Balls
Sugarcane
Paper
Book
Slimeball
Storage Minecart
Powered Minecart
Egg
Compass
Fishing Rod
Clock
Glowstone Dust
Raw Fish
Cooked Fish
Ink Sack
Rose Red
Cactus Green
Coco Beans
Lapis Lazuli
Purple Dye
Cyan Dye
Light Gray Dye
Gray Dye
Pink Dye
Lime Dye
Dandelion Yellow
Light Blue Dye
Magenta Dye
Orange Dye
Bone Meal
Bone
Sugar
Cake
Bed
Redstone Repeater
Cookie
Map
Shears
Melon
Pumpkin Seeds
Melon Seeds
Raw Beef
Steak
Raw Chicken
Cooked Chicken
Rotten Flesh
Ender Pearl
Blaze Rod
Ghast Tear
Gold Nugget
Nether Wart Seeds
Potion
Glass Bottle
Spider Eye
Fermented Spider Eye
Blaze Powder
Magma Cream
Gold Music Disc
Green Music Disc
Chicken
Cow
Mooshroom
Ocelot
Pig
Sheep
Squid
Villager
Enderman
Wolf
Zombie Pigman
Wolf
Ocelot
Blaze
Cave Spider
Creeper
Ghast
Magma Cube
Silverfish
Skeleton
Slime
Spider
Spider Jockey
Zombie
Snow Golem
Iron Golem
Ender Dragon
Rana

View File

@ -34,7 +34,7 @@ class ModuleBase:
here"""
self.config={}
"""Configuration dictionary. Autoloaded from `%(datadir)s/%(modulename)s.yml`"""
"""Configuration dictionary. Autoloaded from `%(datadir)s/%(modulename)s.json`"""
self.log = logging.getLogger("Module.%s" % self.moduleName)
"""Logger object for this module"""
@ -57,7 +57,7 @@ class ModuleBase:
pass
def getConfigPath(self):
"""Returns the absolute path of this module's YML config file"""
"""Returns the absolute path of this module's json config file"""
return self.bot.getConfigPath(self.moduleName)
def getFilePath(self, f=None):

2
pyircbot/modules/CardsAgainstHumanity.py Normal file → Executable file
View File

@ -6,7 +6,6 @@
"""
from pyircbot.modulebase import ModuleBase,ModuleHook
import yaml
import os
import time
from threading import Timer
@ -18,7 +17,6 @@ class CardsAgainstHumanity(ModuleBase):
# init the base module
ModuleBase.__init__(self, bot, moduleName);
self.hooks=[ModuleHook("PRIVMSG", self.scramble)]
self.loadConfig()
# Dictionary
self.whitesFile = open(self.getFilePath("answers.txt"),'r')

View File

@ -9,7 +9,6 @@
from pyircbot.modulebase import ModuleBase,ModuleHook
import random
import yaml
import os
import time
import math

View File

@ -19,11 +19,11 @@ class DogeRPC(ModuleBase):
self.rpc = DogeController(self)
def getBal(self, acct):
" get a balance of an address or an account "
"Get a balance of a local address or an account "
return self.getAcctBal(acct)
def getAcctAddr(self, acct):
" returns the address for an account. creates if necessary "
"Returns the address for an account. creates if necessary "
self.rpc.ping()
addrs = self.rpc.con.getaddressesbyaccount(acct)
if len(addrs)==0:
@ -31,30 +31,31 @@ class DogeRPC(ModuleBase):
return addrs[0]
def getAcctBal(self, acct):
" returns an account's balance"
"Returns an account's balance"
self.rpc.ping()
return float(self.rpc.con.getbalance(acct))
def canMove(self, fromAcct, toAcct, amount):
" true or false if fromAcct can afford to give toAcct an amount of coins "
"True or false if fromAcct can afford to give toAcct an amount of coins "
balfrom = self.getAcctBal(fromAcct)
return balfrom >= amount
def move(self, fromAcct, toAcct, amount):
" move coins from one account to another "
"Move coins from one account to another "
self.rpc.ping()
if self.canMove(fromAcct, toAcct, amount):
return self.rpc.con.move(fromAcct, toAcct, amount)
return False
def send(self, fromAcct, toAddr, amount):
" send coins to an external addr "
"Send coins to an external addr "
self.rpc.ping()
if self.canMove(fromAcct, toAddr, amount):
return self.rpc.con.sendfrom(fromAcct, toAddr, amount)
return False
class DogeController:
"RPC instance control class"
def __init__(self, master):
self.config = master.config
self.log = master.log
@ -62,12 +63,14 @@ class DogeController:
self.ping()
def ping(self):
"Test connection and re-establish if necessary"
try:
self.con.getinfo()
except:
self.connect()
def connect(self):
"Connect to RPC endpoint"
self.log.debug("DogeRPC: Connecting to dogecoind")
self.con = AuthServiceProxy("http://%s:%s@%s:%s" % (self.config["username"], self.config["password"], self.config["host"], self.config["port"]))
self.con.getinfo()

View File

@ -9,7 +9,6 @@
from pyircbot.modulebase import ModuleBase,ModuleHook
import random
import yaml
import os
import time
from threading import Timer

View File

@ -9,7 +9,7 @@
from pyircbot.modulebase import ModuleBase,ModuleHook
import time
import yaml
import json
import random
from threading import Timer
import os
@ -20,7 +20,7 @@ class DuckHunt(ModuleBase):
self.hooks=[ModuleHook("PRIVMSG", self.hunt)]
self.loadConfig()
self.ymlPath = self.getFilePath("scores.yml")
self.jsonPath = self.getFilePath("scores.json")
self.timer = None
self.isDuckOut = False
@ -125,7 +125,7 @@ class DuckHunt(ModuleBase):
def startHunt(self):
" Creates a timer that waits a certain amount of time then sends out a bird \_o< quack"
" Creates a timer that waits a certain amount of time then sends out a bird \\_o< quack"
delay = self.config["delayMin"] + random.randint(0, self.config["delayMax"]-self.config["delayMin"])
self.timer = Timer(delay, self.duckOut)
self.timer.start()
@ -157,12 +157,12 @@ class DuckHunt(ModuleBase):
self.saveScores(scores)
def loadScores(self):
if not os.path.exists(self.ymlPath):
yaml.dump({}, open(self.ymlPath, 'w'))
return yaml.load(open(self.ymlPath, 'r'))
if not os.path.exists(self.jsonPath):
json.dump({}, open(self.jsonPath, 'w'))
return json.load(open(self.jsonPath, 'r'))
def saveScores(self, scores):
yaml.dump(scores, open(self.ymlPath, 'w'))
json.dump(scores, open(self.jsonPath, 'w'))
def ondisable(self):
self.timer.cancel()

View File

@ -9,7 +9,6 @@
from pyircbot.modulebase import ModuleBase,ModuleHook
import random
import yaml
import os
import time
from threading import Timer

View File

@ -8,7 +8,7 @@
from pyircbot.modulebase import ModuleBase,ModuleHook
import random
import yaml
import json
import os
import time
from threading import Timer
@ -34,14 +34,14 @@ class Scramble(ModuleBase):
wordsF.close
self.log.info("Scramble: Loaded %s words" % str(self.wordsCount))
# Load scores
self.scoresFile = self.getFilePath("scores.yml")
self.scoresFile = self.getFilePath("scores.json")
if not os.path.exists(self.scoresFile):
yaml.dump({}, file(self.scoresFile, 'w'))
self.scores = yaml.load(file(self.scoresFile, 'r'))
json.dump({}, open(self.scoresFile, 'w'))
self.scores = json.load(open(self.scoresFile, 'r'))
# Per channel games
self.games = {}
# Hook in
self.hooks=[ModuleBase.ModuleHook("PRIVMSG", self.scramble)]
self.hooks=[ModuleHook("PRIVMSG", self.scramble)]
def scramble(self, args, prefix, trailing):
channel = args[0]
@ -51,7 +51,7 @@ class Scramble(ModuleBase):
self.games[channel].scramble(args, prefix, trailing)
def saveScores(self):
yaml.dump(self.scores, file(self.scoresFile, 'w'))
json.dump(self.scores, open(self.scoresFile, 'w'))
def getScore(self, player, add=0):
player = player.lower()
@ -93,7 +93,7 @@ class scrambleGame:
self.hintsGiven = 0
# Cooldown between words
self.nextTimer = None
# How many guesses submitted this round
# How many gamesWithoutGuesses submitted this round
self.guesses = 0;
# How many games in a row where nobody guessed
self.gamesWithoutGuesses = 0;

18
pyircbot/modules/Test.py Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env python
"""
.. module:: Test
:synopsis: For testing code
.. moduleauthor:: Dave Pedu <dave@davepedu.com>
"""
from pyircbot.modulebase import ModuleBase,ModuleHook
class Test(ModuleBase):
def __init__(self, bot, moduleName):
ModuleBase.__init__(self, bot, moduleName)
self.hooks=[ModuleHook("PRIVMSG", self.dotest)]
def dotest(self, args):
print("DOTEST(%s)"%(args,))

View File

@ -301,9 +301,7 @@ class PyIRCBot:
basepath = "%s/config/%s" % (self.botconfig["bot"]["datadir"], moduleName)
if os.path.exists("%s.yml"%basepath):
return "%s.yml"%basepath
elif os.path.exists("%s.json"%basepath):
if os.path.exists("%s.json"%basepath):
return "%s.json"%basepath
return None
@ -360,15 +358,12 @@ class PyIRCBot:
def load(filepath):
"""Return an object from the passed filepath
:param filepath: path to a file of json or yaml format. filename must end with .json or .yml
:param filepath: path to a json file. filename must end with .json
:type filepath: str
:Returns: | dict
"""
if filepath.endswith(".yml"):
from yaml import load
return load(open(filepath, 'r'))
elif filepath.endswith(".json"):
if filepath.endswith(".json"):
from json import load
return load(open(filepath, 'r'))
else: