This repository has been archived by the owner on May 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fabc64b
commit d8e295f
Showing
5 changed files
with
114 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
# -*- coding: utf-8 -*- | ||
#this file includes the mcgit object | ||
|
||
import configparser | ||
import json | ||
from gittle import Gittle | ||
from mcdlog import * | ||
|
||
helpmsg = '''------thanks for use mcgit------ | ||
those are basic functions: | ||
!!mcg help -show this help message | ||
!!mcg commit list -show a list of commits available | ||
!!mcg commit [info] -reboot the server and commit current world | ||
!!mcg rollback [commit] -reboot the server and rollback the world to a commit | ||
!!mcg branch now -show which branch the server is on now | ||
!!mcg branch list -show all branches avaliable | ||
!!mcg branch change [branch] -reboot and change the server to another branch | ||
(the world now will commit with info 'changebranch') | ||
!!mcg branch delete [branch] -delete a branch | ||
(if you are deleting the branch server is running on,the server will load master branch after reload) | ||
!!mcg merge [branch] -merge the branch to master | ||
--------------------------------''' | ||
|
||
class mcgit(object): | ||
def __init__(self): | ||
conf = configparser.ConfigParser() | ||
try: | ||
conf.read('mcgit.properties') | ||
except: | ||
log('mcgit failed to read a config file.Creating a new one') | ||
conf.add_section('savePath') | ||
conf.set('savePath', 'path', './mcgit') | ||
#try: | ||
#saveRepo = Gittle.init(conf.get('savePath','path')) | ||
#except: | ||
#exitlog('failed to init world repo...', 1, traceback.format_exc()) | ||
|
||
def onServerInfo(self, server, info): | ||
if (info.isPlayer == 0): | ||
pass | ||
else: | ||
if info.content.startswith('!!mcg'): | ||
args = info.content.split(' ') | ||
if (args[1] == 'help'): | ||
for line in helpmsg.splitlines(): | ||
server.tell(info.player, line) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gittle==0.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
# -*- coding: utf-8 -*- | ||
#this file is for handleing server info and parsing those info into a object | ||
|
||
import re | ||
|
||
class parseResult(object): | ||
def __init__(self): | ||
self.hour = 0 | ||
self.min = 0 | ||
self.sec = 0 | ||
self.sourceProcess = '' | ||
self.isPlayer = 0 | ||
self.player = '' | ||
self.message = '' | ||
|
||
def parse(line): | ||
result = parseResult() | ||
result.hour = line[1:3] | ||
result.min = line[4:6] | ||
result.sec = line[7:9] | ||
result.sourceProcess = re.search(r'[[](.*?)[]]', line[11:]).group()[1:-1] | ||
if (result.sourceProcess == 'Server thread/INFO') and (line[33:].startswith('<')): | ||
player = re.search(r'[<](.*?)[>]', line[33:]).group()[1:-1] | ||
if player != '': | ||
result.isPlayer = 1 | ||
result.player = player | ||
content = line[33:].replace('[' + result.sourceProcess + ']: ', '' , 1) | ||
result.content = content.replace('<' + result.player + '> ', '', 1) | ||
else: | ||
result.isPlayer = 0 | ||
result.player = '' | ||
result.content = line[11].replace('[' + result.sourceProcess + ']: ' , '' , 1) | ||
return result |