Beispiel #1
0
def purchase_item(item_id, qty):
    global force_stop

    retry_limit = 3
    for i in range(0, retry_limit):
        status, purchase_limit, purchased_qty = auto_purchase.purchase(
            item_id, qty)
        if not status:
            if purchase_limit:
                force_stop = True
                discord.send_message(
                    f"**Purchase Limit Reached** for id : {user_id}")
                return

            qty = qty - purchased_qty

            print("purchase failed")
            print(f"retrying to purchase {purchased_qty} more item")
            logger.log("Purchase Failed")
            logger.log(f"retrying to purchase {purchased_qty} more item")

        return

    print("Cannot purchase : something went wrong")
    logger.log("Cannot purchase : something went wrong")
    message = f"Failed Purchase : something went wrong. ID : {user_id} purchased: {purchased_qty}, remaining: qty"
    discord.send_message(message)
Beispiel #2
0
def call_data_on_discord(blue_data, red_data, p_blue_win, p_red_win):
    message = ""
    message += f"@everyone (Run by {get_git_username()})\n"
    message += prepare_team_discord_message(blue_data)
    message += prepare_team_discord_message(red_data)
    message += f"P({blue_data['name']} win)={round(p_blue_win, 3)}. "
    message += f"P({red_data['name']} win)={round(p_red_win, 3)}.\n\n"
    message += f"Implied odds: {blue_data['name']}=**{round(1/p_blue_win, 2)}**, "
    message += f"{red_data['name']}=**{round(1/p_red_win, 2)}**."
    send_message(message)
Beispiel #3
0
def run_refine():
    global force_stop
    global last_atb_slot

    inventory = get_inventory()
    plus = inventory[0]['plus']

    logger.log(f"current atb position : {last_atb_slot}")

    print(f"current atb position : {last_atb_slot}")
    if inventory[0]['item_id'] == 0:
        print("ITEM PECAH!!")
        time = datetime.now().strftime("%Y-%m-%d %H:%M")
        text = f"@everyone \n**ITEM PECAH!!** \nid : {user_id}\nIgn: \ntgl jam : {time}\n item: \nkronologi: lupa atb"
        discord.send_message(text)
        force_stop = True
        logger.log("ITEM PECAH!!")
        return

    if last_atb_slot == 0:
        print("purchasing ATB")
        logger.log("Purchasing ATB")
        purchase_item(auto_purchase.ITEM['atb'], atb_purchase_qty)
        sleep(1.5)
        get_atb_from_bank()
        last_atb_slot = 1

    if plus < 9 and plus > 6:
        print(f"refining to {plus+1}")
        logger.log(f"Refining to {plus+1}")
        refine_7_to_9(inventory)

    elif plus >= 9 and plus < max_tempa:
        print(f"refining to {plus+1}")
        logger.log(f"Refining to {plus+1}")
        refine_9_to_12(inventory)

    elif plus == 12:
        print("SUKSES +12 BOI")
        logger.log("SUKSES +12 BOI!!")
        discord.send_message(
            f"@everyone SUKSES JADI +12 BOII di id : {user_id}")

    if plus + 1 == get_item_result():
        print("SUKSES TEMPA")
        logger.log("SUKSES TEMPA")

    if max_tempa == get_item_result():
        discord.send_message(
            f"@everyone SUKSES TEMPA JADI {max_tempa} di id : {user_id}")
        logger.log(f"SUKSES TEMPA KE +{max_tempa}")
        force_stop = True

    if plus == 11:
        logger.log("Item Sukses jadi +11")
        discord.send_message(f"Item sukses jadi +11 di id : {user_id}")
Beispiel #4
0
def post_subreddit_stats(db, subreddit_name, testing=False):
    subreddit.logging.info("Started onceaday routine for /r/%s" %
                           subreddit_name)
    a_day_ago = datetime.datetime.fromtimestamp(time.time() - 60 * 60 * 24)
    a_week_ago = datetime.datetime.fromtimestamp(time.time() -
                                                 60 * 60 * 24 * 8)
    a_month_ago = datetime.datetime.fromtimestamp(time.time() -
                                                  60 * 60 * 24 * 31)
    graph_url = post_graph(
        draw_graph(db, subreddit_name, a_month_ago, a_week_ago),
        subreddit_name)
    subreddit.logging.info("Uploaded graph to %s" % graph_url)

    reddit_text = "## /r/%s moderator actions\n\n### In the last 24h:\n\n" % subreddit_name
    reddit_text += format_actions_reddit(db,
                                         subreddit_name,
                                         since=a_day_ago,
                                         vertical=True)
    reddit_text += "\n\n### 7 day rollover actions:\n\n"
    reddit_text += format_actions_reddit(db,
                                         subreddit_name,
                                         since=a_week_ago,
                                         vertical=True)
    reddit_text += "\n\nAutomatically generated by /u/jwnskanzkwk. [Source code](https://github.com/jwansek/SubredditModActionsLog)"

    subreddit.logging.info("Started posting to reddit...")
    reddit_url = subreddit.post_stats(subreddit_name,
                                      db.get_posting_subreddit(subreddit_name),
                                      graph_url, reddit_text)
    subreddit.logging.info("Posted to reddit @ %s" % reddit_url)

    webhookurl = db.get_webhook(subreddit_name, testing=testing)
    if webhookurl is not None:
        discord.send_message(webhookurl, subreddit_name, reddit_url, graph_url,
                             format_actions_discord(db, subreddit_name))
        subreddit.logging.info("Posted to discord.")
Beispiel #5
0
def order(side, quantity, symbol, order_type=ORDER_TYPE_MARKET):
    try:
        print("sending order")
        discord.send_message(
            f"[{datetime.now().strftime('%d/%m/%Y %H:%M:%S')}] Sending {side} order of {quantity} X {symbol}!"
        )
        order = client.create_order(symbol=symbol,
                                    side=side,
                                    type=order_type,
                                    quantity=quantity)
        print(order)
        discord.send_message(f"```json{json.dumps(order)}```")
    except Exception as e:
        print(f"an exception occured - {e}")
        discord.send_message(
            f"[{datetime.now().strftime('%d/%m/%Y %H:%M:%S')}] Order Failed - an exception occured - {e}!"
        )
        return False

    return True
Beispiel #6
0
 def send(self, sendable : Union[str, Embed]) -> NoReturn:
   if (isinstance(sendable, str)):
     send_message(destination=self.user, content=sendable)
   elif (isinstance(sendable, Embed)):
     send_message(destination=self.user, embed=sendable)
Beispiel #7
0
def on_close(ws):
    discord.send_message(
        f"[{datetime.now().strftime('%d/%m/%Y %H:%M:%S')}] Connection Closed!")
    print('closed connection')
Beispiel #8
0
def on_open(ws):
    discord.send_message(
        f"[{datetime.now().strftime('%d/%m/%Y %H:%M:%S')}] Connection Opened!")
    print('opened connection')