Example #1
0
def lfaqadd(text, reply, event):
    data = WorkingWithFiles.JSONloadFromDisk("data/local_faq/" + event.chan)
    text = text.split()

    word = text[0]

    answer = ' '.join(text[1:])

    data[word] = answer

    WorkingWithFiles.JSONsaveToDisk(data, "data/local_faq/" + event.chan)

    reply("The word " + word +
          " has been added to the LOCAL FAQ. It refers to : " + answer)
Example #2
0
def faqadd(text, reply):
    data = WorkingWithFiles.JSONloadFromDisk("data/faq.json")
    text = text.split()

    word = text[0]

    answer = ' '.join(text[1:])

    data[word] = answer

    WorkingWithFiles.JSONsaveToDisk(data, "data/faq.json")

    reply("The word " + word + " has been added to the FAQ. It refers to : " +
          answer)
Example #3
0
def reset(nick, reply, text):
    if enableTokens:
        WorkingWithFiles.JSONsaveToDisk(default, 'data/usedata/' + nick +
                                        '.json')  # Save to disk
        reply(text + " usetokens was deleted by " + nick)
    else:
        reply("Tokens are not enabled !")
Example #4
0
def getTokens(nick):
    if enableTokens:
        data = WorkingWithFiles.JSONloadFromDisk(
            'data/usedata/' + nick + '.json', default)  # Get data from file
        tokens = int(data.get("tokens", default))  # Extract tokens of a player
        return tokens
    else:
        return staticTokens
Example #5
0
def getMoney(nick):
    """
    :param nick: The nickname of the player
    :return int: The money of the specified player
    """
    data = WorkingWithFiles.JSONloadFromDisk('data/casino.json',
                                             default)  # Get data from file
    argent = int(data[nick]["money"])  # Extract money of a player
    return argent
Example #6
0
def getBet(nick):
    """
    :param nick: The nickname of the player
    :return int: The bet of the specified player
    """
    data = WorkingWithFiles.JSONloadFromDisk('data/casino.json',
                                             default)  # Get data from file
    bet = int(data[nick]["bet"])  # Extract bet of a player
    return bet
Example #7
0
def getCards(nick):
    """
    :param nick: The nickname of the player
    :return list: The cards of the specified player
    """
    data = WorkingWithFiles.JSONloadFromDisk('data/casino.json',
                                             default)  # Get data from file
    cards = data[nick]["cards"]  # Extract cards of a player
    return list(cards)
Example #8
0
def faq(text, reply, notice, event, message):
    text = text.split()
    GlobalData = WorkingWithFiles.JSONloadFromDisk("data/faq.json")
    LocalData = WorkingWithFiles.JSONloadFromDisk("data/local_faq/" +
                                                  event.chan)

    try:
        reponse = FindTheWord(LocalData, GlobalData, text[0])

    except:
        return "I'm Sorry, but I can't find this! Use !listfaq and !llistfaq to see what are the current defined factoids."

    try:
        message(" > " + text[1] + " => " + reponse)

    except:
        reply(reponse)
        notice(
            "Did you know ? You can use !faq word user to HL a particular user "
        )
Example #9
0
def savePlayerData(nick, argent="NotProvided", mise=None, cards=None):
    """
    Save a player data
    """

    if argent == "NotProvided":

        argent = getMoney(nick)

    if not mise:

        mise = getBet(nick)

    if not cards:

        cards = getCards(nick)

    data = WorkingWithFiles.JSONloadFromDisk('data/casino.json', default)
    data[nick] = {
        "money": int(argent),
        "bet": int(mise),
        "cards": list(cards)
    }  # Save to data
    WorkingWithFiles.JSONsaveToDisk(data, 'data/casino.json')  # Save to disk
Example #10
0
def reset(reply, text):
    data = WorkingWithFiles.JSONloadFromDisk('data/casino.json', default)
    data[text] = default  # Save to data
    WorkingWithFiles.JSONsaveToDisk(data, 'data/casino.json')  # Save to disk
    reply(text + " stats was deleted")
Example #11
0
            return True
        else:
            return False

    def __getitem__(self, lookfor):
        """Overides Dictionary __getitem__ to use fuzzy matching"""
        matched, key, item, ratio = self._search(lookfor)

        if not matched:
            raise KeyError("'%s'. closest match: '%s' with ratio %.3f" %
                           (str(lookfor), str(key), ratio))

        return item


WorkingWithFiles.checkExistsPath("data/local_faq/")


def FindTheWord(LocalData, GlobalData, word):
    try:
        answer = LocalData[word]
        return answer
    except:
        pass

    try:
        answer = GlobalData[word]
        return answer
    except:
        pass
Example #12
0
"""

enableTokens = True
staticTokens = int(999999999999)  # Change this to the ammount of tokens everybody will have if enableTokens is False

from cloudbot import hook

if enableTokens:
    from cloudbot.util import WorkingWithFiles
default = """{
"tokens": 0
}"""

if enableTokens:
    WorkingWithFiles.checkExistsPath("data/usedata/")


def getTokens(nick):
    if enableTokens:
        data = WorkingWithFiles.JSONloadFromDisk('data/usedata/' + nick + '.json', default)  # Get data from file
        tokens = int(data.get("tokens", default))  # Extract tokens of a player
        return tokens
    else:
        return staticTokens


def giveTokens(NumberOftokens, nick):
    if enableTokens:
        tokens = getTokens(nick)
        tokens += NumberOftokens
Example #13
0
def llistfaq(reply, event):
    WorkingWithFiles.checkExistsFile("data/local_faq/" + event.chan)
    file = open("data/local_faq/" + event.chan, 'r').read().encode('UTF-8')
    lien = web.paste(file)
    reply(str(lien))
Example #14
0
License:
    GNU General Public License (Version 3)
"""
from random import randrange
import random
import time

from math import ceil
from cloudbot import hook
from cloudbot.util import WorkingWithFiles

default = {"money": 100, "bet": 1, "cards": ""}

# save / load

WorkingWithFiles.checkExistsFile("data/casino.json")


# Parsing

def getMoney(nick):
    """
    :param nick: The nickname of the player
    :return int: The money of the specified player
    """
    data = WorkingWithFiles.JSONloadFromDisk('data/casino.json', default)  # Get data from file
    argent = int(data[nick]["money"])  # Extract money of a player
    return argent


def getBet(nick):
Example #15
0
License:
    GNU General Public License (Version 3)
"""
from random import randrange
import random
import time

from math import ceil
from cloudbot import hook
from cloudbot.util import WorkingWithFiles

default = {"money": 100, "bet": 1, "cards": ""}

# save / load

WorkingWithFiles.checkExistsFile("data/casino.json")

# Parsing


def getMoney(nick):
    """
    :param nick: The nickname of the player
    :return int: The money of the specified player
    """
    data = WorkingWithFiles.JSONloadFromDisk('data/casino.json',
                                             default)  # Get data from file
    argent = int(data[nick]["money"])  # Extract money of a player
    return argent

Example #16
0
enableTokens = True
staticTokens = int(
    999999999999
)  # Change this to the ammount of tokens everybody will have if enableTokens is False

from cloudbot import hook

if enableTokens:
    from cloudbot.util import WorkingWithFiles
default = """{
"tokens": 0
}"""

if enableTokens:
    WorkingWithFiles.checkExistsPath("data/usedata/")


def getTokens(nick):
    if enableTokens:
        data = WorkingWithFiles.JSONloadFromDisk(
            'data/usedata/' + nick + '.json', default)  # Get data from file
        tokens = int(data.get("tokens", default))  # Extract tokens of a player
        return tokens
    else:
        return staticTokens


def giveTokens(NumberOftokens, nick):
    if enableTokens:
        tokens = getTokens(nick)
Example #17
0
def saveUseData(nick, tokens):
    if enableTokens:
        data = {"tokens": int(tokens)}  # Save to data
        WorkingWithFiles.JSONsaveToDisk(data, 'data/usedata/' + nick +
                                        '.json')  # Save to disk
Example #18
0
def llistfaq(reply, event):
    WorkingWithFiles.checkExistsFile("data/local_faq/" + event.chan)
    file = open("data/local_faq/" + event.chan, 'r').read().encode('UTF-8')
    lien = web.paste(file)
    reply(str(lien))
Example #19
0
        else:
            return False

    def __getitem__(self, lookfor):
        """Overides Dictionary __getitem__ to use fuzzy matching"""
        matched, key, item, ratio = self._search(lookfor)

        if not matched:
            raise KeyError(
                "'%s'. closest match: '%s' with ratio %.3f" %
                (str(lookfor), str(key), ratio))

        return item


WorkingWithFiles.checkExistsPath("data/local_faq/")


def FindTheWord(LocalData, GlobalData, word):
    try:
        answer = LocalData[word]
        return answer
    except:
        pass

    try:
        answer = GlobalData[word]
        return answer
    except:
        pass