def job(): dc = LotteryController() numbers = dc.draw_numbers() #numbers_str = ",".join(str(x) for x in numbers) numbers_str = "3,5,12,15,29,17" webhook = Webhook.partial(DISCORD_WEBHOOK_LOTTERY_ID, DISCORD_WEBHOOK_LOTTERY_TOKEN, adapter=RequestsWebhookAdapter()) webhook.send(numbers_str, username="******")
def send_error_msg(content, url_error): url = url_error webhook = Webhook.from_url(url, adapter=RequestsWebhookAdapter()) embed = Embed() embed.add_field( name="Error", value="{}".format(content)).set_footer(text="Error_Detector") webhook.send('Monitor will be stopped please restart the monitor', embed=embed)
def post_to_discord_v2(url, username=None, message=None, filename=None): ### Todas as classes referenciadas, são classes do Discord (Webhook, RequestsWebhookAdapter e File) webhook = Webhook.from_url(url=url, adapter=RequestsWebhookAdapter()) if filename: with open(filename, "rb") as f: file = File(f, filename=Path(filename).name) return webhook.send(content=message, username=username, file=file) else: return webhook.send(content=message, username=username)
def sendWebhookMessage(webhook, name, body_to_post): webhook = Webhook.from_url(url=webhook, adapter=RequestsWebhookAdapter()) webhook.send( body_to_post, avatar_url= "https://upload.wikimedia.org/wikipedia/commons/9/99/Paul_denino_13-01-19.jpg" )
def report_on_discord(message, file=None): print("send report ") bot_name = "Отчетов повелитель" webhook = Webhook.partial(11111111111, '*****', adapter=RequestsWebhookAdapter()) webhook.send(message, username=bot_name, file=file)
class Bot: webhook = Webhook.from_url( 'https://discord.com/api/webhooks/818330362509918238/EQjeQmYltevJAjho3jKFVUzwQvUZVbzIENDNcMbBRcu7VO4kdZYQkRXN3s-EI3zNDKuN', adapter=RequestsWebhookAdapter()) def add_role(self, username, role): msg = f'jillu admit <@!{username}> {role}' self.webhook.send(msg)
def discordwebhook(message, WEBHOOK_ID, WEBHOOK_TOKEN, logger): webhook = Webhook.partial(WEBHOOK_ID, WEBHOOK_TOKEN, adapter=RequestsWebhookAdapter()) logger.debug('create discord webhook data') webhook.send(message) logger.info('announcement sent through discord webhook')
def sendWebhookMessage(body_to_post): for webhook in WEBHOOKS_TO_POST: webhook = Webhook.from_url(url=webhook, adapter=RequestsWebhookAdapter()) webhook.send( body_to_post, username="******", avatar_url= "https://media-exp1.licdn.com/dms/image/C560BAQHm82ECP8zsGw/company-logo_200_200/0/1593628073916?e=2159024400&v=beta&t=89u72cg5KzjSQ1qwB9xPZYhWvr7jFkD_9mUyFdNFnVw" )
async def reboot(): with open('webhook.json') as f: webhook_iroioro = json.load(f) webhook = Webhook.partial(734178673162321930, webhook_iroioro["token_reboot"], adapter=RequestsWebhookAdapter()) webhook.send("再起動、始めました", username='******', avatar_url=webhook_iroioro["avater_reboot"]) webhook = Webhook.partial(734666355944718428, webhook_iroioro["token_reboot1"], adapter=RequestsWebhookAdapter()) webhook.send("再起動、始めました", username='******', avatar_url=webhook_iroioro["avater_reboot"]) await client1.change_presence(activity=discord.Game(name="停止中")) await client2.change_presence(activity=discord.Game(name="停止中")) await client3.change_presence(activity=discord.Game(name='停止中')) await client4.change_presence(activity=discord.Game(name='停止中'))
async def send_webhook(webhook, message, ctx): webhook_id = webhook.id webhook_token = webhook.token webhook = Webhook.partial(int(webhook_id), f"{webhook_token}", adapter=RequestsWebhookAdapter()) webhook.send(f'{message}', username=f"{ctx.author.display_name}", avatar_url=ctx.author.avatar_url) # Sends the message as the author delete_array = [ctx.message] await ctx.channel.delete_messages(delete_array) # Remove the command to make things look cleaner - optional
def send_webhook(): url = webhook_url() product_title, img_url, result = get_variants() webhook = Webhook.from_url(url=url, adapter=RequestsWebhookAdapter()) embed = Embed(title=product_title, url=url) embed.add_field(name='可用尺码', value='\n'.join(result)) embed.set_thumbnail(url=img_url) webhook.send(embed=embed, avatar_url=avatar_url(), username='******')
def riskless_internal(debug_file): now= datetime.now() nowstring = now.hour webhook = Webhook.partial(674056380772253697, 'RTuPvf30qDTtx-WM3s_bfiqxtEJ29KRHadOOqW-2glW-zfCW1Q8NHFIRu1px7qU2RqFi', adapter=RequestsWebhookAdapter()) previouslist = [] prev_ids = [] while nowstring != 3: marketlist, debuglist, ids, runtime = riskless_algo() # print(marketlist) # print(debuglist) # print(ids) if debuglist == []: if previouslist != []: webhook.send('Markets are no longer riskless!') else: None else: n = 0 m = 0 for prev_id in prev_ids: n = n+1 if prev_ids == []: None elif prev_id not in ids: webhook.send('Market no longer riskless! Market ID: '+str(prev_id)+', Market Name: '+ previouslist[n-1][1]) else: None for good_id in ids: m = m+1 if good_id in prev_ids: None else: webhook.send('Market ID: '+str(good_id)+', Market Name: '+ debuglist[m-1][1]+', Expected Profit per Share: '+ str(debuglist[m-1][2]) +', Link to Market: https://www.predictit.org/markets/detail/'+str(good_id)+ ' , Prices of Contracts: ' + str(debuglist[m-1][3])) previouslist = debuglist prev_ids = ids with open(debug_file, 'a') as file: writer = csv.writer(file) line = debuglist insertion = ([datetime.now()]+line) writer.writerow(insertion) file.close() time.sleep(60) now= datetime.now() nowstring = now.hour else: time.sleep(60) now= datetime.now() nowstring = now.hour riskless_internal(debug_file)
def TKS_webhook(user_name, avi_url, webhook_link, info_dic, fields, custom): #info_dict{product link, title, site, thumbnail,} if custom == 0: user_name = "TheKickStation" avi_url = "https://pbs.twimg.com/profile_images/1011541359382052866/4Ewy9XIw_400x400.jpg" webhook = Webhook.from_url(webhook_link, adapter=RequestsWebhookAdapter()) embed = Embed(title=info_dic['product'], colour=0x6651a2, url=info_dic['product-link']) footer = user_name embed.set_footer(text=footer, icon_url=avi_url) embed.set_author(name=info_dic['site'], url=info_dic['site']) embed.set_thumbnail(url=info_dic['thumbnail']) embed.add_field(name="Price", value=fields["price"]) embed.add_field(name="Stock", value=fields["stock"]) atc1_value = "" if len(fields["atc1"]) > 0: for i in range(len(fields["atc1"])): atc1_value += "[" + fields["atc1"][i][0] + "](" + fields["atc1"][ i][1] + ") | " + fields["atc1"][i][2] + "\n" else: atc1_value = '\u200b' atc2_value = "" if len(fields["atc2"]) > 0: for i in range(len(fields["atc2"])): atc2_value += "[" + fields["atc2"][i][0] + "](" + fields["atc2"][ i][1] + ") | " + fields["atc2"][i][2] + "\n" else: atc2_value = '\u200b' embed.add_field(name="ATC", value=atc1_value) embed.add_field(name="ATC", value=atc2_value) datetime_list = str(datetime.datetime.now()).split(".") datetime_now = datetime_list[0] embed.add_field(name="Time stamp (utc)", value=datetime_now) user = info_dic[ 'site'] # only support https://youtube.com/ with / at the end user = user[8:] if "www." == user[:4]: user = user[4:] if "/" == user[-1]: user = user[:-1] webhook.send("", embed=embed, username=user, avatar_url=avi_url)
def send_webhook(): url = 'webhook_link' webhook = Webhook.from_url(url, adapter=RequestsWebhookAdapter()) embed = Embed(color=272183,title='FY5158 Checkout Successful | Splashforce',url='https://twitter.com/GaneshBot',)\ .set_thumbnail(url='https://assets.yeezysupply.com/images/w_937,f_auto,q_auto:sensitive,fl_lossy/c3c8886a281e42e786a9ab95010b82fb_ce49/YEEZY_BOOST_350_V2_LINEN_FY5158_FY5158_04_standard.png')\ .add_field(name='PID',value='FY5158',inline=True)\ .add_field(name='Size',value='5',inline=True)\ .add_field(name='Order Number',value='AYS12345678',inline=True)\ .add_field(name='Profile',value='eason',inline=False)\ .set_footer(icon_url='https://media.discordapp.net/attachments/284082692591583252/585559939746103308/emote.png',text='Splashforce•2020/04/18') webhook.send(embed=embed, avatar_url=avatar_url(), username="******")
def __init__(self,webHookId,WebHookToken,DiscordBotToken,ChannelName): self.messageQueue = Queue() self.client = discord.Client() self.on_ready = self.client.event(self.on_ready) self.on_message = self.client.event(self.on_message) self.channelName = ChannelName self.WEBHOOK_ID = webHookId self.WEBHOOK_TOKEN = WebHookToken self.DISCORD_BOT_TOKEN = DiscordBotToken self.__webhook = Webhook.partial(self.WEBHOOK_ID, self.WEBHOOK_TOKEN,adapter=RequestsWebhookAdapter()) self.emojiTranslator = SmilieTranslation()
def success(): webhook = Webhook.from_url(webhook_url, adapter=RequestsWebhookAdapter()) embed = Embed(color=0x00ff00, title="Success") embed.add_field(name="ClassTime", value=classtime) embed.add_field(name="Date", value=date) embed.add_field(name="Duration", value=duration) embed.add_field(name="Subject", value=subject) embed.add_field(name="By", value=by) webhook.send(content=me_mention, embed=embed) sys.exit()
def failed(): webhook = Webhook.from_url(webhook_url, adapter=RequestsWebhookAdapter()) embed = Embed(color=0xff0000, title=title, description=content) embed.add_field(name="ClassTime", value=classtime) embed.add_field(name="Date", value=date) embed.add_field(name="Duration", value=duration) embed.add_field(name="Subject", value=subject) embed.add_field(name="By", value=by) webhook.send(content=content, embed=embed) sys.exit()
async def loop98(): now = datetime.datetime.now().strftime("%H:%M") if now == "23:59": with open('webhook.json') as f: webhook_iroioro = json.load(f) webhook = Webhook.partial(734184972059017236, webhook_iroioro["token_hizuke"], adapter=RequestsWebhookAdapter()) webhook.send("たぶん日付変わる直前", username='******', avatar_url=webhook_iroioro["avater_hizuke"])
def sendDiscordMessage(message): url = "https://discord.com/api/webhooks/831890918796820510/OWR1HucrnJzHdTE-vASdf5EIbPC1axPikD4D5lh0VBn413nARUW4mla3xPjZHWCK9-9P" debug_url = "https://discord.com/api/webhooks/832603152330784819/yA1ZK7ymT3XBU0fJtg0cKZ9RNMPS0C9h0IDABmZZd_KIquToIODOSVOJ6k2aJQSrwC8I" webhook = Webhook.from_url(url, adapter=RequestsWebhookAdapter()) if message is None: log.warning('Error: Discord Message is empty!') elif 'Error' in message: webhook = Webhook.from_url(debug_url, adapter=RequestsWebhookAdapter()) msg = f'```diff\n-{message}\n```' webhook.send(msg) elif 'Failed' in message: msg = f'```diff\n-{message}\n```' webhook.send(msg) elif 'Success' in message: msg = f'```diff\n+{message}\n```' webhook.send(msg) else: webhook = Webhook.from_url(debug_url, adapter=RequestsWebhookAdapter()) webhook.send(message)
def send_discord_message(subject, email_body): """Sends an embedded message to your specific discord channel :param subject: the subject line of an email message :param email_body: the email body of an email message """ dotenv.load_dotenv() webhook_url = os.getenv('DISCORD_WEBHOOK') webhook = Webhook.from_url(webhook_url, adapter=RequestsWebhookAdapter()) embed = Embed(title=subject, description=email_body) webhook.send(embed=embed)
def loadBotUser(): if os.path.exists(BOT_USER_PATH): botUserFile = open(BOT_USER_PATH, 'r') info = botUserFile.read().split(',') webhook = Webhook.from_url(info[0], adapter=RequestsWebhookAdapter()) botUser = BotUser(webhook, info[1], info[2]) botUserFile.close() else: botUser = getNewBotUser() return botUser
async def on_ready(): global guild global emojis global webhook global channel channel = discord_client.get_channel(discord_channel) guild = channel.guild emojis = { ":{}:".format(emoji.name): "<:{}:{}>".format(emoji.name, emoji.id) for emoji in guild.emojis } webhook = Webhook.from_url(webhook_url, adapter=RequestsWebhookAdapter())
def send_webhook(url, avatar_url, name, content, attachments): webhook = Webhook.from_url(url, adapter=RequestsWebhookAdapter()) webhook.send(content, username=name, avatar_url=avatar_url) if len(attachments) > 0: for a in attachments: filename = a.split('/')[-1] r = requests.get(a, stream=True) path = 'files/' + filename with open(path, 'wb') as out_file: shutil.copyfileobj(r.raw, out_file) webhook.send(file=File(path), username=name, avatar_url=avatar_url)
async def announce(self, ctx, channel: discord.TextChannel, message): get_webhook_stuff = get_webhook(guild_id=ctx.guild.id) webhook_token = str(get_webhook_stuff[channel.id]['webhook_token']) webhook_id = get_webhook_stuff[channel.id]['webhook_id'] webhook_name = get_webhook_stuff[channel.id]['webhook_name'] webhook = Webhook.partial(id=webhook_id, token=str(webhook_token), adapter=RequestsWebhookAdapter()) webhook.send(message, username=str(webhook_name))
def black_hole_mail(request): if request.method == "POST": text = request.POST["text"] user_ip = get_user_ip(request) user_sent_count = cache.get(f"mail_user_ip_{user_ip}") if not user_sent_count: cache.set(f"mail_user_ip_{user_ip}", 1, 30) else: user_sent_count += 1 if user_sent_count > 4: return HttpResponse( json.dumps( {"error": "Error: sending mail too frequently."}), content_type="application/json", ) else: cache.set(f"mail_user_ip_{user_ip}", user_sent_count, 30) if len(text) > 2000: return HttpResponse( json.dumps({ "error": "Error: message too long. can only send 2000 characters." }), content_type="application/json", ) try: webhook = Webhook.partial( settings.MAIL_DISCORD_WEBHOOK_ID, settings.MAIL_DISCORD_WEBHOOK_TOKEN, adapter=RequestsWebhookAdapter(), ) em = Embed( color=0x000000, title="Black Hole", description=f"⚫ You've got guyamail! 📬\n\n{text}", timestamp=datetime.utcnow(), ) em.set_footer( text= f"IP hash: {hashlib.md5(user_ip.encode()).hexdigest()[:32]}") webhook.send(content=None, embed=em, username="******") except (AttributeError, NameError): feedback_folder = os.path.join(settings.MEDIA_ROOT, "feedback") os.makedirs(feedback_folder, exist_ok=True) feedback_file = str(int(datetime.utcnow().timestamp())) with open(os.path.join(feedback_folder, f"{feedback_file}.txt"), "w") as f: f.write(text) return HttpResponse( json.dumps( {"success": "Mail successfully crossed the event horizon"}), content_type="application/json", )
async def generate_object(self, channel: TextChannel) -> Optional[Webhook]: if not isinstance(channel, TextChannel): logger.error(f"Channel {channel} is not a TextChannel!") return None webhook = await channel.create_webhook(name=self.name, avatar=self.avatar) if not self._is_async: # necessary to get the correct adapter (not async) return Webhook.partial(webhook.id, webhook.token, adapter=RequestsWebhookAdapter()) return webhook
def bnb(self): webhook = Webhook.from_url(self.webhook, adapter=RequestsWebhookAdapter()) embed = Embed(title='Succesfully checked out a product.') embed.set_author(name=self.author, icon_url=self.avatar)\ .set_thumbnail(url=self.info['bnb']['url'])\ .add_field(name="Product", value=self.info['bnb']['Product'])\ .add_field(name="Style Code", value=self.info['bnb']['StyleCode'])\ .add_field(name="Size", value=self.info['bnb']['Size'])\ .add_field(name="Email", value=self.info['bnb']['Email'])\ .set_footer(text="via Better Nike Bot",icon_url="https://cdn.discordapp.com/icons/522807268811472937/9adeacd23141d2dfce086ea2a225ce98.png?size=128") webhook.send(embed=embed)
def send_webhook(): url = "https://discordapp.com/api/webhooks/699401809206313061/5koJESNpTWnxS2Gu8ZokSGY0Hgd8C8uFDXvTXqsZJFQdfbqvXqDSZqmy1lbfoAB0aUSX" webhook = Webhook.from_url(url, adapter=RequestsWebhookAdapter()) embed = Embed(title="H67799 Checkout Success|Splashforce", url="https://www.google.com/", color=8087790) embed.add_field(name="Pid", value='H67799', inline=True)\ .add_field(name='size', value='6', inline=True)\ .add_field(name='Price', value='169.95', inline=True)\ .add_field(name='Order Track URL', value='https://www.adidas.co.uk/', inline=True)\ .add_field(name='Order Number', value='||AUK22266777||')\ .set_footer(text='Splashforce {}'.format(__time__.timeStamp()), icon_url=icon_url()) webhook.send(embed=embed, username='******', avatar_url=icon_url())
def send(self, channel, post): e = Embed(title=post.title, type='rich', description=post.body, url=post.title_url, timestamp=post.ts) if post.image_url is not None: e.set_image(url=post.image_url) e.set_footer(text=post.footer) e.set_author(name=post.author, url=post.author_url) webhook = Webhook.from_url(self.webhooks[channel], adapter=RequestsWebhookAdapter()) webhook.send(embed=e)
async def replace_message(message, translation): user = message.author # prepare webhook, delete message and send message with the same name & pic as user webhook_info = await get_webhook(client.user, message.channel, await message.guild.webhooks()) webhook = Webhook.partial(webhook_info.id, webhook_info.token, adapter=RequestsWebhookAdapter()) await message.delete() webhook.send(translation, username=user.nick or user.name, avatar_url=user.avatar_url)