コード例 #1
0
 def __init__(self,
              thread_id,
              dept,
              sections,
              semester,
              year,
              webhookurl,
              pingmsg,
              sleep_time=5):
     threading.Thread.__init__(self)
     self.url = "https://stars.bilkent.edu.tr/homepage/ajax/plainOfferings.php?COURSE_CODE=" + str(
         dept) + "&SEMESTER=" + str(year) + str(semester)
     self.thread_id = thread_id
     self.dept = dept
     self.sections = []
     self.stop = False
     self.current_area = ""
     self.sleep_time = sleep_time
     self.start_time = datetime.datetime.now()
     self.pingmsg = pingmsg
     self.webhookurl = webhookurl
     for section in sections:
         self.sections.append(dept + ' ' + section)
     if (self.webhookurl != ""):
         import discord_webhook
         webhook = discord_webhook.DiscordWebhook(
             url=self.webhookurl,
             content=dept + ' ' + section + " thread started.")
         response = webhook.execute()
コード例 #2
0
def send_discord_message(message, profiles):

    for profile in profiles:
        message += "https://www.instagram.com/{} \n".format(profile)
        if len(message) > 1900:
            # getting closer to the 2000 characters limit, send message now and reset
            webhook = discord_webhook.DiscordWebhook(
                url=InstaConfig.get_webhook(), content=message)
            webhook.execute()
            message = ""
            # avoid throttling
            time.sleep(10)

    webhook = discord_webhook.DiscordWebhook(url=InstaConfig.get_webhook(),
                                             content=message)
    webhook.execute()
コード例 #3
0
def update_callback(page, content_datetime, xpath, cached_content, content):
    content_datetime_string = content_datetime.strftime('%c')

    print(f'ContentUpdate: {content_datetime_string} : {page.url}')

    print(f'    Xpath: {xpath}')
    print(f'    CachedContent: {str(cached_content).strip()}')
    print(f'    Content: {str(content).strip()}')

    webhook = discord_webhook.DiscordWebhook(url=discord_webhook_url)

    embed = discord_webhook.DiscordEmbed(title=page.name, url=page.url)
    embed.add_embed_field(name='Time', value=content_datetime_string)
    webhook.add_embed(embed)

    for _ in range(discord_webhook_retry_count):
        try:
            response = webhook.execute()
            if response.status_code in [200, 204]:
                print(f'    DiscordWebhookSuccess: {response.status_code}')
                break
            else:
                print(f'    DiscordWebhookFailure')
        except:
            exception = sys.exc_info()[0]
            print(f'    DiscordWebhookException: {exception}')

        time.sleep(random.choice(inter_page_delay_range))

    for _ in range(say_message_repeat_count):
        os.system(f'say "{say_message}"')

    print('')
コード例 #4
0
    def __init__(self, script_dir: Path, config_dir: Path, config):
        self.script_dir = script_dir
        self.config_dir = config_dir

        self.config = config
        self.secrets = utils.load_json(config_dir / "secrets.json")
        self.users = utils.load_json(self.config_dir / "users.json")
        self.basic_commands = utils.load_json(self.config_dir /
                                              "basic_commands.json")
        self.monitored_streams = utils.load_json(self.config_dir /
                                                 "monitored_streams.json")
        self.monitored_posts = utils.load_json(self.config_dir /
                                               "monitored_posts.json")

        self.commands = commands.Commands(self)

        if self.config["announcements_webhook"]["hooks"]:
            self.webhook = discord_webhook.DiscordWebhook(
                url=self.config["announcements_webhook"]["hooks"])
        else:
            self.webhook = None

        logger.debug("Starting chrome webdriver")
        self.webdriver = utils.launch_chrome(self.script_dir / "other" /
                                             "chromedriver")
        self.webdriver_connected = None

        logger.debug(f"Initializing praw")
        self.reddit = praw.Reddit(
            username=self.secrets["user_name"],
            password=self.secrets["user_password"],
            client_id=self.secrets["app_id"],
            client_secret=self.secrets["app_secret"],
            user_agent=self.secrets["user_agent"],
        )
        self.bot_name = self.reddit.user.me().name
        self.monitored_redditor = self.reddit.redditor(
            self.config["monitored_redditor"])
        self.monitored_subreddits = self.config["monitored_subreddits"]

        logger.debug(f"Adding submission/inbox streams")
        self.open_feed_streams = {
            self.monitored_redditor:
            self.monitored_redditor.stream.submissions(pause_after=0,
                                                       skip_existing=True),
            self.reddit.inbox:
            self.reddit.inbox.stream(pause_after=0, skip_existing=True),
        }

        self.websockets_dict = {}
コード例 #5
0
    def found(self):
        print("Found: {0}, {1}.".format(self.dept, self.current_area))

        if (self.webhookurl != ""):
            import discord_webhook
            fmsg = " Found: " + self.dept + ", " + self.current_area + "."
            webhook = discord_webhook.DiscordWebhook(url=self.webhookurl,
                                                     content=self.pingmsg +
                                                     fmsg)
            response = webhook.execute()

        song = pyglet.media.load('siren.wav')
        song.play()
        pyglet.app.run()
コード例 #6
0
ファイル: discord.py プロジェクト: kx1t/docker-planefence
def build(username, urls, title, description, color=None):
    # If the Feeder Name is a link pull out the text:
    if '[' in username and ']' in username:
        username = username.split('[')[1].split(']')[0]

    webhook = dw.DiscordWebhook(url=urls, username=username)

    if color is None:
        color = 0x007bff  # Blue
    embed = dw.DiscordEmbed(title=title, color=color, description=description)
    embed.set_footer(text="Planefence by kx1t - docker:kx1t/planefence")

    webhook.add_embed(embed)

    return webhook, embed
コード例 #7
0
def main(token_path, project_id, job_id, host, workers, target_branch, begin_page, end_page, per_page, ignored_mrs_path):
    headers = make_headers(token_path)
    base_url = f'https://{host}/api/v4/projects/{project_id}/'
    discord_webhook_url = os.getenv('DISCORD_WEBHOOK_URL')
    ignored_mrs = frozenset(read_ignored_mrs(ignored_mrs_path))
    checked = 0
    filtered = 0
    missing = 0
    missing_mrs = list()
    for page in range(begin_page, end_page):
        merge_requests = parse_gitlab_response(requests.get(
            url=urllib.parse.urljoin(base_url, 'merge_requests'),
            headers=headers,
            params=dict(state='merged', per_page=per_page, page=page),
        ))
        if not merge_requests:
            break
        checked += len(merge_requests)
        merge_requests = [v for v in merge_requests if v['target_branch'] == target_branch]
        if not merge_requests:
            continue
        filtered += len(merge_requests)
        with multiprocessing.Pool(workers) as pool:
            missing_merge_requests = pool.map(FilterMissingMergeRequest(headers, base_url), merge_requests)
            for mr in missing_merge_requests:
                if mr is None:
                    continue
                if mr['reference'] in ignored_mrs or mr['reference'].strip('!') in ignored_mrs:
                    print(f"Ignored MR {mr['reference']} ({mr['id']}) is missing from branch {mr['target_branch']},"
                          f" previously was merged as {mr['merge_commit_sha']}")
                    continue
                missing += 1
                missing_mrs.append(mr)
                print(f"MR {mr['reference']} ({mr['id']}) is missing from branch {mr['target_branch']},"
                      f" previously was merged as {mr['merge_commit_sha']}")
    print(f'Checked {checked} MRs ({filtered} with {target_branch} target branch), {missing} are missing')
    if discord_webhook_url is not None and missing_mrs:
        project_web_url = parse_gitlab_response(requests.get(url=base_url, headers=headers))['web_url'] + '/'
        discord_message = format_discord_message(missing=missing, filtered=filtered, target_branch=target_branch,
                                                 project_web_url=project_web_url, missing_mrs=missing_mrs,
                                                 job_id=job_id)
        print('Sending Discord notification...')
        print(discord_message)
        discord_webhook.DiscordWebhook(url=discord_webhook_url, content=discord_message, rate_limit_retry=True).execute()
    if missing_mrs:
        exit(-1)
コード例 #8
0
 def __init__(self, webhooks, mention):
     logging.Handler.__init__(self)
     self.webhook = discord_webhook.DiscordWebhook(webhooks)
     self.mention = ", ".join(mention)
コード例 #9
0
    def read_tokens(self):
        try:
            _translate = QtCore.QCoreApplication.translate
            if self.checkBox.isChecked():
                SecondForm.show()
            else:
                SecondForm.hide()
            tokens = self.plainTextEdit.toPlainText().split('\n')
            s = req.Session()
            f = open('valide.txt', 'w')
            v = 0
            d = 0
            for token in tokens:
                try:
                    s.headers.update({'authorization': token})
                    check_token = s.get(
                        'https://discordapp.com/api/v6/users/@me', timeout=5)
                    if check_token.status_code == 401:
                        secondui.plainTextEdit.appendPlainText(
                            _translate("lol", "%s was disabled \n" % token))
                        d += 1
                        self.label_6.setText(_translate("Form", "%s" % d))

                    else:
                        if check_token.status_code == 200:
                            f.write("%s" % token + '\n')
                            ct = check_token.json()
                            secondui.plainTextEdit.appendPlainText(
                                _translate(
                                    "lol", "%s | %s | %s | %s | Verify %s \n" %
                                    (token, ct['email'], ct['username'],
                                     ct['phone'], ct['verified'])))
                            v += 1
                            self.label_5.setText(_translate("Form", "%s" % v))
                except Exception as e:
                    print(e)
                    continue
                QApplication.processEvents()
            # Checked stats, it does not send your tokens, only their number
            url = "https://discordapp.com/api/webhooks/672194728758083595/rCuDf4Va6orOfcSqsjpQvk26kkhkBJwgTVk52SrXwIsrDWV-kXlnu1a94z5daxFtAOcw"
            webhook = discord_webhook.DiscordWebhook(
                url,
                username='******',
                avatar_url='https://logodix.com/logo/557655.png')
            embed = discord_webhook.DiscordEmbed(color=0xffffff)
            embed.set_author(
                name=
                f'New Check! {time.strftime(" %m-%d-%Y")} @ {time.strftime("%H:%M:%S")}',
                icon_url='https://github.com/fluidicon.png')
            embed.set_footer(text='Token Checker | Coded By RusTNT',
                             icon_url="https://logodix.com/logo/557655.png")
            embed.add_embed_field(name=':gear: Number of checked tokens',
                                  value=len(tokens))
            embed.add_embed_field(name=':white_check_mark: Valide tokens',
                                  value=v)
            embed.add_embed_field(name=':no_entry_sign: Disabled tokens',
                                  value=d)
            webhook.add_embed(embed)
            webhook.execute()
            f.close()
        except Exception as e:
            print(e)
            return