def safe(bot, update, remove=False):
    if update.message.from_user.id in config.admin_id or bot.get_chat_member(
            update.message.chat_id, update.message.from_user.id).status in [
                "creator", "administrator"
            ]:
        if remove == False:
            word = update.message.text[6:]
        else:
            word = update.message.text[8:]
        if word.startswith("@"):
            if antispam.is_spam(word, False, False, True):
                word = word[1:]
                if " " in word:
                    bot.send_message(update.message.chat_id,
                                     strings.INVALID_SAFENAME,
                                     parse_mode=ParseMode.HTML)
                else:
                    db = MySQLdb.connect(config.database['server'],
                                         config.database['user'],
                                         config.database['password'],
                                         config.database['name'])
                    db.autocommit(True)
                    cur = db.cursor()
                    if remove == False:
                        cur.execute(
                            "INSERT IGNORE INTO SafeNames (Name, Chat_ID) VALUES ('"
                            + str(word) + "', '" +
                            str(update.message.chat_id) + "')")
                        u = bot.send_message(update.message.chat_id,
                                             (strings.SAFE_NAME_SAVED %
                                              (html.escape(str("@" + word)))),
                                             parse_mode=ParseMode.HTML)
                        util.log_operation('!addsafename:' + str(word),
                                           update.message.chat_id,
                                           update.message.from_user.id)
                    else:
                        cur.execute("DELETE FROM SafeNames WHERE Name = '" +
                                    str(word) + "' AND Chat_ID = '" +
                                    str(update.message.chat_id) + "'")
                        u = bot.send_message(update.message.chat_id,
                                             (strings.SAFE_NAME_REMOVED %
                                              (html.escape(str("@" + word)))),
                                             parse_mode=ParseMode.HTML)
                        util.log_operation('!removesafename:' + str(word),
                                           update.message.chat_id,
                                           update.message.from_user.id)
                    bot.delete_message(update.message.chat_id,
                                       update.message.message_id)
                    time.sleep(5)
                    bot.delete_message(update.message.chat_id, u.message_id)
                    cur.close()
                    db.close()
            else:
                bot.send_message(update.message.chat_id,
                                 strings.INVALID_SAFENAME,
                                 parse_mode=ParseMode.HTML)
        else:
            bot.send_message(update.message.chat_id,
                             strings.INVALID_SAFENAME,
                             parse_mode=ParseMode.HTML)
示例#2
0
文件: app.py 项目: yesrab/userbot
async def spam_tracker(event):
    global SPAM
    if SPAM == True:
        ch = str(event.raw_text)
        spamscore = antispam.score(ch)
        spambool = antispam.is_spam(ch)
        if spambool == True:
            await event.reply('Spam Message Detected')
            await event.reply('Spam results for `' + ch + '`\nScore: ' +
                              spamscore + '\nIs Spam: ' + spambool)
示例#3
0
文件: index.py 项目: xencodes/user
async def my_e_handler(e):
	if '.xen ping' == e.raw_text:
		start=round(time.time() * 1000)
		pongmsg=await e.reply('Pong!')
		end=round(time.time() * 1000)
		msstartend=int(end) - int(start)
		await client(EditMessageRequest(peer=e.chat_id, id=pongmsg.id, message='Pong!\n' + str(msstartend) + 'ms'))
	elif '.msgid' == e.raw_text:
		await e.reply('There are ' + str(e.id + 1) + ' messages (including this one) in this chat')
	elif '.random' == e.raw_text:
		rannum = randint(0, 69420)
		await e.reply(str(rannum))
	elif '.antispam' in e.raw_text:
		checkspam=str(e.raw_text[11:])
		spamscore=str(antispam.score(checkspam))
		spambool=str(antispam.is_spam(checkspam))
		await e.reply('Spam results for `' + checkspam + '`\nScore: ' + spamscore + '\nIs Spam: ' + spambool)
示例#4
0
 def is_spam(self, text):
     return {
         'score': antisp.score(text),
         'is_spam': int(antisp.is_spam(text))
     }
示例#5
0
import streamlit as st
import antispam

query = st.text_input("Enter a sentence to test for spam: ")
train = st.button("Test")
if train:
    answer = antispam.is_spam(query)
    if answer == True:
        st.write("Spam")
    elif answer == False:
        st.write("Not Spam")