I want to create a Bot that automatically keeps posting in a Telegram channel.I am using Node.js.
I am using Telegraf.js wrapper for Telegram API. You may even suggest any other suitable wrapper for this task.
If your Channel is public. You need set admin in you channel.
Use: ctx.telegram.sendMessage(Channels_Username, 'your message')
Example:
ctx.telegram.sendMessage('#birodarlar', 'Hi everyone')
If your Channel is Private You need set admin in you channel.Use: ctx.telegram.sendMessage(Channels_id, 'your message')
Example:
ctx.telegram.sendMessage('-145542325454', 'Hi everyone')
you can wiev your channels id with this link
https://core.telegram.org/bots/api#sendmessage
for 5 minutes you need public it and know channel id with url parsing
Telegraph documentation is very comprehensive and you can find it at https://telegraf.js.org. I'm sure it will answer most of your questions.
If you want your bot to keep posting messages in a channel, simply execute this line of code in a loop:
ctx.telegram.sendMessage(CHANNEL_ID, 'your message')
Don't forget to replace CHANNEL_ID and 'your message' with your own values.
Related
So, when I was making my bot project, I wanted to add a feature in which sends a message after being invited to a server, as a way of thanking the owner for the invitation, however, I cannot seem to find a way to get this since most of the solutions are outdated, due to the version of the library. Any suggestions?
*User Invites the bot*
Bot: "Thanks for inviting me blah blah blah"
You can use the guildCreate event, that gets triggered every time the bot joins a server, example:
client.on('guildCreate', guild => {
let channel = guild.channels.cache.first();
if(channel) channel.send('Hey!');
}
In this example we get a random channel from the guild and send a message in it, you might also check if the bot has the permission to send messages.
I have seen a few bots that have made a bot user
one bot called BetterCensoring did that
It looked like this
does anyone know how to make that?
I have tried to search for an answer a lot but I couldn't find any answers.
Stuff like this is not achieved by actually creating a new user account but rather using a webhook. The send method has the ability to customize username and profile picture of the message.
Webhooks are most easily created with await channel.create_webhook()
Note that a guild can only have 10 webhooks at a time, which is why most bots that use this functionality create a webhook, send a message with it and then delete it right afterwards.
Example (recreating your creeper censoring):
async def on_message(message):
if message.content.startswith('bad word'):
webhook = await message.channel.create_webhook()
await webhook.send('####', username='Creeper', avatar_url='this is an url leading to the creeper image')
await webhook.delete()
I have some disсord servers and I need the bot to create a log channel into which my bot is able to write the data I will indicate in the code.
If you search on discord.py docs you would find this from guild's object.
await create_text_channel(name, *, overwrites=None, category=None, reason=None, **options)
Example:
guild = client.get_guild(ID)
await guild.create_text_channel('logs')
If you want the bot for everyone to use, you would need a database to save channels' id.
About the type of logs that you want to send to each guild it really depends. If it is only logs that you write by your own then just loop all channel's id that you saved and send each one a message.
If it is some discord logs given by discord API then you would have to search in discord.py docs for more info.
I want my bot(coded in discord.js) to show how many voice channels my discord bot is in, and I have no idea how to do that.
Can I get some help? I would offer My bot's premium silver edition to those who helped just dm A350-1000#6715 on discord for redeem code.
After reading the discord.js docs, I found under the class Client a .channels property that returns a ChannelManager which helps handle every channel the client is handling. In the ChannelManager class, there is a property .cache that returns a collection of channels, so I suppose you can loop through the collection and count every channel that is a voice channel, every Channel object has a property .type which returns a string.
Discord.js docs: https://discord.js.org/#/docs/main/master/class/Client
You can use .voiceConnections.
Like this:
client.on('message', message => {
console.log(client.voiceConnections.size)
});
I'm creating a bot in slack using Microsoft's botframework and LUIS and in Node.js. Currently my bot will reply every time someone says something in the channel, however I want my bot to only reply when its name is mentioned in my slack channel. i.e. #my-bot do this
How would I approach this? Would I have to add slack api in order to do this?
One way I'm thinking is to create an entity to check for if #my-bot is mentioned, and if it is then reply and if not then don't. However, I feel there are better ways in doing this.
Thanks.
Edit:
dialog.onDefault(function (session) {
var msg = new builder.Message(session).entities();
console.log(msg);
console.log(session);
session.endDialog('Default Dialog');
});
I've looked through both msg and session and the Entities of both are empty.
I was able to use session.message.entities to use mentioned to know whenever the bot was mentioned.