예제 #1
0
for comment in r.subreddit(sub).comments(limit=25):
    if (comment.id not in already_done and str(comment.author) != "artcbot"):
        # marking comment as read if it's a reply
        # this ensures that the PM part does not respond as well
        comment.mark_read()
        already_done.append(comment.id)
        # Making sure the already_done file doesn't get too big.
        del already_done[0]
        artcbot.write_out("already_done", already_done)

        # Saving comment
        comment_list = str(comment.body)
        comment_list = comment_list.split()

        # passing off to get reply
        reply = artcbot.call_bot(comment_list, comment.author, contributors)

        # Responding if needed
        if (len(reply) > 1):
            reply += "\n\n---\n\n^^To ^^cut ^^down ^^on ^^spam ^^you ^^can ^^private ^^message ^^me ^^commands."
            comment.reply(reply)

# sorting through unread messages
for pm in r.inbox.unread(limit=25):
    pm.mark_read()
    # only responding to pm's, not comment replies
    if (not pm.was_comment):
        body = str(pm.body)
        body = body.split()

        reply = artcbot.call_bot(body, pm.author, contributors)
예제 #2
0
            #it is wednesday, my dudes
            if (channel == "C78G97C9F" and now.weekday() == 2):  #dumbmemes
                #if(channel == "C50T5QMQ8"): #BARTC
                user = getUser(events)
                sc.api_call("reactions.add",
                            token=slack_token,
                            name='wednesday',
                            channel=channel,
                            timestamp=events['ts'])
            message = events["text"].split(' ')
            command = list(set(message).intersection(command_list))
            function = list(set(message).intersection(built_in))
            if (len(command) > 0 or len(function) > 0):
                user = getUser(events)
                #sending user id(s) as contributor(s)
                message = artcbot.call_bot(message, user, ['U4Z02CNN6'])
                if (len(message) > 1): sendMessage(user, channel, message)
    time.sleep(1)


###########################
#not used (possibly broken)
def parseDistance(orig):
    dist = 0
    unit = 'na'

    if (type(orig) == str):
        ary = orig.split()
    else:
        ary = orig
예제 #3
0
    return event['user']

#getting slack text events and responding
sc.rtm_connect()
while True:
    new_events = sc.rtm_read()
    for events in new_events:
        if(events["type"] == "message"):
            message = events["text"].split(' ')
            command = list(set(message).intersection(command_list))
            function = list(set(message).intersection(built_in))
            if(len(command) > 0 or len(function) > 0):
                channel = getChannel(events)
                user = getUser(events)
                #sending contributors as an empty list, no editing of commands on slack
                message = artcbot.call_bot(message, user, ['herumph'])
                if(len(message) > 1): sendMessage(user, channel, message)
    time.sleep(1)

###########################
#not used (possibly broken)
def parseDistance(orig):
    dist = 0
    unit = 'na'

    if (type(orig) == str):
        ary = orig.split()
    else:
        ary = orig

    if (len(ary) == 1):
예제 #4
0
    reply = ""
    if (comment.id not in already_done and str(comment.author) != "artcbot"):
        #marking comment as read if it's a reply
        #this ensures that the PM part does not respond as well
        comment.mark_read()
        already_done.append(comment.id)
        #Making sure the already_done file doesn't get too big.
        del already_done[0]
        artcbot.write_out("already_done", already_done)

        #Saving comment
        comment_list = str(comment.body)
        comment_list = comment_list.split(' ')

        #passing off to get reply
        reply = artcbot.call_bot(comment_list, comment.author, contributors)

        #Responding if needed
        if (len(reply) > 1):
            reply += "\n\n---\n\n^^To ^^cut ^^down ^^on ^^spam ^^you ^^can ^^private ^^message ^^me ^^commands."
            comment.reply(reply)

#sorting through unread messages
for pm in r.inbox.unread(limit=25):
    pm.mark_read()
    #only responding to pm's, not comment replies
    if (not pm.was_comment):
        body = str(pm.body)
        body = body.split(' ')

        reply = artcbot.call_bot(body, pm.author, contributors)
예제 #5
0
    def test_callbot(self):
        reply = artcbot.call_bot(["!pacing", "20:09", "5", "km"], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 kilometer(s) in 20:09 you need to run each kilometer in 4:01, or each mile in 6:30."
        )

        reply = artcbot.call_bot(["!pacing", "20:09", "5km", ""], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 kilometer(s) in 20:09 you need to run each kilometer in 4:01, or each mile in 6:30."
        )

        reply = artcbot.call_bot(["!pacing", "20:09", "5km", "km"], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 kilometer(s) in 20:09 you need to run each kilometer in 4:01, or each mile in 6:30."
        )

        reply = artcbot.call_bot(["!pacing", "20:09", "5km"], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 kilometer(s) in 20:09 you need to run each kilometer in 4:01, or each mile in 6:30."
        )

        reply = artcbot.call_bot(["!pacing", "20:09", "5kilometers"], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 kilometer(s) in 20:09 you need to run each kilometer in 4:01, or each mile in 6:30."
        )

        #I'm funny
        reply = artcbot.call_bot(["!pacing", "20:09", "5kilograms"], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 kilometer(s) in 20:09 you need to run each kilometer in 4:01, or each mile in 6:30."
        )

        reply = artcbot.call_bot(["!pacing", "50:00", "5miles"], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 mile(s) in 50:00 you need to run each mile in 10:00, or each kilometer in 6:15."
        )

        reply = artcbot.call_bot(["!pacing", "50:00", "5.0miles"], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 mile(s) in 50:00 you need to run each mile in 10:00, or each kilometer in 6:15."
        )

        reply = artcbot.call_bot(["!pacing", "50:00", "5.0 miles"], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 mile(s) in 50:00 you need to run each mile in 10:00, or each kilometer in 6:15."
        )

        reply = artcbot.call_bot(["!pacing", "50:00", "5 miles"], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 mile(s) in 50:00 you need to run each mile in 10:00, or each kilometer in 6:15."
        )

        reply = artcbot.call_bot(["!pacing", "50:00", "5 m"], "", "")
        self.assertEqual(
            reply,
            "\n\nTo run 5.0 mile(s) in 50:00 you need to run each mile in 10:00, or each kilometer in 6:15."
        )