Create a channel on a discord server with webhook - api

I am using the discord webhook api to send messages to my discord servers channels. In a new use case I want to create a new channel with a webhook. Unfortunately I could not find any API to do so. I read through the whole documentation here: https://discordapp.com/developers/docs/resources/webhook#create-webhook
Is this even possible to do? I saw methods for a discord bot that allowed it - therefore I kinda think it should be possible with a webhook, too.

I think the Discord webhooks are only for sending messages and nothing more and you'll probably have to use a bot to create the channel if you don't want to do it manually.
Creating a webhook via discord.py API is only supported on the rewrite branch I think
Installing discord.py-rewrite
pip install git+https://github.com/Rapptz/discord.py#rewrite
import discord
from discord.ext.commands import Bot
bot=Bot(command_prefix='.')
#bot.event
async def on_ready():
print(bot.user.name)
#bot.command()
async def chan(msg):
chan=await msg.guild.create_text_channel(name='New text')
web=await chan.create_webhook(name='New web')
print(web.url)
bot.run("YOUr bot token here")
you can find the documentation here and you can create your bot here

Related

Can you add a Nagios Acknowledgment URL to Slack messages

I'm new to nagios and my first task has been slack integration. I am using the Nagios created plugin for Slack and everything is working correctly as far as posting the message in the channels for both hosts and services. I want to add an acknowledgment URL to the message that gets sent to slack, so our team can just acknowledge through the slack message. I have tried adding the URL in various places, like the host/service definitions so I could then call it in the command Slack_notification_handlers. Is it possible to add said acknowledgement urls with the current methods I'm using? or is this something I'm going to have to make myself?

How to get messages from a private channel using Telethon

I used to get the posts from a public telegram channel using telethon and everything works fine until today that the channel became private and although I am a subscriber to the channel I can not retrieve the channel messages with the message-id like before and I get an error that the channel is private and you can not access the messages. I should mention that I am a subscriber to the channel.
I try different things and find out that telethon sign in as a bot and for that reason, the channel does not give it permission to read the channel messages. one other thing that I find out is that to make this work like before any bot should be added to the channel as an administrator to let telethon read messages like before.
does anyone know any way to retrieve messages from a private channel that we are subscribed to without adding bot as an administrator to the channel?
client = TelegramClient('session', api_id, api_hash, proxy=("socks5", 'server', port))
# connecting and building the session
client.connect()
# in case of script ran first time it will
# ask either to input token or otp sent to
# number or sent or your telegram id
if not client.is_user_authorized():
client.send_code_request(phone)
# signing in the client
client.sign_in(phone, input('Enter the code: '))
this is the way I use to sign in to my account but it signs in as a bot this way, is there any workaround not to sign in as a bot?

SAP Cloud SDK JS receives empty data from Enterprise Messaging Queue

I have build a simple cloud-SDK based application for adding as a Webhook in Enterprise messaging queue to receive the events as soon as it gets inside the queue.
I have an OPTIONS and POST function. OPTIONS is for the handshake with the queue and it works.
Now, when there is message in the Queue, it hits my application with the POST block but the request body is coming as empty object.
I have tried the same from the postman, i'm able to receive the data in request body. Only from the Enterprise messaging queue, the data is empty.
In contrast, to verify this, I have used a Express based nodejs application, there i'm able to receive the data from the queue.
What am i missing in the Cloud-SDK based code ?
POST block, looks like this
#Post('ems-events')
receiveEmsEvents(#Body() requestBody: string, #Req() req:Request) {
Logger.log("Event Received with Data:");
Logger.log(requestBody);
Logger.log(req.body);
Logger.log("Log over--");
Logger.log(Object.keys(req));
return {};
}
The SAP Cloud SDK for JavaScript does not offer any support for Enterprise Messaging as of today. The code you're writing here is most likely Nest.js code, which is an independent framework.
That being said, Nest.js does run Express.js under the hood by default. So if you've been able to make it work in Express, you should be able to make it work in Nest.

How to receive webhook signal from 3rd party service

I'm using a SaaS for my AWS instance monitoring and Mandrill for email sending/campaigns.
I had created a simple chart with Zapier but I'd rather like to host it myself. So my question is:
How can I receive a webhook signal from Mandrill and then send it to Datadog from my server? Then again I guess hosting this script right on the same server I'm monitoring would be a terrible idea...
Basically I don't know how to "receive the webhook" so I can report it back to my Datadog service agent so it gets updated on their website.
I get how to actually report the data to Datadog as explained here http://docs.datadoghq.com/api/ but I just don't have a clue how to host a listener for web hooks?
Programming language isn't important, I don't have a preference for that case.
Here you can find how to add a new webhook to your mandrill account: https://mandrillapp.com/api/docs/webhooks.php.html#method=add
tha main thing here is this:
$url = 'http://example/webhook-url';
this is your webhook URL what will process the data sent by mandrill and forward the information to Datadog.
and this is a description about what mandrill will send to your webhook URL: http://help.mandrill.com/entries/21738186-Introduction-to-Webhooks
a listener for webhooks is nothing else then a website/app which triggers an action if a request comes in. Usually you keep it secret or secure it with (http basic) authentication. E.g. create a website called http://yourdomain.com/hooklistener.php. You can then call it with HTTP POST or GET and pass some data like hooklistener.php?event=triggerDataDog or with POST and send data along with the body. You then run a script or anything you want to process that event.
A "listener" is just any URL that you host where you can receive data that is posted to it. Keep in mind, since you mentioned Zapier, you can set up a trigger that receives the webhook data - in this case the listener URL is provided by Zapier, and you can then send that data into any application (or even post to another webhook). Using Zapier is nice because it doesn't require you to write the listener code that receives the hook data and does something with it.

ejabberd auto allow subscription

I have installed and run ejabberd successfully. I've tested the chat function and it works well.
I have a problem with the 'Add Buddy' process. When I add a buddy, the buddy has to manually approve the request. I would like to skip this step and have all buddy requests to be approved automatically.
I'm getting a presence type of 'subscribe' for authorization requests. How can I authorize a buddy programmatically? I'm using objective c.
Ok I found the answer to my question.
Basically, just follow the protocol on http://xmpp.org/rfcs/rfc3921.html#sub and programmatically send a subscribe request.