diff --git a/bot.py b/bot.py index 9977cba..54eed51 100644 --- a/bot.py +++ b/bot.py @@ -3,10 +3,16 @@ import datetime from dateutil import tz +# use four space indentation only + from_zone = tz.gettz('UTC') to_zone = tz.gettz('Asia/Kolkata') +def msg_wrapper(): + return "PRIVMSG " + channel + " " + + def ping(): # responds to server pings ircsock.send("PONG :pingis\n") @@ -19,8 +25,12 @@ def joinchan(chan): ircsock.send("JOIN " + chan + "\n") +def welcome(): + ircsock.send(msg_wrapper() + ":Hello! " + user + " Welcome to jec-dev! Please introduce yourself with name, branch, sem, and area of interest \n ") + + def hello(): - ircsock.send("PRIVMSG " + channel + " :Hello! Welcome to jec-dev! Happy Hacking! :D\n") + ircsock.send(msg_wrapper() + ":Hello! Welcome to jec-dev! Happy Hacking! :D\n") if __name__ == '__main__': @@ -35,12 +45,15 @@ def hello(): ircsock.setblocking(False) ircsock.send("USER " + botnick + " " + botnick + " " + - botnick + " Test Bot\n") # user authentication + botnick + " Test Bot\n") # user authentication # here we actually assign the nick to the bot ircsock.send("NICK " + botnick + "\n") joinchan(channel) + with open("user_list_file", 'rb') as usernames: + user_list = usernames.read().split('\n') + while 1: try: ircmsg = ircsock.recv(2048) @@ -63,6 +76,11 @@ def hello(): user = split_message[0].split('!')[0] ircmsg = local.time().strftime('%H:%M') + ' ' + user + ' ' + ' '.join(split_message[3:]) log.write(ircmsg+'\n') + if user not in user_list: + welcome() + user_list.append(user) + with open("user_list_file", 'a') as usernames: + usernames.write(user+'\n') time.sleep(2) except Exception: continue diff --git a/logging/index.html b/logging/index.html deleted file mode 100644 index 57f5adb..0000000 --- a/logging/index.html +++ /dev/null @@ -1,166 +0,0 @@ - - - - - bootstrap compatable calendar - - - - - -
-

LOGS

-
-
- - - - - - diff --git a/logging/serve.go b/logging/serve.go deleted file mode 100644 index 995cc5f..0000000 --- a/logging/serve.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -Usage: - -p="8100": port to serve on - -d=".": the directory of static files to host -*/ -package main - -import ( - "flag" - "log" - "net/http" -) - -func main() { - port := flag.String("p", "8100", "port to serve on") - directory := flag.String("d", ".", "the directory of static file to host") - flag.Parse() - - http.Handle("/", http.FileServer(http.Dir(*directory))) - - log.Printf("Serving %s on HTTP port: %s\n", *directory, *port) - log.Fatal(http.ListenAndServe(":"+*port, nil)) -} diff --git a/logging/server.sh b/logging/server.sh deleted file mode 100644 index 9f26234..0000000 --- a/logging/server.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -case $1 in - start) - echo "Starting log server." - go run serve.go & - ;; - stop) - echo "Stopping log server." - sudo kill $(sudo lsof -t -i:5000) - ;; - *) - echo "jec-dev bot logging server." - echo $"Usage $0 {start|stop}" - exit 1 -esac -exit 0 diff --git a/logging/static/css/style.css b/logging/static/css/style.css deleted file mode 100644 index 25b375b..0000000 --- a/logging/static/css/style.css +++ /dev/null @@ -1,89 +0,0 @@ -.calendar-day { - width: 100px; - min-width: 100px; - max-width: 100px; - height: 80px; -} -.calendar-table { - margin: 0 auto; - width: 700px; -} -.selected { - background-color: #eee; -} -.outside .date { - color: #ccc; -} -.timetitle { - white-space: nowrap; - text-align: right; -} -.event { - border-top: 1px solid #b2dba1; - border-bottom: 1px solid #b2dba1; - background-image: linear-gradient(to bottom, #dff0d8 0px, #c8e5bc 100%); - background-repeat: repeat-x; - color: #3c763d; - border-width: 1px; - font-size: .75em; - padding: 0 .75em; - line-height: 2em; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - margin-bottom: 1px; -} -.event.begin { - border-left: 1px solid #b2dba1; - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; -} -.event.end { - border-right: 1px solid #b2dba1; - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; -} -.event.all-day { - border-top: 1px solid #9acfea; - border-bottom: 1px solid #9acfea; - background-image: linear-gradient(to bottom, #d9edf7 0px, #b9def0 100%); - background-repeat: repeat-x; - color: #31708f; - border-width: 1px; -} -.event.all-day.begin { - border-left: 1px solid #9acfea; - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; -} -.event.all-day.end { - border-right: 1px solid #9acfea; - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; -} -.event.clear { - background: none; - border: 1px solid transparent; -} -.table-tight > thead > tr > th, -.table-tight > tbody > tr > th, -.table-tight > tfoot > tr > th, -.table-tight > thead > tr > td, -.table-tight > tbody > tr > td, -.table-tight > tfoot > tr > td { - padding-left: 0; - padding-right: 0; -} -.table-tight-vert > thead > tr > th, -.table-tight-vert > tbody > tr > th, -.table-tight-vert > tfoot > tr > th, -.table-tight-vert > thead > tr > td, -.table-tight-vert > tbody > tr > td, -.table-tight-vert > tfoot > tr > td { - padding-top: 0; - padding-bottom: 0; -} - -.current { - cursor: pointer; -} diff --git a/logging/static/js/index.js b/logging/static/js/index.js deleted file mode 100644 index 2dc85c8..0000000 --- a/logging/static/js/index.js +++ /dev/null @@ -1,302 +0,0 @@ -var $currentPopover = null; -$(document).on('shown.bs.popover', function(ev) { - var $target = $(ev.target); - if ($currentPopover && ($currentPopover.get(0) != $target.get(0))) { - $currentPopover.popover('toggle'); - } - $currentPopover = $target; -}).on('hidden.bs.popover', function(ev) { - var $target = $(ev.target); - if ($currentPopover && ($currentPopover.get(0) == $target.get(0))) { - $currentPopover = null; - } -}); - - -//quicktmpl is a simple template language I threw together a while ago; it is not remotely secure to xss and probably has plenty of bugs that I haven't considered, but it basically works -//the design is a function I read in a blog post by John Resig (http://ejohn.org/blog/javascript-micro-templating/) and it is intended to be loosely translateable to a more comprehensive template language like mustache easily -$.extend({ - quicktmpl: function(template) { - return new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('" + template.replace(/[\r\t\n]/g, " ").split("{{").join("\t").replace(/((^|\}\})[^\t]*)'/g, "$1\r").replace(/\t:(.*?)\}\}/g, "',$1,'").split("\t").join("');").split("}}").join("p.push('").split("\r").join("\\'") + "');}return p.join('');") - } -}); - -$.extend(Date.prototype, { - //provides a string that is _year_month_day, intended to be widely usable as a css class - toDateCssClass: function() { - return '_' + this.getFullYear() + '_' + (this.getMonth() + 1) + '_' + this.getDate(); - }, - //this generates a number useful for comparing two dates; - toDateInt: function() { - return ((this.getFullYear() * 12) + this.getMonth()) * 32 + this.getDate(); - }, - toTimeString: function() { - var hours = this.getHours(), - minutes = this.getMinutes(), - hour = (hours > 12) ? (hours - 12) : hours, - ampm = (hours >= 12) ? ' pm' : ' am'; - if (hours === 0 && minutes === 0) { - return ''; - } - if (minutes > 0) { - return hour + ':' + minutes + ampm; - } - return hour + ampm; - } -}); - - -(function($) { - - //t here is a function which gets passed an options object and returns a string of html. I am using quicktmpl to create it based on the template located over in the html block - var t = $.quicktmpl($('#tmpl').get(0).innerHTML); - - function calendar($el, options) { - //actions aren't currently in the template, but could be added easily... - $el.on('click', '.js-cal-prev', function() { - switch (options.mode) { - case 'year': - options.date.setFullYear(options.date.getFullYear() - 1); - break; - case 'month': - options.date.setMonth(options.date.getMonth() - 1); - break; - case 'week': - options.date.setDate(options.date.getDate() - 7); - break; - case 'day': - options.date.setDate(options.date.getDate() - 1); - break; - } - draw(); - }).on('click', '.js-cal-next', function() { - switch (options.mode) { - case 'year': - options.date.setFullYear(options.date.getFullYear() + 1); - break; - case 'month': - options.date.setMonth(options.date.getMonth() + 1); - break; - case 'week': - options.date.setDate(options.date.getDate() + 7); - break; - case 'day': - options.date.setDate(options.date.getDate() + 1); - break; - } - draw(); - }).on('click', '.js-cal-option', function() { - var $t = $(this), - o = $t.data(); - if ($(this).hasClass('calendar-day current')) { - var curr = new Date(o.date) - var dd = ("0" + curr.getDate()).slice(-2) - var mm = ("0" + (curr.getMonth() + 1)).slice(-2) - var y = curr.getFullYear() % 2000; - - var formatted_date = dd + '-' + mm + '-' + y; - console.log(formatted_date) - window.location = '../logs/' + formatted_date + '.log' - } - - if (o.date) { - o.date = new Date(o.date); - } - $.extend(options, o); - draw(); - }).on('click', '.js-cal-years', function() { - var $t = $(this), - haspop = $t.data('popover'), - s = '', - y = options.date.getFullYear() - 2, - l = y + 5; - if (haspop) { - return true; - } - for (; y < l; y++) { - s += ''; - } - $t.popover({ - content: s, - html: true, - placement: 'auto top' - }).popover('toggle'); - return false; - }).on('click', '.event', function() { - var $t = $(this), - index = +($t.attr('data-index')), - haspop = $t.data('popover'), - data, time; - - if (haspop || isNaN(index)) { - return true; - } - data = options.data[index]; - time = data.start.toTimeString(); - if (time && data.end) { - time = time + ' - ' + data.end.toTimeString(); - } - $t.data('popover', true); - $t.popover({ - content: '

' + time + '

' + data.text, - html: true, - placement: 'auto left' - }).popover('toggle'); - return false; - }); - - function dayAddEvent(index, event) { - if (!!event.allDay) { - monthAddEvent(index, event); - return; - } - var $event = $('
', { - 'class': 'event', - text: event.title, - title: event.title, - 'data-index': index - }), - start = event.start, - end = event.end || start, - time = event.start.toTimeString(), - hour = start.getHours(), - timeclass = '.time-22-0', - startint = start.toDateInt(), - dateint = options.date.toDateInt(), - endint = end.toDateInt(); - if (startint > dateint || endint < dateint) { - return; - } - - if (!!time) { - $event.html('' + time + ' ' + $event.html()); - } - $event.toggleClass('begin', startint === dateint); - $event.toggleClass('end', endint === dateint); - if (hour < 6) { - timeclass = '.time-0-0'; - } - if (hour < 22) { - timeclass = '.time-' + hour + '-' + (start.getMinutes() < 30 ? '0' : '30'); - } - $(timeclass).append($event); - } - - function monthAddEvent(index, event) { - var $event = $('
', { - 'class': 'event', - text: event.title, - title: event.title, - 'data-index': index - }), - e = new Date(event.start), - dateclass = e.toDateCssClass(), - day = $('.' + e.toDateCssClass()), - empty = $('
', { - 'class': 'clear event', - html: ' ' - }), - numbevents = 0, - time = event.start.toTimeString(), - endday = event.end && $('.' + event.end.toDateCssClass()).length > 0, - checkanyway = new Date(e.getFullYear(), e.getMonth(), e.getDate() + 40), - existing, - i; - $event.toggleClass('all-day', !!event.allDay); - if (!!time) { - $event.html('' + time + ' ' + $event.html()); - } - if (!event.end) { - $event.addClass('begin end'); - $('.' + event.start.toDateCssClass()).append($event); - return; - } - - while (e <= event.end && (day.length || endday || options.date < checkanyway)) { - if (day.length) { - existing = day.find('.event').length; - numbevents = Math.max(numbevents, existing); - for (i = 0; i < numbevents - existing; i++) { - day.append(empty.clone()); - } - day.append( - $event.toggleClass('begin', dateclass === event.start.toDateCssClass()).toggleClass('end', dateclass === event.end.toDateCssClass()) - ); - $event = $event.clone(); - $event.html(' '); - } - e.setDate(e.getDate() + 1); - dateclass = e.toDateCssClass(); - day = $('.' + dateclass); - } - } - - function yearAddEvents(events, year) { - var counts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - $.each(events, function(i, v) { - if (v.start.getFullYear() === year) { - counts[v.start.getMonth()]++; - } - }); - $.each(counts, function(i, v) { - if (v !== 0) { - $('.month-' + i).append('' + v + ''); - } - }); - } - - function draw() { - $el.html(t(options)); - //potential optimization (untested), this object could be keyed into a dictionary on the dateclass string; the object would need to be reset and the first entry would have to be made here - $('.' + (new Date()).toDateCssClass()).addClass('today'); - if (options.data && options.data.length) { - if (options.mode === 'year') { - yearAddEvents(options.data, options.date.getFullYear()); - } else if (options.mode === 'month' || options.mode === 'week') { - $.each(options.data, monthAddEvent); - } else { - $.each(options.data, dayAddEvent); - } - } - } - - draw(); - } - - ; - (function(defaults, $, window, document) { - $.extend({ - calendar: function(options) { - return $.extend(defaults, options); - } - }).fn.extend({ - calendar: function(options) { - options = $.extend({}, defaults, options); - return $(this).each(function() { - var $this = $(this); - calendar($this, options); - }); - } - }); - })({ - days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], - months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], - shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], - date: (new Date()), - daycss: ["c-sunday", "", "", "", "", "", "c-saturday"], - todayname: "Today", - thismonthcss: "current", - lastmonthcss: "outside", - nextmonthcss: "outside", - mode: "month", - data: [] - }, jQuery, window, document); -})(jQuery); - -var data = [] -//data must be sorted by start date - -//Actually do everything -$('#holder').calendar({ - data: data -}); diff --git a/logging/static/less/style.less b/logging/static/less/style.less deleted file mode 100644 index f9933db..0000000 --- a/logging/static/less/style.less +++ /dev/null @@ -1,79 +0,0 @@ -@daywidth: 100px; - -//from bootstrap variables: - -@state-success-text: #3c763d; -@state-success-bg: #dff0d8; -@state-info-text: #31708f; -@state-info-bg: #d9edf7; -//@state-warning-text: #8a6d3b; -//@state-warning-bg: #fcf8e3; -//@state-danger-text: #a94442; -//@state-danger-bg: #f2dede; - - -.calendar-day { - width: @daywidth; - min-width: @daywidth; - max-width: @daywidth; - height: 80px; -} -.calendar-table { margin: 0 auto; width: @daywidth * 7;} - -.selected { background-color: #eee;} -.outside .date {color: #ccc; } -.timetitle { - white-space: nowrap; - text-align: right; -} - -.colors(@color, @text) { - @top: @color; - @border: darken(@color, 15%); - @bottom: darken(@color, 7.5%); - border-top: 1px solid @border; - border-bottom: 1px solid @border; - background-image: linear-gradient(to bottom, @top 0px, @bottom 100%); - background-repeat: repeat-x; - color: @text; - border-width: 1px; - - &.begin { - border-left: 1px solid @border; - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; } - &.end { - border-right: 1px solid @border; - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; - } -} - -.event { - .colors(@state-success-bg, @state-success-text); - font-size: .75em; - padding: 0 .75em; - line-height: 2em; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - margin-bottom: 1px; - &.all-day { .colors(@state-info-bg, @state-info-text); } - &.clear { background: none; border: 1px solid transparent; } -} - - -.cell-styles(@ruleset) { - & > thead > tr, & > tbody > tr, & > tfoot > tr { - & > th, & > td { - @ruleset(); - } - } -} - -.table-tight { - .cell-styles({ padding-left: 0; padding-right: 0; }); -} -.table-tight-vert { - .cell-styles({ padding-top: 0; padding-bottom: 0; }); -} \ No newline at end of file diff --git a/user_list_file b/user_list_file new file mode 100644 index 0000000..cae8c33 --- /dev/null +++ b/user_list_file @@ -0,0 +1,50 @@ +:wolfe.freenode.net +twain +t +:knrai_ +:knrai__ +:Gaurav_ +:verne.freenode.net +ec-dev-botwain +:sandesh +:jec-dev-bot +:knrai +:barjavel.freenode.net +:tolkien.freenode.net +998. +:tolkien.freenode.net +:zeekhuge +:orwell.freenode.net +well.freenode.net +998. +:tolkien.freenode.net +:krishna +:cherryh.freenode.net +:leguin.freenode.net +iversity +keep +:san-D +:Mutter +:jec-dev-botwain +:krishna__ +Bearstech +:karatkievich.freenode.net +.net. +@ChanServ +:karatkievich.freenode.net +:Mutter_ +:u043 +:rajaniemi.freenode.net +net +thank +:BongBrahm_durwas +:durwasa +:vipul20 +:krishna2 +:knrai1 +:botwayne +:pikapi +c-dev-botwain +372 +:Guest75630 +:san-d_