Exemple #1
0
    def test_getshow_group(self):
        requestText = u'Mike & Molly'

        keyConfig = ConfigParser.ConfigParser()
        keyConfig.read(["keys.ini", "..\keys.ini"])
        keyConfig.read(["bot_keys.ini", "..\\bot_keys.ini"])
        bot = telegram.Bot(keyConfig.get('BotIDs', 'TELEGRAM_BOT_ID'))
        chatId = keyConfig.get('BotAdministration',
                               'TESTING_TELEGRAM_GROUP_CHAT_ID')

        add.setCommandCode('getshow', open('../commands/getshow.py').read())
        getshow = main.load_code_as_module('getshow')
        getshow.run(bot, chatId, 'SalamiArmy', keyConfig, requestText)
Exemple #2
0
    def test_getshow(self):
        requestText = u'pussy'

        keyConfig = ConfigParser.ConfigParser()
        keyConfig.read(["keys.ini", "..\keys.ini"])
        keyConfig.read(["bot_keys.ini", "..\\bot_keys.ini"])
        bot = telegram.Bot(keyConfig.get('BotIDs', 'TELEGRAM_BOT_ID'))
        chatId = keyConfig.get('BotAdministration',
                               'TESTING_TELEGRAM_PRIVATE_CHAT_ID')

        add.setCommandCode('getshow', open('../commands/getshow.py').read())
        getshow = main.load_code_as_module('getshow')
        getshow.run('Admin', requestText, chatId)
Exemple #3
0
    def test_getanswer_group(self):
        requestText = 'what\'s in the Cuphead cups?'

        keyConfig = ConfigParser.ConfigParser()
        keyConfig.read(["keys.ini", "..\keys.ini"])
        keyConfig.read(["bot_keys.ini", "..\\bot_keys.ini"])
        bot = telegram.Bot(keyConfig.get('BotIDs', 'TESTING_TELEGRAM_BOT_ID'))
        chatId = keyConfig.get('BotAdministration',
                               'TESTING_TELEGRAM_GROUP_CHAT_ID')

        add.setCommandCode('getanswer',
                           open('../commands/getanswer.py').read())
        getanswer = main.load_code_as_module('getanswer')
        bot.sendMessage(chat_id=chatId,
                        text=getanswer.run('Admin', requestText))
Exemple #4
0
# coding=utf-8
import main
watchcric = main.load_code_as_module('watchbitcoin')


def run(bot, chat_id, user, keyConfig, message, totalResults=1):
    watchcric.unwatch(bot, chat_id, message)
Exemple #5
0
# coding=utf-8
import main
watchsound = main.load_code_as_module('watchsound')

def run(bot, chat_id, user, keyConfig, message, totalResults=1):
    watchsound.unwatch(bot, chat_id, message)


Exemple #6
0
# coding=utf-8
import uuid

from google.appengine.ext import ndb

watchedCommandName = 'iss'

import main
iss = main.load_code_as_module(watchedCommandName)


class WatchValue(ndb.Model):
    # key name: str(chat_id)
    currentValue = ndb.StringProperty(indexed=False, default='')


# ================================


def setWatchValue(chat_id, request_text, NewValue):
    es = WatchValue.get_or_insert(watchedCommandName + ':' + str(chat_id))
    es.currentValue = NewValue + (':' +
                                  request_text if request_text != '' else '')
    es.put()


def getWatchValue(chat_id):
    es = WatchValue.get_by_id(watchedCommandName + ':' + str(chat_id))
    if es:
        return es.currentValue
    return ''
Exemple #7
0
# coding=utf-8
import main
watchrand = main.load_code_as_module('watchrand')


def run(bot, chat_id, user, keyConfig, message, totalResults=1):
    watchrand.unwatch(bot, chat_id, message)
Exemple #8
0
# coding=utf-8
import main
watchlink = main.load_code_as_module('watchlink')


def run(bot, chat_id, user, keyConfig, message, totalResults=1):
    watchlink.unwatch(bot, chat_id, message)
Exemple #9
0
# coding=utf-8
import string

import main
getlink = main.load_code_as_module('getlink')

def run(bot, chat_id, user, keyConfig, message, num_to_send=1):
    requestText = message.replace(bot.name, "").strip()
    args = {'cx': keyConfig.get('Google', 'GCSE_OTHER_SE_ID'),
            'key': keyConfig.get('Google', 'GCSE_APP_ID'),
            'safe': 'off',
            'q': requestText}
    single_page_watch(args, bot, chat_id, keyConfig, requestText, user, 'getlink')

def unwatch(bot, chat_id, message):
    watches = main.getAllWatches()
    if ',' + str(chat_id) + ':' + getlink.CommandName + ':' + message + ',' in watches or \
            watches.startswith(str(chat_id) + ':' + getlink.CommandName + ':' + message + ',') or \
            watches.endswith(',' + str(chat_id) + ':' + getlink.CommandName + ':' + message) or \
                    watches == str(chat_id) + ':' + getlink.CommandName + ':' + message:
        main.removeFromAllWatches(str(chat_id) + ':' + getlink.CommandName + ':' + message)
        bot.sendMessage(chat_id=chat_id, text='Watch for /' + getlink.CommandName + ' ' + message + ' has been removed.')
    else:
        bot.sendMessage(chat_id=chat_id, text='Watch for /' + getlink.CommandName + ' ' + message + ' not found.')

def single_page_watch(args, bot, chat_id, keyConfig, requestText, user, CommandName):
    data, total_results, results_this_page = getlink.Google_Custom_Search(args)
    if 'items' in data and results_this_page >= 0:
        offset_this_page = 0
        total_sent = 0
        while offset_this_page < results_this_page:
Exemple #10
0
# coding=utf-8
import main
watchmc = main.load_code_as_module('watchmc')

def run(bot, chat_id, user, keyConfig, message, totalResults=1):
    watchmc.unwatch(bot, chat_id, message)


Exemple #11
0
# coding=utf-8
import main
watchdefine = main.load_code_as_module('watchdefine')


def run(bot, chat_id, user, keyConfig, message, totalResults=1):
    watchdefine.unwatch(bot, chat_id, message)
Exemple #12
0
import main
getgerman = main.load_code_as_module('getgerman')


def run(bot, chat_id, user, keyConfig, message, totalResults=1):
    getgerman.run(bot, chat_id, user, keyConfig, message, totalResults)
Exemple #13
0
# coding=utf-8
import string

from google.appengine.ext import ndb

import main
bitcoin = main.load_code_as_module('bitcoin')

watchedCommandName = 'bitcoin'


class BitcoinWatchValue(ndb.Model):
    # key name: str(chat_id)
    currentValue = ndb.StringProperty(indexed=False, default='')
    all_chat_ids = ndb.StringProperty(indexed=False, default='')


# ================================


def setWatchValue(chat_id, request_text, NewValue):
    es = BitcoinWatchValue.get_or_insert(watchedCommandName + ':' +
                                         str(chat_id))
    es.currentValue = NewValue + (':' + str(request_text)
                                  if str(request_text) != '' else '')
    es.put()


def getWatchValue(chat_id):
    es = BitcoinWatchValue.get_by_id(watchedCommandName + ':' + str(chat_id))
    if es:
Exemple #14
0
# coding=utf-8

from google.appengine.ext import ndb

import main
from telegram_commands.getsound import get_tracks

watchedCommandName = 'getsound'

import main
getsound = main.load_code_as_module(watchedCommandName)


class WatchValue(ndb.Model):
    # key name: str(chat_id)
    currentValue = ndb.StringProperty(indexed=False, default='')


# ================================


def setWatchValue(chat_id, request, NewValue):
    es = WatchValue.get_or_insert(watchedCommandName + ':' + str(chat_id) +
                                  ':' + request)
    es.currentValue = NewValue
    es.put()


def getWatchValue(chat_id, request):
    es = WatchValue.get_by_id(watchedCommandName + ':' + str(chat_id) + ':' +
                              request)
Exemple #15
0
# coding=utf-8
import main
watchiss = main.load_code_as_module('watchiss')

def run(bot, chat_id, user, keyConfig, message, totalResults=1):
    watchiss.unwatch(bot, chat_id, message, True)