List of commits:
Subject Hash Author Date (UTC)
Bot now prints in a log file if given at initialization e13bd3dbb86d1bb6f072f751412e89d444d870f3 Detche 2016-11-29 15:38:18
Updated example. e95d1599676ae10b950b2c069e666060005627cf Detche 2016-11-13 19:52:41
Added scheduler to task core. Modified comm for new event. ed51d5d18684dabdb17675294727ad5e8b8af454 Detche 2016-11-13 19:44:05
Started adding possibility to save in database. cf28a7731335cd1ffd2ebd03cc2e890c25e1c64b Detche 2016-11-13 19:43:21
Changed db interface and users/groups models. d0fdf8873a107c44d6acbef5cbffc869461d9aab Detche 2016-11-03 15:22:10
Changed UserId from element to attribute. 5407592cba9e7488519e069927a8ffb9ed32fdf6 Detche 2016-11-02 15:02:30
Added tasks system. 13bbf9857a0a61d5e2b0fd9483f5efd235cbd4f2 Detche 2016-11-02 14:58:20
Modified Knowledge process. Fixed indent 28e52095a297cbb0e6b9b6d799bb80ebe52828c1 Detche 2016-10-23 12:11:30
Updated README 8e298151286ec3cb4df29633aaca90fc871f2e80 Detche 2016-10-23 10:10:45
Update README.rst 7965df28cbef557fd3819919b4d44f0733dcecf0 Guillaume 2016-10-23 00:06:05
Added README page 8339ac5b13803b026dbfc5edd77fa50a24a70ecb Detche 2016-10-22 23:47:05
Added comments to sources. ce6491ef1337ea34d33b7e4ede0eb9f634e7ab1a Detche 2016-10-22 23:32:26
Added examples. Modified reaction class to add triggers. 545a35d1c5bb36e1b4e4d818b0e6a8f6642a222f Detche 2016-10-22 20:56:54
Initial commit 2cd79df6224290a994b1453f0327740816b0f632 Detche 2016-10-21 16:21:02
Commit e13bd3dbb86d1bb6f072f751412e89d444d870f3 - Bot now prints in a log file if given at initialization
Author: Detche
Author date (UTC): 2016-11-29 15:38
Committer name: Detche
Committer date (UTC): 2016-11-29 15:38
Parent(s): e95d1599676ae10b950b2c069e666060005627cf
Signing key:
Tree: 2d13253864c88647caee2ff95d5463cbe225ed0e
File Lines added Lines deleted
botly/behaviour.py 2 3
botly/bot.py 17 5
botly/comm.py 1 1
botly/reaction.py 1 1
botly/task.py 1 1
File botly/behaviour.py changed (mode: 100644) (index 5221f53..25f3a07)
5 5 class Behaviour: class Behaviour:
6 6 """Behaviour class holds the reaction sorted by event name.""" """Behaviour class holds the reaction sorted by event name."""
7 7
8 def __init__(self, reactions):
8 def __init__(self, reactions, bot):
9 9 self.reactions = {} self.reactions = {}
10 10 # We will group reactions based on the event # We will group reactions based on the event
11 11 # they react on. # they react on.
12 print('Loading reactions into behaviour...')
13 12 for reaction in reactions: for reaction in reactions:
14 13 ename = reaction.eventName ename = reaction.eventName
15 print("Loading reaction '"
14 bot.print("Loading reaction '"
16 15 + reaction.moduleName + reaction.moduleName
17 16 + "' into event table '" + "' into event table '"
18 17 + ename + "'.") + ename + "'.")
File botly/bot.py changed (mode: 100644) (index 32af3d8..4b444c9)
... ... from botly.behaviour import Behaviour
17 17 class Bot: class Bot:
18 18 """Main class that represents the bot. Will load various dependencies.""" """Main class that represents the bot. Will load various dependencies."""
19 19
20 def __init__(self, rootModule, dbPath):
20 def __init__(self, rootModule, dbPath, logFile=''):
21 21 """Initialization loads database, reactions and tasks from drive.""" """Initialization loads database, reactions and tasks from drive."""
22 22 self.me = None self.me = None
23 23 self.server = None self.server = None
24 self.logPath = logFile
24 25
25 26 # Load database and models # Load database and models
26 27 Db.load(dbPath) Db.load(dbPath)
 
... ... class Bot:
36 37
37 38 # Load the bot behaviour (reactions to events) # Load the bot behaviour (reactions to events)
38 39 self.behaviour = Behaviour(load_reactions(self, self.behaviour = Behaviour(load_reactions(self,
39 rootModule + '.reactions'))
40 rootModule + '.reactions'), self)
40 41
41 42 # Set the default channel that was saved in bot settings # Set the default channel that was saved in bot settings
42 43 self.mainChannel = discord.Object( self.mainChannel = discord.Object(
 
... ... class Bot:
45 46 def live(self): def live(self):
46 47 """Runs the bot until it is exited. """ """Runs the bot until it is exited. """
47 48 # Listen to Discord's events (blocking call) # Listen to Discord's events (blocking call)
48 print("Connecting to Discord...")
49 self.print("Connecting to Discord...")
49 50 self.comm.run() self.comm.run()
50 print("\nBotly exited.")
51 self.print("\nBotly exited.")
51 52
52 53 def print(self, message, msgtype='INFO'): def print(self, message, msgtype='INFO'):
53 print('[' + msgtype + ']' + message)
54 m = '[' + msgtype + ']'
55 if not message.startswith('['):
56 m += ' '
57 m += message
58 if self.logPath is not None and len(self.logPath):
59 f = open(self.logPath, 'a')
60 f.write(m + '\n')
61 f.close()
62 else:
63 print(m)
54 64
55 65 async def leave(self): async def leave(self):
56 66 """Coroutine that disconnects the robot from Discord.""" """Coroutine that disconnects the robot from Discord."""
67 self.logFile.close()
68 self.logFile = None
57 69 await self.comm.logout() await self.comm.logout()
58 70
59 71 async def say(self, channel, message): async def say(self, channel, message):
File botly/comm.py changed (mode: 100644) (index 85d021b..069710f)
... ... class Comm(discord.Client):
15 15 'CacheMaxMessages')) 'CacheMaxMessages'))
16 16
17 17 async def on_ready(self): async def on_ready(self):
18 print('Bot ready. Press Ctrl+C to shutdown.')
18 self.bot.print('Bot ready.')
19 19 server = None server = None
20 20 for s in self.servers: for s in self.servers:
21 21 server = s server = s
File botly/reaction.py changed (mode: 100644) (index e27b1bf..4c0e2c3)
... ... def load_reactions(bot, reactionsParent):
127 127 # Inject instance info in reaction object # Inject instance info in reaction object
128 128 reaction.set_instance_info(bot) reaction.set_instance_info(bot)
129 129 reaction.set_module_name(module) reaction.set_module_name(module)
130 print('Loaded ' + str(len(reactions)) + ' reactions from drive.')
130 bot.print('Loaded ' + str(len(reactions)) + ' reactions from drive.')
131 131 return reactions return reactions
132 132
133 133
File botly/task.py changed (mode: 100644) (index 0e0cfa8..b3fc3c8)
... ... def load_tasks(bot, tasksParent):
206 206 # Inject instance info in task object # Inject instance info in task object
207 207 task._set_instance_info(bot) task._set_instance_info(bot)
208 208 task._set_module_name(module) task._set_module_name(module)
209 print('Loaded ' + str(len(tasks)) + ' tasks from drive.')
209 bot.print('Loaded ' + str(len(tasks)) + ' tasks from drive.')
210 210 return tasks return tasks
211 211
212 212
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/detche/Botly

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/detche/Botly

Clone this repository using git:
git clone git://git.rocketgit.com/user/detche/Botly

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main