Example #1
0
    def __init__(self, config):
        import bot
        from server import Server
        self.config = config
        # Values from config
        self.sprites = {}
        self.colors: List[str] = []
        self.color_map: Dict[str, int] = {}
        self.bump_width: int = None
        self.bump_height: int = None
        self.width: int = None
        self.height: int = None
        self.chat_radius: int = None
        self.max_buffer: int = None
        self.world_map: numpy.ndarray = None
        self.bump_map: numpy.ndarray = None
        self.portals: Dict[Tuple[int, int], Dict[str, int]] = {}
        self.entities: Dict[Tuple[int, int], Entity] = {}
        self.dialogue: Dict[str, interactions.Dialogue] = {}
        self.base_items: Dict[str, dict] = {}
        self.messages = {}
        self.battles: List[Battle] = []

        self.config = config
        self.mongo = MongoClient()
        self.legend_db = self.mongo.legend
        self.users = self.legend_db.users
        self.games: Dict[str, DiscordGame] = {}
        self.load_config()
        self.world = World(self.world_map, self.bump_map, self.portals,
                           self.entities)
        self.server: Server = None
        self.server_thread = None
        self.running = False
        print("Create bot")
        self.bot = None
        self.loop = None
        # This is blocking, it must run last.
        bot.create_bot(config, self)
Example #2
0
 def test_create(self):
     assert isinstance(create_bot(), Bot)
Example #3
0
import os

from bot import create_bot

if __name__ == "__main__":
    token = os.environ.get("BOT_TOKEN")

    if not token:
        raise EnvironmentError

    bot = create_bot()
    bot.run(token)
Example #4
0
from bot import create_bot
from dotenv import load_dotenv
from pathlib import Path
import os

load_dotenv(dotenv_path=Path('.env'))

bot_prefix = ("!", "?")
client = create_bot(bot_prefix=bot_prefix, self_bot=False)

if __name__ == '__main__':
    client.run(os.getenv("discord_token_bot", None))
Example #5
0
def main():
    TOKEN = 'your_token'
    updater = create_bot(TOKEN)
    updater.start_polling()
    updater.idle()
Example #6
0
def run():
    bot = create_bot()
    post = make_post(bot)
    sticky_post(post)
Example #7
0
def bot():
    bot = create_bot()
    return bot
Example #8
0
File: sim.py Project: mfekadu/jeans
    s1 = arbiter.shapes[0]
    s2 = arbiter.shapes[1]
    if hasattr(s1.body, 'type') and hasattr(s2.body, 'type'):
        types = [s1.body.type, s2.body.type]
        if ('bot' in types):
            print("separate_collision", arbiter.shapes, space,
                  data) if cfg.DEBUG >= 2 else None


handler = space.add_default_collision_handler()
handler.begin = begin_collision
handler.pre_solve = pre_collision
handler.post_solve = post_collision
handler.separate = separate_collision

bot_body, bot_shape = create_bot()


def run():
    '''
    run the main loop for the game engine
    '''
    p_app.run()


def schedule(fun):
    '''
    given a function name
    tell pyglet to call that function every 1/60 seconds
    '''
    p_clock.schedule_interval(fun, cfg.PY_STEP)