Ejemplo n.º 1
0
def test_greet1():
    # Set Up
    name = 'Ron'

    # Execute
    greeting = greet(name)

    # Validate
    assert (greeting == 'Hello, Ron!')
Ejemplo n.º 2
0
async def on_message(message):
    await client.change_presence(game=discord.Game(name='with Mommy.'))
    mess = message.content.lower()
    chan = message.channel
    auth = str(message.author)
    server = message.server

    storeModules = [storingQuotes.storeLastQuote, storingQuotes.storeQuote]

    retrieveModules = [
        retrievingQuotes.getLastQuote, retrievingQuotes.getQuoteAtLine,
        retrievingQuotes.getRandomQuote
    ]

    if message.author == client.user:
        return

    else:
        response = greetings.greet(mess)
        if response != None and response != "":
            await client.send_typing(chan)
            await client.send_message(chan, response)

        response = greetings.gbye(mess)
        if response != None and response != "":
            await client.send_typing(chan)
            await client.send_message(chan, response)

        storingQuotes.tempStoreLastQuote(mess, auth)

        for function in storeModules:
            response = function(mess, chan, server, auth)
            if response != None and response != "":
                await client.send_typing(chan)
                await client.send_message(chan, response)
            break

        for function in retrieveModules:
            response = function(mess, server)
            if response != None and response != "":
                await client.send_typing(chan)
                await client.send_message(chan, response)
            break
Ejemplo n.º 3
0
Archivo: nda.py Proyecto: proog/nda
    def main_loop_iteration(self):
        # check for external input
        self.redis_input()

        # perform various passive operations if the interval is up
        if (datetime.utcnow() -
                self.last_passive).total_seconds() < self.passive_interval:
            return

        # check if any nicks with unread messages have come online (disabled for now)
        # unread_receivers = self.database.mail_unread_receivers()
        # if len(unread_receivers) > 0:
        #     self._ison(unread_receivers)

        # check if it's time to talk
        if self.idle_talk:
            for channel in self.channels:
                if channel.idle_timer.can_talk():
                    seq_id = 0
                    quote = self.database.random_quote(channel=channel.name,
                                                       stringify=False)
                    if quote is not None:
                        message, author, date, seq_id = quote
                        self.send_message(channel.name, message)
                    channel.add_history(
                        'idle talk', 'seq_id=%i, i=%i, d=%i' %
                        (seq_id, channel.idle_timer.interval,
                         channel.idle_timer.delay))
                    channel.idle_timer.message_sent(
                    )  # notify idle timer that we sent something, even with no quote

        # check if it's time for a festive greeting
        for channel_name, greeting in greetings.greet():
            channel = self.get_channel(channel_name)
            if channel is not None:
                self.send_message(channel_name, greeting)
                channel.add_history('greeting', greeting)

        self.last_passive = datetime.utcnow()
Ejemplo n.º 4
0
Archivo: nda.py Proyecto: proog/nda
    def main_loop_iteration(self):
        # check for external input
        self.redis_input()

        # perform various passive operations if the interval is up
        if (datetime.utcnow() - self.last_passive).total_seconds() < self.passive_interval:
            return

        # check if any nicks with unread messages have come online (disabled for now)
        # unread_receivers = self.database.mail_unread_receivers()
        # if len(unread_receivers) > 0:
        #     self._ison(unread_receivers)

        # check if it's time to talk
        if self.idle_talk:
            for channel in self.channels:
                if channel.idle_timer.can_talk():
                    seq_id = 0
                    quote = self.database.random_quote(channel=channel.name, stringify=False)
                    if quote is not None:
                        message, author, date, seq_id = quote
                        self.send_message(channel.name, message)
                    channel.add_history(
                        "idle talk",
                        "seq_id=%i, i=%i, d=%i" % (seq_id, channel.idle_timer.interval, channel.idle_timer.delay),
                    )
                    channel.idle_timer.message_sent()  # notify idle timer that we sent something, even with no quote

        # check if it's time for a festive greeting
        for channel_name, greeting in greetings.greet():
            channel = self.get_channel(channel_name)
            if channel is not None:
                self.send_message(channel_name, greeting)
                channel.add_history("greeting", greeting)

        self.last_passive = datetime.utcnow()
Ejemplo n.º 5
0
from greetings import greet
greet()
Ejemplo n.º 6
0
import datetime
import greetings as gr
# import recogniseSpeech as rs
import event_handler as event

if __name__ == '__main__':
    gr.greet()
    cTime=datetime.datetime.now().minute
    while 1:
        # query = rs.takeCommand().lower()
        query = str(input('Command : ')).lower()
        print(datetime.datetime.now().minute)

        # if datetime.datetime.now().minute < cTime+1 or ('hey' in query):
        if True:
            cTime = datetime.datetime.now().minute
            event.handle_event(query)
        else:
            print('Something is not right')
Ejemplo n.º 7
0
import hy
import greetings

greetings.greet("Foo")
Ejemplo n.º 8
0
 def test_greet3(self):
     self.assertNotEqual(greet('Charles'), 'Hello, Charlie!')
Ejemplo n.º 9
0
 def test_greet2(self):
     self.assertEqual(greet('Ron'), 'Hello, Ron!')
Ejemplo n.º 10
0
import greetings
greetings.greet("Bill")
Ejemplo n.º 11
0
def test_greet_the_world():
    assert greet("world") == "Hello, world!"