def on_bot_load(bot):
    waiting_time = SaveIO.load(save_subdir, "waitingtime")
    if len(waiting_time) == 0:
        waiting_time = 20
    else:
        waiting_time = waiting_time[0]
    Data.waiting_time = waiting_time
    Data.links = SaveIO.load(save_subdir, "linkedWords")
    if Data.links == {}:
        Data.links = []
        SaveIO.save(Data.links, save_subdir, "linkedWords")
    Data.link_explanations = SaveIO.load(save_subdir, "linkExplanations")
    if Data.link_explanations == {}:
        Data.link_explanations = []
        SaveIO.save(Data.link_explanations, save_subdir, "linkExplanations")
    Data.game_banned = SaveIO.load(save_subdir, "gameBannedUsers")
    Data.spell_manager.load()
    if Data.game_banned == {}:
        Data.game_banned = {"stackexchange.com": [],
                            "meta.stackexchange.com": [],
                            "stackoverflow.com": []}
    Data.joined_game = SaveIO.load(save_subdir, "usersInGame")
    if Data.joined_game == {} or Data.joined_game is None:
        Data.joined_game = {"stackexchange.com": [],
                            "meta.stackexchange.com": [],
                            "stackoverflow.com": []}
    Data.spell_manager.c = bot.client
    t = Thread(target=scheduled_empty_queue, args=(bot,))
    t.start()
Esempio n. 2
0
def on_bot_load(bot):
    global Points
    global Stars
    global Pins
    Points = SaveIO.load(save_subdir, 'Points_Data')
    Stars = SaveIO.load(save_subdir, 'Stars_Data')
    Pins = SaveIO.load(save_subdir, 'Pins_Data')
Esempio n. 3
0
def on_bot_load(bot):
    global command_banned_users
    global banned_users
    bot.command = command_ban_deco(bot.command)
    bot.on_event = ban_deco(bot.on_event, bot)
    command_banned_users = SaveIO.load(save_subdir, "command_banned_users")
    banned_users = SaveIO.load(save_subdir, "banned_users")
Esempio n. 4
0
def on_bot_load(bot):
    global command_banned_users
    global banned_users
    bot.command = command_ban_deco(bot.command)
    bot.on_event = ban_deco(bot.on_event, bot)
    command_banned_users = SaveIO.load(save_subdir, 'command_banned_users')
    banned_users = SaveIO.load(save_subdir, 'banned_users')
Esempio n. 5
0
def on_bot_load(bot):
    global data
    global auth_handler
    data = SaveIO.load(save_subdir, "keys_data")
    if data == {}:
        defaults['consumer_secret'] = get_secret()
        data = defaults
        SaveIO.save(data, save_subdir, "keys_data")

    auth_handler = tweepy.OAuthHandler(data['consumer_key'], data['consumer_secret'])
    if "access_token" in data and "access_token_secret" in data:
        auth_handler.set_access_token(data['access_token'], data['access_token_secret'])
    else:
        try:
            redirect_url = auth_handler.get_authorization_url()
        except tweepy.TweepError:
            print("[oauth] [tweepy] FATAL: Failed to get authorization URL.")
            sys.exit(503)
        webbrowser.open_new_tab(redirect_url)
        verifier = input("[oauth] Type the verification code from Twitter: ")
        try:
            access_token, access_token_secret = auth_handler.get_access_token(verifier)
        except tweepy.TweepError:
            print("[oauth] [tweepy] FATAL: Could not fetch access token with provided verifier code.")
            sys.exit(504)
        data['access_token'], data['access_token_secret'] = access_token, access_token_secret
        SaveIO.save(data, save_subdir, "keys_data")
        auth_handler.set_access_token(access_token, access_token_secret)
Esempio n. 6
0
def get_random_line(file):
    file = SaveIO.load(save_subdir,file,'txt')
    list_lines = file.splitlines()
    n_lines = len(list_lines)
    if n_lines>0:
	    message = list_lines[randint(0,n_lines-1)]
    else:
        message = "I am at loss for words. Contact my owner"
    return message    
Esempio n. 7
0
def on_bot_load(bot):
    global Medals
    Medals = SaveIO.load(save_subdir, "Medals_Data")
 def load(self):
     self.earnedSpells = SaveIO.load("shadowsden", "earnedSpells")
Esempio n. 9
0
def put_tweet(tweet_id, dt, tweet_text):
    tweets = SaveIO.load(save_subdir, 'tweets')
    tweets[tweet_id] = [dt, tweet_text]
    SaveIO.save(tweets, save_subdir, 'tweets')
Esempio n. 10
0
def get_token():
    return SaveIO.load(save_subdir, "SphereEngineKey", "txt")