Example #1
0
def cron(channel):
    import globals
    try:
        channel = channel.lstrip("#")
        from src.lib.twitch import get_stream_status, get_hosts
        from src.lib.channel_data import ChannelData
        from src.lib.queries import Database
        cd = ChannelData(channel)
        if get_stream_status():
            channel_id = cd.get_channel_id_from_db()[0]
            hosts = get_hosts(channel_id)
            unthanked_users = []
            for host in hosts:
                host_data = cd.get_channel_data_by_user(host["host_login"], "host")
                if not host_data:
                    cd.insert_channel_data(host["host_login"], "host")
                    db = Database()
                    db.add_user([host["host_login"]], channel)
                    db.modify_points(host["host_login"], channel, 100)
                    unthanked_users.append(host["host_login"])
            if len(unthanked_users) == 1:
                user = unthanked_users[0]
                resp = "Thank you {0} for the host! Here's 100 cash!".format(user)
                globals.irc.send_message("#" + channel, resp)
            elif len(unthanked_users) > 1:
                resp = "The following users are receiving 100 cash for hosting: " + ", ".join(unthanked_users) + "!"
                globals.irc.send_message("#" + channel, resp)
            elif len(unthanked_users) > 10:
                resp = "Thanks to the {0} people hosting! Each of you get 100 cash!".format(
                    len(unthanked_users))
                globals.irc.send_message("#" + channel, resp)
        else:
            cd.remove_channel_data("host")
    except Exception as error:
        print error
Example #2
0
def treatsForAllTimer(channel, delta):
    if twitch.get_stream_status(channel):
        user_dict, all_users = twitch.get_dict_for_users(channel)
        try:
            modify_points_all_users_timer(all_users, delta)
        except:
            return "Twitch's backend is down. Treats can't be added in this state. Moderators should monitor http://twitchstatus.com/ for updates."
Example #3
0
def cron(channel):
    try:
        channel = channel.lstrip("#")
        from src.lib.twitch import get_stream_status, get_hosts
        from src.lib.channel_data import ChannelData
        from src.lib.queries import Database
        cd = ChannelData(channel)
        if get_stream_status():
            channel_id = cd.get_channel_id_from_db()[0]
            hosts = get_hosts(channel_id)
            unthanked_users = []
            for host in hosts:
                host_data = cd.get_channel_data_by_user(
                    host["host_login"], "host")
                if not host_data:
                    cd.insert_channel_data(host["host_login"], "host")
                    db = Database()
                    db.add_user([host["host_login"]], channel)
                    db.modify_points(host["host_login"], channel, 100)
                    unthanked_users.append(host["host_login"])
            if len(unthanked_users) == 1:
                user = unthanked_users[0]
                resp = "Thank you {0} for the host! Here's 100 cash!".format(
                    user)
                globals.irc.send_message("#" + channel, resp)
            elif len(unthanked_users) > 1:
                import globals
                resp = "The following users are receiving 100 cash for hosting: " + ", ".join(
                    unthanked_users) + "!"
                globals.irc.send_message("#" + channel, resp)
            elif len(unthanked_users) > 10:
                resp = "Thanks to the {0} people hosting! Each of you get 100 cash!".format(
                    len(unthanked_users))
                globals.irc.send_message("#" + channel, resp)
        else:
            cd.remove_channel_data("host")
    except Exception as error:
        print error