add timestamp functionality (#44)

closes #43
pull/49/head
Mal Hancock 2019-01-25 13:13:48 -08:00 committed by GitHub
parent 4fdb5d19e6
commit 479d009346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -74,13 +74,16 @@ def test_plugin(msg):
The function will need to accept a single argument in order to accept a `Message` object from the bot.
The `Message` object has the following attributes:
* `cmd`: the command that triggered the function
* `cmd`: (for command plugins) the command that triggered the function
* `nick`: the user who triggered the command
* `arg`: all the trailing text after the command. This is what you will use to get optional information for the command
* `arg`: (for command plugins) all the trailing text after the command. This is what you will use to get optional information for the command
* `text`: (for listener plugins) the entire text of the message
* `channel`: the channel where the command was initiated
* `ops`: the list of bot operators
* `botnick`: the nickname of the bot
* `logger`: instance of `Bot`'s logger
* `datetime`: aware `datetime.datetime` object when the `Message` object was created
* `timestamp`: float for the unix timestamp when the `Message` object was created
It also contains the following IRC functions:
* `privmsg`: send a message to an arbitrary channel or user

View File

@ -1,3 +1,4 @@
from datetime import datetime, timezone
import imp
import logging
import os
@ -28,6 +29,8 @@ class Bot(irc.bot.SingleServerIRCBot):
class Message:
def __init__(self, channel, nick, botnick, ops, logger, action, privmsg, notice, cmd=None, arg=None, text=None, nick_list=None):
self.datetime = datetime.now(timezone.utc)
self.timestamp = self.datetime.timestamp()
self.channel = channel
self.nick = nick
self.nick_list = nick_list