Get message and use it Telegram bot (pyTelegramBotAPI) - telegram-bot

I am making a Telegram bot. I want write code that:
user send command - /color
bot ask ‘Red: ‘
user send text
How can I get that message without ‘/’ ?
#bot.message_handler(commands=['color'])
def info_produkts(message):
bot.send_message(message.chat.id, "Red: ")
text = Update.message.replay_text()
But it's not working...
I am working in visual studio code.

use regexp= keyboard like that
`#bot.message_handler(regexp='color')

Related

Telegram bot unban command

This is my code to unban a user by replying to a message previously left by the user in the bot. But I also want to implement the /unban id command to be able to unban a user by their id. But I don't know how to do it. Please, help.
#bot.message_handler(commands=["unban"], func=Filters.is_answer)
def unblock(message):
user_id = (
Message.select()
.where(Message.id == message.reply_to_message.message_id)
.get()
.from_
)
try:
Block.select().where(Block.user_id == user_id).get().delete_instance()
bot.send_message(user_id, "you have been unbanned"),
except Block.DoesNotExist:
pass
bot.send_message(
message.chat.id, ("{user_id} has been unbanned").format(user_id=user_id)
)
I thought to just read the entire contents of the /unban command through message.text, but I didn’t see any errors, but the command stopped working

I have a problem with InlineKeyboardButton in python telegram API

This is what my bot will do:
If someone sends a command like \sendFriendReq to my bot, then my bot will send a message with their details and an Inline Button with with "yes" and "no".
The problem I'm facing: How can i know who send those messages other than formatting the text with their details, is there a way to send their chat id along with the inline button so i can use that chat id to send a reply to my bot users
Disclaimer: This is not the actual problem but the solution to this problem could solve my problem so alternate solution to send friend req won't help me
This would give you pretty much every detail about the incomming message:
userid = update.message.from_user.id
firstname = update.message.from_user.first_name
lastname = update.message.from_user.last_name
fullname = update.message.from_user.full_name
username = update.message.from_user.name
message = update.message.text
chatid = update.message.chat_id

Unable to read the Content of Email Automation Anywhere

I am reading the incoming mails from a outlook mailbox using automation anywhere Email Automation - Get All Messages menu. My simple code is given below. But everytime I am getting html objects and tags printing in the message box, I want only the email message.
Start Loop "Each message on server:outlook.office.365.com,User Name:xyz#xyz.com,SSL Server Type:POP3,Message Format:Plain Text"
Message Box:"$Email Message$"
Can anyone help????
In your original Email Automation - Get All Messages command, there should be a "Message Format" option below port number.
If not - you could offload to a javascript script that might look like this and call it via Run Script:
function noTags(vString) {
return vString.replace(/<(.|\n)*?>/g, '');
}
Passing vString into it and getting vString back out, now without the tags.

Slack API - How to remove message formating when sending data out of slack

I'm building a slack bot. You feed my bot several info, including an email address, and it sends the data through an outgoing webhook.
The problem is that if I give my bot the required info, the http request returns this (exemple) :
{"name":"Alexandre","email":"<mailto:test#gmail.com|test#gmail.com>","test":"hello world"}
This sucks, because the server catching the hook (zapier) cannot interpret the mailto: with the brackets. This message formatting is something slack does automatically. Any ideas on how I can remove message formatting for URLs and emails ?
Thanks !
I would suggest passing the argument parse as none, according to https://api.slack.com/docs/formatting.
I don't know if you've fixed this issue. I just encountered the same problem. I built my slackbot using Python and I created a method to get rid of the "mailto". This might not be the answer that you are looking for, but hopefully it gives some insight:
def unformat_message(param):
while param.count('mailto') >= 1:
mailto_position_at_param = param.find("<mailto")
end_of_mailto_position_at_param = param.find("com>")
taken_email_position = param.find("com|")
if mailto_position_at_param != -1 and end_of_mailto_position_at_param != -1 and taken_email_position != -1:
old_string = param[mailto_index:end_mailto_index+4]
new_string = param[mailto_index+8:email_index+3]
param = param.replace(old_string,new_string)
return param

How to check email using a vb.net application

I am looking for a vb.net code for receiving e-mails without using any 3rd party libraries. I want to check Unread messages, Inbox and Sent messages. A Working sample is appreciated.
What is the default port for SMTP , is it port 25 (is it the same for all SMTP mail servers?). Which is more flexible in my case POP3 or IMAP ?
Edit:
Someone please give me a sample working code for receiving mail using lumisoft (pop) in vb.net
From lumisoft Help.
/*
To make this code to work, you need to import following namespaces:
using LumiSoft.Net.Mime;
using LumiSoft.Net.POP3.Client;
*/
using(POP3_Client c = new POP3_Client()){
c.Connect("ivx",WellKnownPorts.POP3);
c.Authenticate("test","test",true);
// Get first message if there is any
if(c.Messages.Count > 0){
// Do your suff
// Parse message
Mime m = Mime.Parse(c.Messages[0].MessageToByte());
string from = m.MainEntity.From;
string subject = m.MainEntity.Subject;
// ...
}
}
Pop is more supported and most servers have it on if you want to implement your own pop service a good place to start is the rfc.