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 @@ - - -
- -' + 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_