async def on_message(message): if (message.author.bot): return if (message.author.id != message.author.bot): if (message.content.startswith("!") == False): db.add_all_messages(all_messages_collection, str(message.author), message.created_at, message.content, message.guild.id, str(message.channel.name)) # Updates keyword list keywords_list = db.get_keywords(keywords_collection, message.guild.id) for key in keywords_list: if key in message.content: keyword_found = key print('Found') # Adds message to the database if it has a keyword db.add_message(message_collection, users_collection, str(message.author), keyword_found, message.content, message.guild.id, str(message.channel.name), message.created_at) await client.process_commands(message)
def loop(): text, message = irc.read() if irc.pong(text): return if message: db.add_message(message)
def message_handler(update, context): user = update.effective_user if user: name = user.first_name else: name = 'anonim' text = update.effective_message.text reply_text = f'hello, {name}\n\n{text}' update.message.reply_text(text=reply_text, reply_markup=get_keyboard()) if text: add_message(user_id=user.id, text=text)
def message_posted(slack_event): try: event = slack_event['event'] channel_id = event['channel'] user_id = event['user'] time_stamp = event['ts'] text = event['text'] msg = Message('', channel_id, time_stamp, user_id, text) db.add_message(msg) except: logging.getLogger(__name__).error('Failed to unpack slack event')
def send_message(user, message, room_id): if len(message) < 1: print('too short') return 'too short' if user[1] == None: print('no user') return 'no user' if room_id == None: print('no room') return 'no room' db.add_message(user[0], message, room_id)
def post_msg(): tijd = str(datetime.now()) inhoud = request.form['content'] db.add_message(tijd, inhoud) s = "<p>Deze content werd gepost:</p><block>" s += request.form['content'] s += "</block>" s += "<p>en dit op <span>" + str(datetime.now()) + "</span></p>" s += "<p>Normaal zou je nu een bericht moeten tonen aan de gebruiker of een redirect doen...</p>" s += "<a href='/'>Voorlopig kan je hier klikken om terug te gaan</a>" return (s)
def handle_api_event(self, event): slack_event = event.event_info event_type = slack_event['event']['type'] if 'subtype' in slack_event['event'] and slack_event['event'][ 'subtype'] == 'message_deleted': event_type = 'message_deleted' if event_type == 'reaction_added': db.add_react(create_react(slack_event)) elif event_type == 'reaction_removed': db.remove_react(create_react(slack_event)) elif event_type == 'message': db.add_message(create_message(slack_event)) elif event_type == 'message_deleted': db.remove_message(create_message(slack_event))
async def echo_message(message: types.Message): if message.text: db.add_message(user_id=message.from_user.id, text=message.text, time=message.date, name=message.chat.first_name) try: movies, length, titles = functions.find(message.text) if length > 0: if length > 5: k = 5 else: k = length for i in range(k): movie = movies.iloc[i] msg = text(bold(movie.title), f'Описание: {movie.description}...', f'Год: {movie.year}', f'Страна: {movie.country}', f'Жанр: {movie.genre}', f'Время: {movie.runtime} минуты', f'Режисер: {movie.film_director}', f'Актеры: {movie.cast}', sep='\n') await bot.send_photo(chat_id=message.from_user.id, photo=movie.img_url, parse_mode=ParseMode.MARKDOWN, caption=msg) if length > 5: if length > 50: length = 50 await bot.send_message(message.from_user.id, bold('Я также нашел по вашему запросу:'), parse_mode=ParseMode.MARKDOWN) for i in range(5, length): await bot.send_message(message.from_user.id, titles.iloc[i]) if length == 0: await bot.send_message( message.from_user.id, 'К сожалению, я ничего не нашел по вашему запросу. Проверьте правильность написания 😌😌😌' ) except: await bot.send_message( message.from_user.id, 'К сожалению, я ничего не нашел по вашему запросу. Проверьте правильность написания 😌😌😌' )
def start(bot, update): # print(update) # print(update.message.chat.id) user_id = update.message.chat.id username = update.message.chat.username update.message.reply_text( "Держи свой чек-лист:\ndrive.google.com/fsjsdfjsjfkjs\n\n" + "Телеграм-канал, где Инна делится инсайтами по финансовой грамотности:\n\n" + "t.me/test_channel12312") flag = False for row in db.get_info(): if row[0] == user_id: flag = True if not flag: db.add_message(int(user_id), username)
def message(): msgtype = request.values.get('type') frm_nick = request.values.get('nick') to = request.values.get('to') to_nick = request.values.get('to_nick') body = request.values.get('body') timestamp = request.values.get('timestamp') callback = request.values.get('callback', None) style = '' print 'message.timestamp:', type(timestamp), timestamp visitor_id, user_id = (g.uid, to) if g.is_guest else (to, g.uid) db.add_message(msgtype, visitor_id, user_id, g.uid, frm_nick, to, to_nick, body, style, timestamp) ret = g.client.message(to, body, style, timestamp, msgtype=msgtype) if callback is not None: ret = '%s(%s);' % (callback, ret) return ret
def message(): msgtype = request.values.get('type') frm_nick = request.values.get('nick') to = request.values.get('to') to_nick = request.values.get('to_nick') body = request.values.get('body') timestamp = request.values.get('timestamp') callback = request.values.get('callback', None) style = '' print 'message.timestamp:', type(timestamp), timestamp visitor_id, user_id = (g.uid, to) if g.is_guest else (to, g.uid) db.add_message(msgtype, visitor_id, user_id, g.uid, frm_nick, to, to_nick, body, style, timestamp) ret = g.client.message(to, body, style, timestamp, msgtype=msgtype) if callback is not None: ret = '%s(%s);' % (callback, ret) return ret
def message_handler(update: Update, context: CallbackContext): user = update.effective_user if user: name = user.first_name else: name = 'аноним' text = update.effective_message.text reply_text = f'Привет, {name}!\n\n{text}' # Ответить пользователю update.message.reply_text( text=reply_text, reply_markup=get_keyboard(), ) # Записать сообщение в БД if text: add_message( user_id=user.id, text=text, )
async def on_message(message): global last_general_message if message.channel.id == 738937428378779659: # skyblock-updates await message.publish() if message.channel.id == 719579620931797002: # general last_general_message = time.time() if message.channel.id == 718114140119629847: # suggestions await process_suggestion(message) if message.channel.id == 763088127287361586: # spam if message.content and message.content[ 0] != '!' and not message.author.bot: uwuized_message = message.content\ .replace('@', '')\ .replace('r', 'w')\ .replace('l', 'w')\ .replace('R', 'W')\ .replace('L', 'W')\ .replace('<!642466378254647296>', '<@642466378254647296>') await message.channel.send(uwuized_message) asyncio.ensure_future(db.add_message(message.author.id)) await process_counting_channel(message) await betterbot.process_commands(message) await modbot.process_messsage(message)