def freezeUsers(): bantime = int(time.time()) db.execute( "SELECT id, username FROM users WHERE freezedate < %s AND frozen = 1 AND privileges > 2", (bantime, )) checkfrozen = db.fetchall() id = checkfrozen reason = "Auto-restricted for not submitting a liveplay upon request." if id is not None: for row in checkfrozen: user = row[0] name = row[1] print(f"Restricting {name} for expired freeze timer...") db.execute( "UPDATE users SET privileges = 2, ban_datetime = %s WHERE id = %s", (bantime, user)) if config.Webhook is not None: db.execute("UPDATE users SET notes = %s WHERE id = %s", (reason, user)) logs = "has auto-restricted " + name + " for not submitting a liveplay upon request." db.execute( "INSERT INTO `rap_logs` (`id`, `userid`, `text`, `datetime`, `through`) VALUES (NULL, '4', %s, %s, 'Misumi Admin Panel')", (logs, bantime)) webhookdesp = "{} has been autorestricted from failing to provide a liveplay".format( name) webhook = webhook.Webhook(config.Webhook, color=0xadd8e6, footer="Misumi Anti Cheat") webhook.set_author(name='Nahoko', icon='https://a.misumi.me/4', url="https://misumi.me/u/4") webhook.set_title(title="osu!Misumi", url='https://misumi.me') webhook.set_desc(webhookdesp) webhook.post() print('Expired Freeze Timers: Done!')
def main(): collections = os.environ.get('COLLECTIONS', '') s3_url = os.environ.get('S3', '') webhook_url = os.environ.get('WEBHOOK', '') sentry_url = os.environ.get('SENTRY', '') r = raven.Client(sentry_url) w = webhook.Webhook(webhook_url, s3_url) collections = collections.split(',') docs = {} while True: try: for collection in collections: doc = w.get(collection) docs[collection] = doc w.send(docs) except Exception as e: print e r.captureException() time.sleep(30 * 60) # 30 min.
def webhookPost(): # url = "https://discordapp.com/api/webhooks/430687214549204993/KeRt_krZwouxhHNDrbkbg64HXgZdUM2XQlqL3Ny5SFusM-I-U79wbGaqqxy4UdF_kSB3" url = "https://discordapp.com/api/webhooks/431783097521143810/Gm58CDhYUXJBcAImv5lrzaPSS8l7fAlVgVUELWs_LiyrmKMHv3mgr4_Rs8IrKPLAG6d8" mbox_text = a.mbox.get(1.0, END) username_text = a.entry1.get() imgurl_text = a.entry2.get() if username_text == "": username_text = None if imgurl_text == "": imgurl_text = None wb = webhook.Webhook(url, mbox_text, username_text, imgurl_text) try: wb.post() except Exception as err: print(err)
def index(self): # raw_body = cherrypy.request.body.read() raw_json = cherrypy.request.json # получаем вебхук if raw_json[ 'object_kind'] == 'merge_request': # если вебхук вызван мержреквестом logging.debug(raw_json) webhook_object = webhook.Webhook(raw_json) action = raw_json['object_attributes'].get('action', None) # действие for user in webhook_object.assignees_array: # для каждого пользователя private_key = db.token.find_one( {'idGitLab': encoder(user['username'])}) # достаем ключ авторизации пользователя if private_key is None: logging.error( "Warning! No user was found to a merge request!") else: if action is None: continue result = webhook_object.get_repo_compare(private_key) for receiver in db.token.find( {'idGitLab': encoder(user['username'])}): if result: # для каждого телеграм аккаунта, прикрепленного к этому юзеру for j, file in enumerate(result['diffs']): if action == 'open' or action == 'merged': webhook_object.send_open(receiver, file) if action == 'reopen' and j < 1: webhook_object.send_reopen(receiver) if action == 'update' and j < 1: webhook_object.send_update(receiver) if action == 'close' and j < 1: webhook_object.send_close(receiver) if action == 'none' and j < 1: webhook_object.send_new(receiver) if (action == 'update' or action == 'close') \ and len(result['diffs']) - 1 != 0 \ and j >= 1: webhook_object.send_others( receiver, result) break # прерываем вывод сообщений, чтобы не засорять чат else: webhook_object.send_undefined(receiver) # отсылаем кнопочку со ссылкой на merge request webhook_object.send_button(receiver)
#! /usr/bin/python3 """ Raider.IO progress """ import redis import requests import webhook import conf # Every wednesday 9am # 0 9 * * 3 timeout 58 /mnt/raid10/cron/raiderio.py >> /var/log/crons/raiderio.log 2>&1 wh = webhook.Webhook(conf.url_discord_webhook_guild) r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True, db=1) rio_api = "https://raider.io/api/v1/guilds/profile?region=eu&realm=dun%20modr&name=mirrors&fields=raid_progression%2Craid_rankings" slug = "antorus-the-burning-throne" api = requests.get(url=rio_api).json() if api is not None and "raid_rankings" in api and "raid_progression" and slug in api[ "raid_rankings"]: prev_rank = r.get("bot:raiderio") rank = api["raid_rankings"][slug]["mythic"]["realm"] progress = api["raid_progression"][slug]["summary"]
if(twitter_embed): embeds.append(twitter_embed) if(env.debug): embeds.append(debug_embed(twitter)) if(mastodon_embed): embeds.append(mastodon_embed) if(env.debug): embeds.append(debug_embed(mastodon)) if(github_embed): embeds.append(github_embed) if(env.debug): embeds.append(debug_embed(github)) if(steam_embed): embeds.append(steam_embed) if(env.debug): embeds.append(debug_embed(steam)) if(osu_embed): embeds.append(osu_embed) if(env.debug): embeds.append(debug_embed(osu)) success = webhook.Webhook().send_message( embeds=embeds ) if(success): print("Success.") else: print("Webhook Send Error. :(")
* @stevensu1977 (found keywords: join) If we have not gotten back to your issue within a few business days, you can try the following: * Join our [community slack channel](https://github.com/cloudnativeto/community/slack) and ask on #cloudnativeto. * Try find someone from [here](https://github.com/orgs/cloudnativeto/people) if you know they worked closely on the area and CC them. <sub>:owl: Hoot! I am a [Mjölnir-Bot], a bot for [cloudnativeto](https://github.com/cloudnativeto). My owner is [stevensu1977](https://github.com/stevensu1977).</sub> _Originally posted by @mjolnir-bot in https://github.com/cloudnativeto""" #初始化PyGithub github = Github(os.environ.get('GITHUB_ACCESS_TOKEN')) app = Flask(__name__) hook = webhook.Webhook(app) app.logger.debug("Load GITHUB_SECRET,GITHUB_ACCESS_TOKEN successful") def get_repo(repo_name): return github.get_repo(repo_name) def verify_hmac_hash(data, signature): """ verify_hmac_hash 通过github webhook secret 计算msg内容是否正确 """ github_secret = bytes(os.environ['GITHUB_SECRET'], 'UTF-8') mac = hmac.new(github_secret, msg=data, digestmod=hashlib.sha1) return hmac.compare_digest('sha1=' + mac.hexdigest(), signature)
def main(): urls = os.environ.get('URLS', '') webhook_url = os.environ.get('WEBHOOK', '') s3_url = os.environ.get('S3', '') r = raven.Client(os.environ.get('SENTRY_DSN', '')) if not urls: return w = webhook.Webhook(webhook_url, s3_url) post_list_parsers = [] for url in urls.split(','): post_list_parser = parser.PostListParser(url=url) post_list_parsers.append(post_list_parser) while True: try: post_parsers = [] for post_list_parser in post_list_parsers: posts = post_list_parser.parse() for post in posts: post_parser = parser.PostParser( session=post_list_parser.session, post=post) try: episodes = post_parser.parse() for episode in episodes: if w.exist(episode): continue episode_parser = parser.EpisodeParser( session=post_parser.session, episode=episode, referer=post.url) episode = episode_parser.parse() if not episode: continue if not episode.title: continue if not episode.images: continue if len(episode.images) < 1: continue w.send(episode) # end time.sleep(1) except Exception as e: print e continue except requests.ConnectionError as e: print e continue except httplib.BadStatusLine as e: print e continue except Exception as e: print e r.captureException() time.sleep(15 * 60) # 15 min
#! /usr/bin/python3 """ Streams Cron """ import time import sys import redis import requests import webhook import conf now = time.time() wh = webhook.Webhook(conf.url_discord_webhook_news) r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True, db=1) twitch_api = "https://api.twitch.tv/kraken/streams/followed?oauth_token={0}".format( conf.twitch_token) r.zremrangebyscore("bot:twitch", "-inf", now - (60 * 15)) t = requests.get(url=twitch_api).json() if "streams" not in t: print(t) sys.exit()